Re: [Pythonmac-SIG] py2app + pyqt: Differences between command-line and double-click
Hi Stuart, I have been suffering similar problems since MacOSX changed the way they handle windows, a couple of versions back. See: http://mail.python.org/pipermail/tkinter-discuss/2012-May/003161.html The problem there also included the argv_emulation flag, and setting this to false fixed the problem. If you need argv_emulation=True, then put some code in to iconify/deiconify the window (maybe followed by a lift). May result in the window flashing, but at least it will be workable to your users. I have the following in my code for my toplevel window: self.lift() if sys.platform ==darwin: self.iconify() self.update() self.deiconify() Mick On 13 August 2013 02:13, Berg, Stuart be...@janelia.hhmi.org wrote: Hi Ronald, It took me a while to follow up on this thread I started a few months ago because I wanted to find a minimal test case that illustrates my problem. Now I've got one. Apparently the PyQt spashscreen doesn't behave correctly when I use the py2app argv_emulation option. To save you from digging through your email for the previous posts, I'll summarize my issue again: - I use py2app to bundle my app, which is implemented with PyQt4 (qt-4.8.3, pyqt-4.9.5). - I want to show a QSplashScreen when my app starts up, and hide it when the main window is shown. - When I double-click my app bundle: -- There is a brief delay -- The splash screen appears -- The main window does not appear. -- At this point, I can summon the main window into existence by using command-tab to switch away from the app and then back again. - I get correct splash screen behavior if I launch the app from the command line via MyBundle.app/Contents/MacOS/myapp I noticed that the odd behavior happens when I use the argv_emulation option. Here's a minimal example that shows the incorrect behavior on my machine. To see correct behavior, comment out the 'argv_emulation' option in setup.py. If necessary, I can probably use a workaround to avoid argv_emulation, but if there is a quick fix for this, I'd love to know about it. Thanks, Stuart # bash commands to run: $ python setup.py py2app $ open dist/splashtest.app # incorrect splash screen behavior $ open dist/splashtest.app/Contents/MacOS/splashtest # Correct behavior ## ### splashtest.py import sys, time from PyQt4.QtGui import QPixmap, QSplashScreen, QApplication, QMainWindow app = QApplication([]) # Show a (blank) splash screen splash = QSplashScreen( QPixmap(300, 200) ) splash.show() app.processEvents() time.sleep(1) # Create show the main window window = QMainWindow() window.show() window.raise_() # Close the splash screen splash.finish(window) sys.exit( app.exec_() ) ## # setup.py from setuptools import setup, find_packages setup( app=['splashtest.py'], options={ 'py2app': { 'argv_emulation': True, 'includes':['PyQt4.QtCore','PyQt4.QtGui' ] } }, setup_requires=['py2app'] ) ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] py2app + pyqt: Differences between command-line and double-click
Hi Ronald, It took me a while to follow up on this thread I started a few months ago because I wanted to find a minimal test case that illustrates my problem. Now I've got one. Apparently the PyQt spashscreen doesn't behave correctly when I use the py2app argv_emulation option. To save you from digging through your email for the previous posts, I'll summarize my issue again: - I use py2app to bundle my app, which is implemented with PyQt4 (qt-4.8.3, pyqt-4.9.5). - I want to show a QSplashScreen when my app starts up, and hide it when the main window is shown. - When I double-click my app bundle: -- There is a brief delay -- The splash screen appears -- The main window does not appear. -- At this point, I can summon the main window into existence by using command-tab to switch away from the app and then back again. - I get correct splash screen behavior if I launch the app from the command line via MyBundle.app/Contents/MacOS/myapp I noticed that the odd behavior happens when I use the argv_emulation option. Here's a minimal example that shows the incorrect behavior on my machine. To see correct behavior, comment out the 'argv_emulation' option in setup.py. If necessary, I can probably use a workaround to avoid argv_emulation, but if there is a quick fix for this, I'd love to know about it. Thanks, Stuart # bash commands to run: $ python setup.py py2app $ open dist/splashtest.app # incorrect splash screen behavior $ open dist/splashtest.app/Contents/MacOS/splashtest # Correct behavior ## ### splashtest.py import sys, time from PyQt4.QtGui import QPixmap, QSplashScreen, QApplication, QMainWindow app = QApplication([]) # Show a (blank) splash screen splash = QSplashScreen( QPixmap(300, 200) ) splash.show() app.processEvents() time.sleep(1) # Create show the main window window = QMainWindow() window.show() window.raise_() # Close the splash screen splash.finish(window) sys.exit( app.exec_() ) ## # setup.py from setuptools import setup, find_packages setup( app=['splashtest.py'], options={ 'py2app': { 'argv_emulation': True, 'includes':['PyQt4.QtCore','PyQt4.QtGui' ] } }, setup_requires=['py2app'] ) ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
[Pythonmac-SIG] py2app + pyqt: Differences between command-line and double-click
Hi, I'm using py2app to packages my (cross-platform) PyQt app into a Mac OS X application bundle. (py2app is great, btw!) I was wondering if anyone could point me to some documentation that explains in detail how a python app bundle's launch process differs from launching the python app directly from the command-line. My app bundle seems to function exactly the same in most respects, but my main window doesn't activate unless I manually activate the application via command-tab. I give a few more details in this question on stack overflow: http://stackoverflow.com/questions/16574315/qt-mainwindow-does-not-appear-until-application-is-activated-manually Any ideas, suggestions, or links would be appreciated. Thanks, Stuart ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] py2app + pyqt: Differences between command-line and double-click
Hi, I answered on stack overflow too - but the short version is call show() *then also call* raise_() on your main window. The answer to an earlier version of this question has a couple of links for more background: http://stackoverflow.com/questions/3662559/why-does-my-pyqt-application-open-in-the-background-on-mac-os-x On Wed, May 15, 2013 at 1:32 PM, Berg, Stuart be...@janelia.hhmi.orgwrote: Hi, I'm using py2app to packages my (cross-platform) PyQt app into a Mac OS X application bundle. (py2app is great, btw!) I was wondering if anyone could point me to some documentation that explains in detail how a python app bundle's launch process differs from launching the python app directly from the command-line. My app bundle seems to function exactly the same in most respects, but my main window doesn't activate unless I manually activate the application via command-tab. I give a few more details in this question on stack overflow: http://stackoverflow.com/questions/16574315/qt-mainwindow-does-not-appear-until-application-is-activated-manually Any ideas, suggestions, or links would be appreciated. Thanks, Stuart ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] py2app + pyqt: Differences between command-line and double-click
Hi Michael, Thanks for your response. I am already calling show() and then raise() (though my SO question didn't make that clear -- sorry about that). I think I'm having a different issue than the one in the link you provided, because my app behaves correctly when launched from the command line. It only misbehaves when launched from the app-bundle (i.e. when launched with double-click). For that reason, I suspect that perhaps there may be a subtle difference in the way the app bundle launches the main thread. (Grasping in the dark here...) Any py2app experts out there care to comment? -Stuart On May 15, 2013, at 4:50 PM, Michael McCracken wrote: Hi, I answered on stack overflow too - but the short version is call show() *then also call* raise_() on your main window. The answer to an earlier version of this question has a couple of links for more background:http://stackoverflow.com/questions/3662559/why-does-my-pyqt-application-open-in-the-background-on-mac-os-x On Wed, May 15, 2013 at 1:32 PM, Berg, Stuart be...@janelia.hhmi.org wrote: Hi, I'm using py2app to packages my (cross-platform) PyQt app into a Mac OS X application bundle. (py2app is great, btw!) I was wondering if anyone could point me to some documentation that explains in detail how a python app bundle's launch process differs from launching the python app directly from the command-line. My app bundle seems to function exactly the same in most respects, but my main window doesn't activate unless I manually activate the application via command-tab. I give a few more details in this question on stack overflow: http://stackoverflow.com/questions/16574315/qt-mainwindow-does-not-appear-until-application-is-activated-manually Any ideas, suggestions, or links would be appreciated. Thanks, Stuart ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] py2app + pyqt: Differences between command-line and double-click
There aren't any other window-focus related gotchas that I know of in the bootstrap code, and I've looked at most of it - can you share more about your program, and perhaps show what your setup.py looks like? On Wed, May 15, 2013 at 2:31 PM, Berg, Stuart be...@janelia.hhmi.orgwrote: Hi Michael, Thanks for your response. I am already calling show() and then raise() (though my SO question didn't make that clear -- sorry about that). I think I'm having a different issue than the one in the link you provided, because my app behaves correctly when launched from the command line. It only misbehaves when launched from the app-bundle (i.e. when launched with double-click). For that reason, I suspect that perhaps there may be a subtle difference in the way the app bundle launches the main thread. (Grasping in the dark here...) Any py2app experts out there care to comment? -Stuart On May 15, 2013, at 4:50 PM, Michael McCracken wrote: Hi, I answered on stack overflow too - but the short version is call show() *then also call* raise_() on your main window. The answer to an earlier version of this question has a couple of links for more background: http://stackoverflow.com/questions/3662559/why-does-my-pyqt-application-open-in-the-background-on-mac-os-x On Wed, May 15, 2013 at 1:32 PM, Berg, Stuart be...@janelia.hhmi.orgwrote: Hi, I'm using py2app to packages my (cross-platform) PyQt app into a Mac OS X application bundle. (py2app is great, btw!) I was wondering if anyone could point me to some documentation that explains in detail how a python app bundle's launch process differs from launching the python app directly from the command-line. My app bundle seems to function exactly the same in most respects, but my main window doesn't activate unless I manually activate the application via command-tab. I give a few more details in this question on stack overflow: http://stackoverflow.com/questions/16574315/qt-mainwindow-does-not-appear-until-application-is-activated-manually Any ideas, suggestions, or links would be appreciated. Thanks, Stuart ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] py2app + pyqt: Differences between command-line and double-click
On 15 May, 2013, at 22:32, Berg, Stuart be...@janelia.hhmi.org wrote: Hi, I'm using py2app to packages my (cross-platform) PyQt app into a Mac OS X application bundle. (py2app is great, btw!) I was wondering if anyone could point me to some documentation that explains in detail how a python app bundle's launch process differs from launching the python app directly from the command-line. My app bundle seems to function exactly the same in most respects, but my main window doesn't activate unless I manually activate the application via command-tab. I give a few more details in this question on stack overflow: http://stackoverflow.com/questions/16574315/qt-mainwindow-does-not-appear-until-application-is-activated-manually Any ideas, suggestions, or links would be appreciated. That's odd. I would expect the opposite behavior because your application should get the focus when launched by the finder and the terminal still has focus when you start a script in the Terminal app. Does the Qt application example in py2app's repository have the same behavior (last time I checked it worked fine on my machine)? What application does have the focus when you double click on the application? And btw, what do you mean by launch from the terminal in your SO question? Are you starting the .app from the Terminal using 'MyApp.app/Contents/MyAp', or by running 'open MyApp.app' or even by just running 'python myapp.py'? Ronald Thanks, Stuart ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG