Python and Qt4 Designer

Vincent Vande Vyvre vincent.vandevyvre at
Sun Jul 15 09:58:37 CEST 2012

On 15/07/12 07:31, Michael Torrie wrote:
> 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.
Rusi is not the op, and his question is about these lines

    app = None
    if ( not app ):

not this one

        app = QtGui.QApplication([])

which should be written like this

        app = QtGui.QApplication(sys.argv)

Vincent V.V.
Oqapy <> . Qarte
<> . PaQager <>

More information about the Python-list mailing list