Python and Qt4 Designer

Michael Torrie torriem at gmail.com
Sun Jul 15 01:31:38 EDT 2012


On 07/14/2012 11:13 AM, rusi wrote:
> I looked at the second link and find code like this:
> 
> app = None if ( not app ): app = QtGui.QApplication([])
> 
> Maybe I'm dense but whats that if doing there?
> 
> Frankly I seem to be a bit jinxed with gui stuff.  A few days ago 
> someone was singing the praises of some new themed tk stuff. I could 
> not get the first two lines -- the imports -- to work and then gave 
> up

Since you haven't had any experience with gui development then probably
loading ui files isn't the right place to start.  First principles
(creating gui widgets from scratch) would be it.

In any case, the line in question is quite simple.  It creates a
QApplication object, which is basically the engine that drives all Qt
applications.  Once you call .run() on it, it takes over and handles all
the mouse events and such for you.  In fact you do not have any control
over the program's execution from this point on, other than to define
event call-back methods or functions that are called by the widgets when
things happen, like mouse clicks.

All gui toolkits operate this way.  You set up the widgets, then you run
the main engine or main event loop and control never returns to your
main program until something triggers the end (like closing a window or
the quit menu item is pressed).

Probably a complete working example is what you need to see, that is
documented.  I primarily work with Gtk, but I'll whip up a Qt one
tomorrow if I can.



More information about the Python-list mailing list