[PySide] Why doesn't this example work?
schampailler at skynet.be
Fri Oct 24 20:56:48 CEST 2014
I've no explanation neither... But I'd say that may be due to the fact that during the time.seep, your application is not processing GUI events since at that point app.exec_() has not yet been called). You could try to make a pause by using a QTimer, but that'd imply to app.exec_() before (and maybe you precisely want to avoid that...)
you could also try :
for t in range(3)
for i in range(100): # Strange name to avoid defining local variable...
I had to do that to have a QSplashScreen to display properly (and a QSplashScreen definitely is a window outside the application loop, like what I understand you try to do)
Jim Byrnes <jf_byrnes at comcast.net> wrote:
> In looking at the lists archives, I see that most of the participants
> seem to be experienced developers. As a novice programmer I hope I am
> not intruding by asking some basic questions.
> I am working my way through examples in a PySide book I bought.
> According to the author the example should display a 200 x 150 window,
> pause 3 seconds and then display a 300 x 300 window. On my system
> (Ubuntu 12.04) there is a approx 3 second delay after starting the
> program and then I see the 300 x 300 window. I never see the first window.
> Could someone explain to me why it does not act as described?
> # Import required modules
> import sys
> import time
> from PySide.QtGui import QApplication, QWidget
> class SampleWindow(QWidget):
> """ Our main window class
> # Constructor function
> def __init__(self):
> self.setWindowTitle("Sample Window")
> self.setGeometry(300, 300, 200, 150)
> if __name__ == '__main__':
> # Exception Handling
> myApp = QApplication(sys.argv)
> myWindow = SampleWindow()
> myWindow.resize(300, 300)
> myWindow.setWindowTitle("Sample Window Resized")
> except NameError:
> print("Name Error:", sys.exc_info())
> except SystemExit:
> print("Closing Window...")
> except Exception:
> print (sys.exc_info())
> Thanks, Jim
> PySide mailing list
> PySide at qt-project.org
Timeo Danaos et dona ferentes
Twitter : @Arakowa1
More information about the PySide