为什么我的 PyQt 应用程序在 Mac OS X 的后台打开? [英] Why does my PyQt application open in the background on Mac OS X?

查看:23
本文介绍了为什么我的 PyQt 应用程序在 Mac OS X 的后台打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 Mac OS X 中开发的 PyQt 应用程序,每当我尝试启动该应用程序时,它始终是堆栈中最底层的应用程序.所以在启动后,我总是需要一直按 command+tab 到应用程序列表的末尾才能将焦点切换到它.

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.

我读到可以通过使用pythonw"命令启动应用程序来修复此行为,但这没有任何区别,重命名我的脚本以具有 .pyw 扩展名(或同时执行两者)也没有任何区别.什么可能导致此问题?

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

推荐答案

基于本文 http://diotavelli.net/PyQtWiki/PyInstallerOnMacOSX,需要在app.show()之后调用app.raise_(​​)

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

这篇关于为什么我的 PyQt 应用程序在 Mac OS X 的后台打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