Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

21 June 2014

Planning a journey.

Maybe you've wondered where I've been. Maybe not, of course. No problem, I'm telling anyway.

Well, I was here. Looking around, meeting wonderful people. Wondering what to do next, looking for a project.

Appreciating the usefulness of Wikipedia and Twitter, once you have a project. Or even just half of a problem, a vague idea. The Wikipedia Effect can be a blessing, in the latter case.

So, now I'm looking at this Flask. I like it.

So, a website is on its way. A static website, thanks to Frozen-Flask.

(Why static? Because "let's start simple" sounds like a good idea.)

And in a month... EuroPython.

13 April 2014

When I grow up.

[Puts on her best wise auntie look.]

Growing up is also about choices.

[Wise auntie look comes crashing down.]

No, I'm not that good at following my own wisdom. I want to do everything, at once.

But you should also find out which way is your way. Start with your strength first, feel great, then challenge yoursef out of your comfort zone later.

For instance, let's say that you want to move your Python knowledge to yet another level.

But the further you go, the more the roads you see in front of you.

So now it's time for a test. You know, like those "Which Star Wars Character Are You?" tests. But simpler.

And let's hope that this time I don't come out as Greedo.

Q1: Where did you sit when you were in school?

  1. First row. Hand up.
  2. Last row. Under the radar.
  3. School?

Q2: Pick one light reading.

  1. War and Peace. And without skipping the philosophical digressions.
  2. Harry Potter.
  3. The Evil Genius Guide to Taking Over the World.

