代码:
import sys
from PySide import QtGui
class BrowserDevelopment(QtGui.QMainWindow):
def __init__(self):
super(BrowserDevelopment, self).__init__()
self.startingUI()
def startingUI(self):
self.setWindowTitle('Alphabrowser')
self.resize(800, 400)
self.statusBar()
#Menueinstellungen an sich
menue = self.menuBar()
#Actions des Menues:
#datei menue
menuleiste_datei = menue.addMenu('File')
datei_exit = QtGui.QAction('Exit', self)
datei_exit.setStatusTip('Close the programm')
menuleiste_datei.addAction(datei_exit)
datei_exit.triggered.connect(self.close)
#Einstellungen menue
menuleiste_configurations = menue.addMenu('Configurations')
configurations_settings = QtGui.QAction('Settings', self)
configurations_settings.setStatusTip('Configurations(Settings)')
menuleiste_configurations.addAction(configurations_settings)
configurations_settings.triggered.connect(self.newwindow)
self.show()
def newwindow(self):
wid = QtGui.QWidget()
wid.resize(250, 150)
wid.setWindowTitle('NewWindow')
wid.show()
def main():
app = QtGui.QApplication(sys.argv)
ex = BrowserDevelopment()
sys.exit(app.exec_())
if __name__== '__main__':
main()
如果您单击“配置”,然后单击“设置”,则会弹出一个窗口,它确实如此。但它闪烁并消失。我试图添加第二个 sys.exit(app.exec_()) 但它没有定义,因为它在另一个方法中。我应该让应用程序全球化还是与所谓的“线程”有关?问候