[Yr11 Information Technology] GUI development for Python

Baas, Benjamin B baas.benjamin.b at edumail.vic.gov.au
Tue Jun 30 12:05:13 AEST 2015


Hi all python programmers,

Why did this not send the first time.

I have spent a day and a half researching options for GUI development in python, this includes getting a friend that has some good contacts in the open development world to find some information for me and I have now been looking into two separate solutions, PyQT and Glade

PyQT has been mentioned before on the edulist, is the python implementation of the QT frame work. Glade is a GUI designer for PyGTK which is the python implementation of the GTK+ frame work. Both GTK and QT are well documented and supported, but if I have to pick a python implementation I would probably go for PyGTK as is seems to have better support, PyQT has been passed around between three different companies and the documentation shows this.

Both PyQT and PyGTK have all in one installers, that come with all required libraries as well as designers. I have included the links below, beware that you will need python 2.7 for PyGTK. I had no issues install and running both PyQT and PyGTK.

All in one installers.
PyQT:
http://www.riverbankcomputing.com/software/pyqt/download

PyGTK:
http://www.pygtk.org/downloads.html

Now for the part you might actually want to read. How well do they work. I managed to get a simple adding program working in less than an hour for both solutions but I prefer PyGTK over PyQT. The designger for PyGTK is called Glade I found it easier to use then the default designer that comes with PyQT, Glade has a better layout and it was easier to find and change properties for the widgets as well as changing the layout. They both work the same way and look relatively the same so designer choice is personal preference.

Both PyQT and Glade work in the same way when it comes to getting the coding to work. The designers create a custom XML file that you then have to connect the code to. In this part of the GUI development I prefer PyGTK greatly over PyQT. In PyGTK you can link directly to the XML file and the build process as well as create the code to handle the GUI events (called signals) was a lot easier to understand compared to PyQT. In PyQT you cannot link directly to the XML file, you have to first create a python file using a batch file include with the PyQT installation, this means any time you change your interface you have to rerun the batch file. I have attached the code for both solutions to this email, if you want to run the GUI you will need to make sure you have PyQT and PyGTK installed. Currently the code is undocumented. I will create tutorials for both PyQT and PyGTK later on in the holidays.

For reference this is what I based my work on:
http://www.overclock.net/t/342279/tutorial-using-python-glade-to-create-a-simple-gui-application

If you are looking for a GUI designer program in python that lets you edit the code directly through the program (like visual studios or eclipse) you are out of luck all solutions that I could find require you to do your coding separately from the GUI designer, but hey at least you don’t have to code the GUI. The problem with python although it is a great language to teach programming it is a scripting language not really designed for GUI applications. A part of my thinks I might teach python in year 11 but ignore GUIs and in year 12 get the students on to a language that has better GUI support, reason being I feel that GUIs aren’t necessary for teaching the basic of programming they just add an extra layer of complexity.

That was a lot of words and I hope someone reads it. If you have any questions feel free to ask.

Cheers,

Ben.

Benjamin Baas
[Description: cid:image001.png at 01C9CA67.50F474D0] Alkira Secondary College
•   Nurture Ave, Cranbourne North | PO Box 4314, Narre Warren South 3805
'   +61 3 5991 3500      6 +61 3 5991 3599     • www.alkirasecondarycollege.com.au<https://www.edumail.vic.gov.au/owa/redir.aspx?C=GI0-d3Fejk-aG7zt-yEQAWEnl3PNGdEIbSWP-izmbr9gJQw4PnRjfThNmS1aTWtjD-_xfvHJGJY.&URL=http%3a%2f%2fwww.alkirasecondarycollege.com.au%2f>
Alkira Secondary College believes in Personalised learning for all, and  Respect for the individual


Important - This email and any attachments may be confidential. If received in error, please contact us and delete all copies. Before opening or using attachments check them for viruses and defects. Regardless of any loss, damage or consequence, whether caused by the negligence of the sender or not, resulting directly or indirectly from the use of any attached files our liability is limited to resupplying any affected attachments. Any representations or opinions expressed are those of the individual sender, and not necessarily those of the Department of Education and Training.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.edulists.com.au/pipermail/yr11it/attachments/20150630/62a98dc2/attachment.html 


More information about the yr11it mailing list