开发者

Why does my PyQt application open in the background on Mac OS X?

开发者 https://www.devze.com 2023-01-15 09:06 出处:网络
I\'ve got a PyQt app which I\'m developing in Mac OS X, and whenever I try launching the app, it always is the very bottom application on the stack.So after launching, I always need to command+tab all

I've got a PyQt app which I'm developing in Mac OS X, and whenever I try launching the app, it always is the very bottom application on the stack. So after launching, I always need to command+tab all the way to the end of the application list to switch focus to it.

I read that this behavior can be fixed by launching the app with the "pythonw" command, but this doesn't make any diffe开发者_Python百科rence, nor does renaming my script to have the .pyw extension (or doing both). What could be causing this problem?


Based on this article http://diotavelli.net/PyQtWiki/PyInstallerOnMacOSX, you need to call app.raise_() after app.show()

ui = MainWindow()
ui.show()
ui.raise_()

ref: http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg18945.html

0

精彩评论

暂无评论...
验证码 换一张
取 消