Q3: Are you still here?

  1. Of course. I don't leave what I'm reading behind.
  2. Uh... yeah?
  3. [Silence. Somewhere someone's smashing something to see how it works.]

Results! Majority of...

  1. Have a cookie. Yes, you can have it. Go to Think Python: How to Think Like a Computer Scientist. You will be thorough, as usual, and patient. You will come out of the book with a methodic understanding of concepts with some theoretical background (you're allowed to peek into appendices before the end and see what the big-Oh notation is), the satisfaction of overcoming the tricks of many nice exercises, and a beautiful vocabulary (courtesy of the glossary at the end of each chapter).
  2. Have a cookie. Yes, you can take a cookie for each one of your friends. Bring them all here, while we're at it. No, I'm not sending you to the principal's office. I'm sending you to the intermediate projects of the Python Workshops that you can find via those great guys at OpenHatch. Some projects of the Boston Python Workshop are here; but you can find more, and they're always growing. If you're lucky (and, mostly, US-based) you can go and play with your friends live! at one of these workshops. But I guess that just the idea of making your own game of Snakes beats that tic-tac-toe that you were playing with over there.
  3. Have a cookie. Come on, come here. Please. I'll be quick. Have a cookie, yes. I know you're thinking about how to steal the jar. But I have something better for you: go to newcoder.io and see if you can get those tasty cookies. They're not easy to get. You have to deal with the world out there. You'll have to get your hands dirty, I'm afraid. I bet you... Hey! Where are you?

No majority?

You got me. Have all the cookies, you deserve them. Now throw a dice with a number of faces that is a multiple of three to choose between the options above.

Anyway.

Now have fun. Whoever you are, Python's got something for you.

And after you had fun your way, explore the rest. Challenge and surprise yourself.

Let's learn Python and grow up.

My poster at PyCon 2014 will be tomorrow (today, in EST) at 10:00am. Come and say hello.

12 April 2014

An official tutorial (and a gentleman).

I have fond memories of The Python Tutorial on python.org. My first Python textbook was Learn Python The Hard Way, but as you might have gathered, around the tenth chapter of printing text I was a bit dispirited. So I went for something that sounded short, to the point, and a bit official, even dry.

The Python Tutorial was a great help. I read (more on this "read") it, I found what I wanted to know: that's the way you write a while loop, this is the way you define a function, classes are written according to this syntax. Then I moved on, keeping the website as a go-to reference for my little doubts.

I've just gone through it again, and I realise that I was saved by my worst flaws. No, not from, by.

First of all, I can be restless: I got to Defining Functions I enjoyed it, then I peeked into the next chapter and I saw Data Structures, I thought that was useful and quite easy to understand, and that section on Lambda Expressions in the middle of the two left my radar.

Then there's the fact that I knew something about programming. It was in Java, it was very little, but it was more than zero. This means that I knew the names of the topics: if I wanted to write was a while, I knew to look for "loops." (Actually, the while is covered in an example in the chapter before loops. The organisation of the topics is not the strong point of The Python Tutorial.)

Even how I didn't know very much played in my favour: it that the scope of my quest to do what I already knew wasn't so wide to get myself lost in small(ish) details.

So I found The Python Tutorial a great tool, under these two conditions: some (even very basic) background in code, some tendency (ability?) to skim and overlook topics that you'll get back to at a second reading. Also, the topics are many but the pace is quick, and the examples are simple: it's a perfect complement to Dive Into Python 3.

Looking again at The Python Tutorial after using it as a "beginners' text" was a bit a "Princess and the Frog" story: you think that you're over what's in there, then you find out that there's a lot more. The most important thing is in the URL: it's the official tutorial on the PSF website, so it's a gateway for the official documentation.

And there are many other good reasons why The Python Tutorial should always be there in your bookmarks: that drop-down menu (on the upper left of each page) that takes you from the page in Python 2.x to the same page in Python 3.x; the glossary (again, both in the 2.x and 3.x flavour).

So: this official tutorial can sound (or even be) a bit aloof sometimes. But you can (and shall) become fond of the company of this gentleman.

10 April 2014

The Big Jump.

So, are you ready for the next level?

So let's Dive Into Python 3.

You should know how to deal with an if or with a loop, in Python or in another language. You should have learned what a function is. You should have an idea of what "Object Oriented" means. You should be able to keep cool when you see that there's a parallel with a language you don't know.

So you dive straight into the good stuff. In detail.

I said "in detail": the chapters are quite long. But they're well subdivided into sections, so if you don't have to swallow everything in one gulp. I'm looking at you, dear chapter on regular expressions.

And since we're on the subject of chapters and sections: Dive Into Python 3 is probably the most pleasantly readable textbook that I have met. There are the collapsible tables of contents; there is just one column, so you're not distracted from what you're studying. The font is beautiful and easy to read.

Another great idea: the difficulty of each topic is marked at the beginning of each chapter. I think that difficulty is always quite subjective; but it's always good to remark that sometimes prerequisites are harder than more advanced topics.

And then there's the text itself. The writing is conversational but precise; it takes you seriously and it doesn't make you feel stupid if you don't know something. The examples and the snippets of code are neither trivial nor unnecessarily convoluted, and they are cleverly annotated outside the code itself.

So: if you're already comfortable with programming, if you automatically go beyond the "reading" part of teaching yourself into the "writing code and playing around with it" part, here's a fantastic book for you.

Now you might wonder where's the catch. There's mostly one: Dive Into Python 3 is, well, a textbook on Python 3. This means that you have to look elsewhere for Python 2.x; but if you're comfortable with Dive Into Python 3 you shouldn't find googling "Python 2 and 3 differences" too hard. I recommend this page on python.org, that being the website of the PSF is trustworthy by definition. Dive Into Python 3 has an appendix on the 2to3 script; but it's an appendix, and it's marked as "very difficult" in a book that is already not so easy.

Another possible issue is that you cannot really skip chapters. Sections, maybe. But you have to follow the path that's been laid down in the book. This is not a bad thing; but if you're reading something at this level you might sometimes wish to have the chance of a more flexible syllabus. But, on the other hand, if you're at this level you can realise when you have to go back and where to; so no harm done.

One last thing: there are many links from which you can take your study to a deeper level, so you can complement the somewhat "cookbook" flavour of Dive Into Python 3 by looking at the official documentation or even at a good post on a blog. But beware the "Problem with Wikipedia"...

6 April 2014

You and me.

Codecademy sweeps you off your feet. At least, as you might have guessed in the last post (sorry for the hiatus), it swept me off my feet. But you need a quiet bedroom to rest after the most amazing party, to regain the strength you need to plan the next one.

Welcome to Python for you and me.

Take a seat. A cup of tea, possibly caffeine-free. Reorganise what’s your mind has devoured.

The topics are already there for you, clearly subdivided into short chapters. Nothing too theoretical, mostly to-the-point examples that will immediately bring back to your mind what you’ve studied, or make you wish to learn more about something you haven’t seen before.

It’s great if you want to revise the very basics. It’s even better if you’ve never met the topic: you are likely to get the general idea of it, the sketch of a map to help you not to get lost when you will bring your study to the next level.

That’s basically the best and the worst about Python for you and me: it’s simple. It’s unthreatening, in the best meaning of the word, so you don’t spin into "I’ll never get this!" mode. But you must be wary of complacency. You read a chapter, then the other, then the next: everything is calm and quiet. So quiet that you don’t check if you really understood what you read. The code samples are simple. (I just tried to say the last sentence out loud, my tongue is tied in a knot. Let’s move on.) The lack of exercises is tempting you into not challenging yourself.

I love Python for you and me. It’s the reference text to keep on your (metaphorical) bedside table: you revise your background, you go back and forth a few chapter to get some context, you check your general position. It’s the perfect companion for Codecademy or Learn Python the Hard Way: I suggest a combination with the latter if you like the Hard Way and you don’t mind (or even enjoy) being taken between two opposite poles; if you like a more playful or relaxed approach, I would pair with the former.

Last but not least: don’t underestimate how far the book will take you. Under the unassuming look you will find an amazing guide to PEP 8 guidelines, a great introduction to testing (and since you will already be nervous because if test will fail, the relaxed approach of Python for you and me will be a real help), the basis of structuring and releasing a project (and since you will already be self-conscious of the big step, the Python for you and me style will put you at ease).

All in all: a fantastic resource. The soft bed from which you rise so much more rested, before moving on to the next level.

And now, on to the next level.

2 April 2014

Do you want to build a project? (Come on, let's go and play.)

This time I'm going to play it safe. Maybe too safe. But hey - I've always been against criticising something just because it's fashionable.

So, let's talk about Codecademy: the Python track and beyond.

I was wary of Codecademy. Exercises without apparent theory? Mmmh. A little stern teacher inside me kept repeating me sermons about pampering myself too much. But then, at PyCon 2013, Jessica McKellar introduced Python for beginners with the hands-on Codecademy tool. And I fell in love.

Codecademy is the Addictive and Playful Way to approach the Hard Way. It's the cool aunt who gives you her Led Zeppelin CDs, teaches you not to give up listening even if it's not what you're used to, but never brags about "in my times". And as an icing on the cake she tells you about her escapades when she was listening to that song.

You do your exercises and you don't fool yourself into thinking that you know how to do something just because you read the theory. Even better: your exercises are checked as soon as you've done them, so you know if you know or you don't know. You soon become committed not to lose your winning streak, so you exercise every day. You want to grab those nice colourful badges, so you challenge your fear of not being good enough.

And you learn. Not so slowly, and surely.

The topics are introduced at a fundamentally constant pace. If you pick up the basics quickly, you can dash through the first tutorials and then take your time to absorb the harder stuff (and since the track touches concepts as far as lambda expressions, the harder stuff is not always so intuitive). If you are the kind of student who gains velocity over time, you can spend your first days to get acquainted with the first concepts and then enjoy the more complex ideas.

After you've learned your concepts (even if you didn't notice that you were learning, you were too busy solving the problem at hand), for each section of the track you have a project to put in practice everything: a project on larger and more satisfying scale than an "exercise section" in a traditional textbook, but small enough not to derail you in an overwhelmingly ambitious plan. (There isn't one for the Advanced Topics, but once you'll be there you'll be old and wise enough to take care of yourself. It would be nice, but that's a minor issue.)

And then, you go beyond! The community gives you nice projects. You can give back to the community with nice projects.

You try your skills at dealing with APIs, and you learn the wider concepts you need for those APIs.

You learn to ask questions and get answers (and that's another skill, and a most useful one) discussing with other students in the forum: a good practice for when you will eventually interact with others on Stack Overflow.

To top it all off, you have a glossary that will help you in those "I knew what this word meant"/"How should I say that?" moments.

Theory and practice, play and commitment. You have it all. You just have not to fall into the trap of "it's not serious if it's not painful."

Enjoy.

The title of this post is a reference to my favourite movie of this past winter, the story of a young woman who learns to control her power and to put it to a better use, for the fun of everyone including herself. Here's something to show you its funny side:

1 April 2014

I did it my (hard) way.

Let's start this series by gambling all my credibility.

[Deep breath.]

[Another deep breath.]

[Yet another deep breath.]

The hard way is not my way.

There, I said it. And now, please, let me defend my position.

I know that Learn Python The Hard Way is one of the, if not the, most common answers to the question "I want to learn Python, can you suggest me a tutorial?" - so I don't doubt that there are people who find it extremely helpful. And I don't think it's a bad book; but I think that it has some serious limits.

Learn Python The Hard Way reminds me of Gioacchino Rossini's joke about Richard Wagner: "a composer who has beautiful moments but awful quarter hours."

Here's an example of a beautiful moment; even better, a deeply wise one:

As you study this book, and continue with programming, remember that anything worth doing is difficult at first. Maybe you are the kind of person who is afraid of failure so you give up at the first sign of difficulty. Maybe you never learned self-discipline so you can't do anything that's "boring." Maybe you were told that you are "gifted" so you never attempt anything that might make you seem stupid or not a prodigy. Maybe you are competitive and unfairly compare yourself to someone like me who's been programming for 20+ years.

Whatever your reason for wanting to quit, keep at it. Force yourself. If you run into a Study Drill you can't do, or a lesson you just do not understand, then skip it and come back to it later. Just keep going because with programming there's this very odd thing that happens. At first, you will not understand anything. It'll be weird, just like with learning any human language. You will struggle with words, and not know what symbols are what, and it'll all be very confusing. Then one day BANG your brain will snap and you will suddenly "get it."

(Emphasis mine.)

I cannot find a single fault in this passage.

It's encouraging and it keeps you grounded at the same time. It spells out the incredibly important study trick of "your tutorial is not a TV series, spoilers are good." It reminds me of what John von Neumann once said, that in mathematics you don't understand things, you get used to them (something should be taught to every child, to dispel that horrid idea that "I don't understand this" means "I'm hopelessly not good at this").

I want to stand up and cheer.

But then there are the quarter hours.

Twenty. Nine. Chapters. To. Get. To. See. An. If.

Twenty. Nine.

This self-discipline borders on masochism.

As someone who always finds it easier to solve other people's problems than to imagine brand new problems (although I'm good at finding the problematic limits of any solution; but I digress) I truly appreciate the incredible amount of exercises that the book offers. But there's a terrible side effect of this "old master teaches young apprentice by the way of apparently mundane and repetitive tasks" approach: the young apprentice becomes so diligent that they never step out of line. It's not just a matter of being overwhelmed by the amount of lines that you have to copy: it's ending up depending on the teacher even to break the toy to see what's in there.

Perhaps I'm giving for granted the desire to rebel. The joy of "hey, let's see what it happens if I turn left instead of right as you told me!" The mindset of not taking anything for granted.

(I'm not sure whether the paragraph above is more introspective or paradoxical.)

If you don't have this questioning instinct, it's likely that Learn Python The Hard Way is the perfect book to kickstart it; and since this instinct is a fundamental tool in any scientific and technical field, The Hard Way could be a very good way to start your journey into programming.

By the way: The Hard Way will also take you quite far if you stick with it. Many of the topics in the poster are there.

I still think it's very hard, if not altogether impossible, to teach rebellion - especially through discipline. But maybe it's just my hedonism, all play and not enough work, no reverence to my betters.

You decide. I'm off to boost my rebellious feelings with some Wagner. The last quarter hour of The Valkyrie. Beautiful opera about a girl rebelling to her father to obey her father's wishes; it's worth sitting through all four hours (plus intervals) of it. By the way: have I ever told you that I love Wagner much more than I like Rossini? Personal taste can be so strange and, well, personal.

Everyone has their own way, after all.

Unfortunately necessary disclaimer: let's not go into the "Wagner and politics" or the "Wagner was an [expletive] who lived on his friends' money while having affairs with their wives" issue. At least, not here.

19 March 2013

More PyCon! It's a wish, not just a title.

I left the last post minutes before Jessica McKellar's keynote at PyCon 2013. Unfortunately the keynote was cancelled. Raymond Hettinger followed a series of lightning talk with a keynote the theme of which was "Python is amazing" (I don't rememeber the exact words, but that's the main idea). YAY!

Getting started with automated testing, by Carl Meyer, was a great introductory talk, a good way to remind me that not writing tests is not (just) being lazy, it's counterproductive (and therefore leads to more work later).

Then I moved on to a couple of much-needed talk on community building: Scaling community diversity outreach, by (take a breath) Asheesh Laroia, Jessica McKellar, Dana Bauer and Daniel Choi, and, after lunch, How (Not) To Build An OSS Community by Daniel Lindsley. So far my contacts in London for programming have been by mentor in the TechAbility programme (my gateway drug pusher, the way I really got into programming - thank you Ben!), a couple of friends and of course my husband (but I tend not to talk too much about computers with him). I probably never realized how much I miss a "real life" (as opposed to "just IRC/internet") community since I got here. There are the GNOME beer events, of course! But the only London Python User Group I see online is "professionals only", so it doesn't look very newcomers-friendly... and there is no chapter of the PyLadies in London. (I was told that I should set one up - but I cannot do it on my own. And yes, dear Londoners, this is another cry for help!) All of this probably just means that I need a job, I am tired of doing things on my own. End of the rant, sorry.

Later in the afternoon, yet another fantastic talk. Lynn Root presented Sink or swim: 5 life jackets to throw to New Coders. It was perfectly tailored for the stage I am in my programming education: I know the basics, now what? Well, there is her website, then there is... teaching others. I sense a pattern here...

And then I went to rest, because the day after I had to present my poster and I was already too nervous.

The day after - the last day - was basically "hey, here's my poster". I had presented a poster only once in my life, but it was a much smaller (although quite big!) conference, and it was in another field (game theory).

And you know what? I loved it! (Even if it meant missing the keynotes... and the other posters.)

I talked about what I did last summer, why it's a good idea to do something like that, how you do it (and what you shouldn't do); most important, I spread the word about the Outreach Program for Women - all the leaflets but one or two were gone by the end of the session, and many people went away with the link to the website scribbled on a piece of paper!

I wasn't able to stand on my feet, afterwards. So: nap! And then, introduction to sprints...

...so that yesterday I managed to find something for me at the OpenHatch sprint. I helped with a webpage that was incomplete (a webpage that was... teaching - how to contribute to an OpenSource project. Mmmmh, more of that pattern), and I cleaned up the wiki a bit. I had never heard of OpenHatch before this conference, but I hope this is the beginning of a beautiful frienship (to use the words of Claude Rains in Casablanca).

And now I should be packing (how will I stuff all the t-shirts I got into my suitcase?) and go on my way...

So: a big thank you to PyCon, to the PSF (who generously sponsored my travel and my hotel!), to all the wonderful people I met, too many to fit in a post here (also: I am terrible with names, I would probably forget someone). And... maybe see you in Florence later this year!

PS: I wrote the post this morning (PST). It's now almost night (also PST, I don't want to know what time it is in London), and I am at the airport - flight delayed by approximately 3 hours. I use the airport connection to give you... the poster! With a huge thank you to Marina Zhurakhinskaya and Meg Ford who sent me so many useful suggestions.

16 March 2013

So: PyCon!

I should have probably written something in the last days, but I was, well... overwhelmed.

I arrived in Santa Clara (after about 12 hours on a plane, and that was just to San Francisco) on the 12th - in the afternoon, local time. A few hours to rest, to get used to the jet lag, and then...

TUTORIALS!

A hands-on introduction to Python for beginning programmers, by Jessica McKellar, was the perfect start: a smooth (re)introduction to the basics - it made me feel well. Hands-on intermediate Python, by Matt Harrison, followed. Fantastic. I learned so much, in such a short time: the balance of theory and practice was the right one. And the handouts are going to provide a very interesting (re)read for the future.

And on Wednesday night, some of the OPW women of the area had a small outing... (A special thank you to Aleta Dunne for the organization!)

Then, Thursday. Scripting: from Hard-drive to Github to PyPI, also by Matt Harrison, was advertised as "Novice" - but unfortunately I found it a bit too fast-paced for me. More precisely: the Python in it was not too difficult, but the "software engineering practice" level was above me. I look forward to re-reading the handouts in a less hectic environment. In the afternoon, there was Jessica McKellar again with Contribute with me! Getting started with open source development. Some much needed git practice - I will just say that.

And then... PARTY! I met nice people, I browsed the booths of the job fair getting contacts (and merchandise)... great time.

The conference started on Friday. Moving remarks by Jesse Noller on "changing the future" were followed by a keynote by Eben Upton... and the announcement that all of us (all 2500, and yes, that is two-thousand-five-hundred!) were going to get a Raspberry Pi. I will let you imagine the enthusiasm in the room.

I had to pick a talk. I was undecided between Jessica McKellar's How the Internet works and Esther Nam's How to Except When You're Excepting: I went for the first, and it was a fantastic introductory talk. I have to find a good book on the subject... (yes, dear reader, that is a cry for help!)

Then I spent some time browsing around, and after lunch I crashed in the Ada Initiative booth. I have rarely seen such a welcoming crowd, so great at making you feel at ease... Talking about the Imposter Syndrome mixed with nail painting (don't ask), and I also got a lot of good advice for my career.

I was really looking forward to a couple of talks on documentation - but I was feeling terrible (one of my dizziness attacks, a particularly nasty one) and I moved back to the hotel for a quiet night. I hope that the recording will be put online soon.

Now I am here, completing this post... But wait! It's almost time for the first keynote of the day! I'd better hurry! Talk to you soon! Bye!

21 August 2012

So, how did it go?

The ButtonBox had some problems. Namely: it was a calculator... that did not work! At least, not if you tried to do something along the lines of "2 + 3 - 1".

I spent half a day re-writing the methods for calculating things, remembering my reverse Polish notation - and now it works, at least as long as you don't require that multiplication has precedence over sum.

Anyway, then it was time for the MenuButton (with some help to use jhbuild) and the Tooltip.

The first one was done on the model of what was already done in Vala. As I said at GUADEC, reading Vala knowing a bit of Java is like reading Spanish knowing Italian: you meet a lot of false friends, but you end up getting the general meaning. So, Vala examples has been my reference for all the internship.

The Tooltip was done just adding some tooltips to the old Toolbar code. Simple, and there is already room for an exercise (I added the tooltips to 3 buttons out of 4 - who will complete the job? No-one but you, my dear reader!)

Unfortunately, due to a couple of constraints (time and being a bit under the weather) my work has stopped here. I plan to start again as soon as possible, to write that "custom widget" and to revise all the pages of tutorial (should the "API Reference" section point to the stable or to the unstable version? What do you think?).

So: how did it go?

How did the internship go? Are you really asking that?

Answer: IT-WAS-GREAT.

I have learned a lot (I much more proficient in Python, I have learned how to do at least the basic stuff with Gtk+, I have managed to get along with git...), I am much more confident about my skills (in programming in particular and in "keeping a job" in general), and my ability to learn something new quickly.

So: when do we start doing something new again?

Soon, I think... Watch this space!

Last but not least: another HUGE thank you to Marina, for organizing the Outreach Program for Women and to Tiffany, for being such an extraordinary mentor... thank you, really, from the bottom of my heart.

16 August 2012

Near the end, a cliffhanger.

(As in every half-decent movie!)

The time of my internship in the Outreach Program for Women is almost over! A GIGANTIC THANK YOU to Marina, Tiffany and everybody that has given me the opportunity to participate in the OPW. I cannot start expressing how grateful I am for the chance... and for the confidence boost that comes with it!

But the time is not over yet, and I still have work to do.

I have to do: example of MenuButton (ok), of Scrollbar (ok, I guess), of StatusIcon (it has appeared there tonight: is it going to be a sisyphean work? - but ok, again!), of Tooltip (I plan to do something simple, so: ok)... and a "create your own" widget.

And that is not ok.

I am completely at loss for ideas! So, please, dear readers... if you have any suggestion, let me know in the comments! I cannot guarantee I will follow all of your suggestions, of course: but I would really love some input.

In the meanwhile, I am doing all over again my example for ButtonBox, since I was inspired by the "nifty calculator" by Daniel Sielgel. Mine should be a bit simpler, though...

(Also missing - alas, completely missing! - are the exercises for the tutorial. That will be a work to be done after the end of the internship - my goal now is to have all the examples and theory pages ready for the 20th. Yes, that includes the mysterious "custom widget"! As I told you in the title, a cliffhanger...)

Comments & suggestions, as usual - and more than usual! - are welcome in the comments.

1 August 2012

GUADEC + 1 (actually: + 2)

OK, I got it wrong.

GUADEC did not really end on Sunday.

On Monday, I went to my first hackfest - the PyGObject hackfest. It was fantastic. Thank you to Martin Pitt and Paolo Borelli and John Palmieri and everyone (sorry, I am terrible at remembering names!) that helped me to learn so many new things. Thank you, in particular, for your patience with this beginner.

On Tuesday, I finally sat down at a table with Tiffany and we redesigned what I am doing for this summer, given the many useful suggestions we had during GUADEC. The new idea: you should be able to consult the "example" pages (which are divided into: example, code for the example, useful methods, API references, exercises) both from a page that groups the widgets by "category" (windows, display widgets, buttons...) and from a page that gives you a series of "lessons" - a more "sequential" tutorial. The former is aimed at more expert hackers, whereas the latter is for almost absolute beginners. In the latter there are also the "theory" pages (properties, the MVC design...). For the order of the tutorial I owe a lot to Taryn Fox's page here (although I changed some things).

Any suggestion is, as always, very welcome!

28 June 2012

Theory and practice are always the same thing. In theory, not in practice.


Ok, I said: "The main idea: one page, one widget; one widget, one page." in the last post about the 0 Beginners Tutorial, two weeks ago. (My, how time flies and all that sort of things!)

Of course, since things are never going to be as planned, this is not what will happen.

First thought, about ten days ago: "It would be nice to talk a bit about strings and Unicode, on the model of what Sebastian Pölsterl does here". Then it occurred to me that also this page of his tutorial is a great model too.

So: three pages (strings, signals and callback functions, properties) that are not attached to a widget - but linked from some widgets' pages.

Then I was about to rewrite the TreeView widget documentation page, and the ComboBox documentation page... and here comes the idea to write a page about the Model/View/Controller design, about TreeModel and its implementations ListStore and TreeStore, so that the similarities of TreeView and ComboBox are clearer (and therefore it is easier to learn both - my opinion is that ComboBox is slightly easier, but difficulty is always subjective!). Also: in the plan for the tutorial there are two ComboBox examples and four TreeView examples. To repeat a long explanation on the M/V/C design and the methods for TreeModel & friends would make things more confused.

So, now: off to write the M/V/C design page! And then hopefully I will be able to write some code samples again... I miss my Python! (Sorry Mallard, nothing against you...)

As usual: your thoughts? Ideas?

14 June 2012

What's in a page?

A page of the O Beginners Tutorial for Gtk+ in Python, I mean...

First of all, there is an image of a window with the widget "in action".

Then there is the code to get exactly that example. Heavily commented: each line is explained (ok, the "here we set the width and the length of the window" is left out after a couple of examples).

In some cases, here there is a note to comment the code even further.

Then (thanks Jewelfox for the idea!) a series of "useful methods for this widget". I am thinking of writing this part as a list (one method for each bulletpoint), but in a relatively conversational style because a "plain" list could bore you and make you miss some parts while you skim over it. A great help in this is the tutorial by Sebastian Pölsterl, from which I already took an example (and that has been my Rosetta Stone between the C of the Gtk+3 Reference Manual and Python).

Finally, all the links to the pages in the Gtk+3 Reference Manual that I used to write the example.



Is there anything else you would like? Is there anything else you would do differently? If so, leave a comment...

And the Bigger Picture? The Tutorial Itself?

The main idea: one page, one widget; one widget, one page.

Then: a map! A graph to describe "from here you can go here, there, or there", and "to get here you will need what you learn there". And how would you do that? Only via hyperlinks on the page? Wouldn't they get lost in the variety of links described above - and wouldn't the bigger picture of the tutorial get lost in it? On the other hand: a "real" graph for all the examples needed for the tutorial could be a little too tangled...

[And: how's the work progressing? After a first very rough draft of many (but not all) widgets, so far I have written better pages for the window widgets (Gtk.Window, Gtk.ApplicationWindow, Gtk.Dialog, Gtk.AboutDialog, Gtk.MessageDialog) and I am now dealing with version 0.2 of the display widgets' pages (Gtk.Image, Gtk.Label, Gtk.Spinner, Gtk.Statusbar, Gtk.Progressbar). To come: buttons and toggles, numeric and text data entry, Gtk.TextView and more, including list and tree widgets (and therefore Gtk.ListStore and Gtk.TreeStore).]

26 May 2012

New examples (they know where their towel is).

Yesterday I managed to write the example of a GtkScale and the one of a GtkSpinbutton.

Yesterday was Towel Day.

Guess at which value the screenshot showed them?

SpinButton...
...and Scales!
(Both examples also use a Statusbar.)
(On a more serious note, a lesson from yesterday: if the interpreter does not return any error but something is wrong, always check if you're using the constructor in the correct way. For instance I tried for 3 hours to write the GtkScale as
scale = Gtk.Scale() 
scale.new_with_range(Gtk.Orientation.HORIZONTAL, 0, 100, 5)
and variations on the theme, only to get a scale - without a handle! I had to do a
scale = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL, adjustment=some_adjustment)
to get the desired result...)

Update: Now the examples use a label. Simpler, more elegant.

21 May 2012

So...

Let's start!

Hi, I'm Marta, I am a OPW intern. I want to write a "0 Beginners Tutorial" for using Gtk+ in Python.

How did I end up here? I wish I knew... no, wait: I know! It was something along the lines of...

No balloon, so far, but a lot of fun!

(This great cartoon was found here! Always give credit where credit's due...)

Thanks to my mentor Tiffany, in the last weeks I have already begun playing with Gtk+ and Python. So far: a Button, a Label and and Image (note to self: next time, do them in reverse order, easier to harder - although label and image have more or less the same difficulty); and a window using MessageDialog and one with a Dialog (note to self: as above - although I understand [but maybe I'm wrong! If so, please tell me in the comments!] that MessageDialog is the "easy" version, writing the Dialog was much easier).

And now: off to do something! There are still a lot of examples that need to be done...