Programming desktop apps in python and glade

I have started having a play around with quickly today. I have always wanted to have a go at GUI programming — I’m OK at scripting and ‘web’ programming, but the only desktop GUI work I have done has been on windows in Access/VBA :S

Doing the basics seems fine, but I’m jumping straight in at the deep end! The situation I have at the moment is I have my Main window, and on opening it it opens a login window. What I am struggling with is passing data back to the main window from the login window.

So… does anyone know of any tutorials for python with glade? Everything google throws at me seems to be different to the way that quickly sets up the project, and makes them hard to follow. Is the quickly way standard? Should I abandon quickly, and go with one of the tutorials and start again from scratch?

Add post to: Delicious Reddit Slashdot Digg Technorati Google
(already: 3) Comment post

Comments

Andrew 25.10.2009 16:37
avatarFirst of all, quickly is using gtkbuilder not glade, glade is being depreciated, however they are both produced by using the glade interface builder. Second of all, glade (or gtkbuilder in this case) is just a simple way of creating user interfaces quickly and visually, instead of creating them by scratch through code. GtkBuilder is just a way of creating PyGTK (python and GTK) applications more visually. You can create an interface through writing the code out, however it is a bit harder Therefore if you need help, you should search for pygtk help. I recommend you go through the PyGTK Tutorial, it is a great guide. The documentation available is also great, giving you all the functions you will need to get data from that window. Finally if you do get stuck, go on #pygtk on freenode.net (IRC) or you can always email me Links: Tutorial – http://www.pygtk.org/pygtk2tutorial/ch-Introduction.html Reference Manual – http://library.gnome.org/devel/pygtk/stable/
rickspencer3 19.12.2009 1:45
avatarlibglade is deprecated, but Glade the tool for building .ui files to feed into gtkbuilder is not deprecated and is used by quickly projects
mrben 15.12.2009 15:49
avatarBearing in mind the above comment, which is all true, the guys at www.learningpython.com also did some stuff with pygtk and glade. Or catch me or Elleo on #lugradio ;)
rickspencer3 19.12.2009 1:53
avatarIn terms of communicating between the login dialog, and the main window, there is a pattern for this described in the tutorial: $quickly tutorial What you do is add a public method or property to your login dialog. Then after the main window runs the dialog, but before it destroys it, get the information you need from the dialog. So the main window code might look like:

    response = logindialog.run()
    if response == gtk.RESPONSE_OK:
        username = logindialog.username
        password = logindialog.password
    else:
        #do something if the dialog was canceled or closed
    logindialog.destroy()

    #do something with the username and password

meh, formatting is not working out, try here: http://paste.ubuntu.com/343836/ HTH Cheers, Rick
Steve 28.12.2009 22:42
avatarCheers for that Rick, I did implement something similar:

    #run the application
    window = NewMainWindow()
    window.show()
    if login != None:
      gtk.main()

Where login is a globally declared dictionary returned by the login dialog. I also fixed the formatting on the comment with a <pre><code class="python">blahblah</code></pre> :-)

Required. 30 chars of fewer.

Required.

Comment post