擅长:python、mysql、java
<p>系统菜单栏中出现“python”,因为您从python运行脚本,一旦打包应用程序,标题就会消失。例如,下面的代码</p>
<pre class="lang-py prettyprint-override"><code># FileName PyQt5MenuProblem.py
import sys
from PyQt5.QtWidgets import QApplication,QMainWindow
class AppTest(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setWindowTitle("My application")
self._createMenuBar()
def _createMenuBar(self):
self.menuBar = self.menuBar()
self.menuBar.setNativeMenuBar(False)
fileMenu = self.menuBar.addMenu("&File")
editMenu = self.menuBar.addMenu("&Edit")
if __name__== "__main__":
app = QApplication(sys.argv)
plotWindow = AppTest()
plotWindow.showMaximized()
sys.exit(app.exec_())
</code></pre>
<p>包装后</p>
<pre><code>pyinstaller onefile PyQt5MenuProblem.py
</code></pre>
<p>看起来像<br/>
<a href="https://i.stack.imgur.com/15HJp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/15HJp.png" alt="enter image description here"/></a></p>
<p>关键词:MacOS,用户界面,LSUIElement,pyinstaller,pyqt5</p>