Thanks for the help! I've found the mistake. QApplication was instantiated more than one time because a little "app.quit()" was hidden somewhere... Now I have two GUI behaving correctly (well, I hope so)
By the way, if pumpThread is not the more elegant workaround, is there any other ( and smarter :) ) way to do this? Why do we need to call a refresh thread that calls every 0.01 sec : utils.executeDeferred ( app.processEvents() )? Can't we simply launch QApplicaton and all the GUI in another thread? Sorry to bother you with that, I think this issue must have been already pushed in the list. Thanks again Pierre On 16 juin, 22:22, John Creson <[email protected]> wrote: > Also, > > you can’t have more than one qt.QApplication(sys.argv) running at once. > > In your second example, you are using pumpThread which works around defining > the app in a bad way, but then you re-define it the way that doesn't make > maya happy. > > Perhaps just comment out the app= line in the second example. > > They can all call pumpThread, since this is protected from starting more > than once. > > > > On Tue, Jun 16, 2009 at 4:10 PM, John Creson <[email protected]> wrote: > > I think this may be Python cleaning up :) > > > Once your GUIs start getting more complex, you have to use the global > > application > > > instantiation and global windows variables. > > > If you don't use both the global application instantiation and global > > windows variables, > > > then the resultant GUI will appear and disappear very quickly as Python > > cleans up its > > > local variables. > > > import sys > > > import PyQt4 as qt > > > app=None > > > win=None > > def windo(): > > > global app > > global win > > app = qt.QApplication(sys.argv) > > win = qt.QLabel("Hello world!",None) > > win.show() > > > windo() > > > On Tue, Jun 16, 2009 at 3:52 PM, Pierre A <[email protected] > > > wrote: > > >> Hi, > > >> I'm experiencing a strange behavior with modal dialogs. > >> Let's see the following code snippet: (Im in a method's class context) > > >> def launchDialog(self): > >> diag = QtGui.QDialog(self) > >> ret = diag.exec_() > >> print ret > > >> I can see the dialog during a few miliseconds, then it disapears. The > >> return value is always 0 > > >> Now, another piece of code: > >> def launchDialog(self): > >> self.diag = QtGui.QDialog(self) > >> ret = self.diag.exec_() > >> print ret > > >> I'm just adding the dialog as a member of the class. The dialog > >> becomes modal, but exec_() returns immediately. > > >> I have the same problems with the convenience methods of > >> QtGui.QMessageBox and QtGui.QInputDialog, they are closed immediately > >> too... > > >> I'm in a particular state in maya. I have two different GUI launched. > >> They both use pumpthread: > >> ## LAUNCH APP > >> window = None > >> app = None > >> def LaunchApp(): > >> global app > >> global window > >> pt.initializePumpThread() > >> app = QtGui.QApplication(sys.argv) > >> window = MyWindowClass() > >> window.show() > > >> If only one GUI is launched, diag.exec_() doesn't disappear. :'( But I > >> really need to have multiple windows > >> I'm stuck! I don't know how to solve this. Perhaps I could instanciate > >> the QtApp in another module which would act as a singleton and share > >> the QApplication with the different GUI? > > >> Thanks! > > >> Pierre --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/python_inside_maya -~----------~----~----~----~------~----~------~--~---
