On 10/24/2014 01:12 PM, Jim Byrnes wrote: > On 10/22/2014 10:52 PM, Eric Thomson wrote: >> I meant to write that I put >> myWindow.repaint() >> before time.sleep(3). >> >> Incidentally, what book are you working through? > > PySideGUI Application Development > >> >> On 10/22/14, Eric Thomson <[email protected]> wrote: >>> Try putting >>> myWindow.repaint() >>> before myWindow.show(). >>> >>> That took away the weird behavior on my end. I cannot explain it, though. > > As amended above, it worked for me also. > > Thanks, Jim
I guess I should have flipped the page and read a little further, I would have found this text. You might not initially see a window when executing this program on an XWindow based system such as Linux, because the main application loop has not been called yet, so none of the objects has been really constructed and buffered out to the underlying XWindow system. I am running Ubuntu. To be fair to the author I thought I should mention this. Regards, Jim >>> >>> On 10/22/14, Jim Byrnes <[email protected]> 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): >>>> QWidget.__init__(self) >>>> self.setWindowTitle("Sample Window") >>>> self.setGeometry(300, 300, 200, 150) >>>> self.setMinimumHeight(100) >>>> self.setMinimumWidth(250) >>>> self.setMaximumHeight(200) >>>> self.setMaximumWidth(800) >>>> >>>> if __name__ == '__main__': >>>> # Exception Handling >>>> try: >>>> myApp = QApplication(sys.argv) >>>> myWindow = SampleWindow() >>>> myWindow.show() >>>> time.sleep(3) >>>> myWindow.resize(300, 300) >>>> myWindow.setWindowTitle("Sample Window Resized") >>>> myWindow.repaint() >>>> myApp.exec_() >>>> sys.exit(0) >>>> except NameError: >>>> print("Name Error:", sys.exc_info()[1]) >>>> except SystemExit: >>>> print("Closing Window...") >>>> except Exception: >>>> print (sys.exc_info()[1]) >>>> >>>> Thanks, Jim >>>> >>>> _______________________________________________ >>>> PySide mailing list >>>> [email protected] >>>> http://lists.qt-project.org/mailman/listinfo/pyside >>>> >>> _______________________________________________ PySide mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/pyside
