我在使用信号来显示一个小屏幕时遇到了一点麻烦。缩短我到目前为止的所有内容,以下代码应该显示我的问题。
import sys
from PyQt4 import QtGui, QtCore
qApp = QtGui.QApplication(sys.argv)
class InformatieVenster(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.setWindowTitle('Informatie')
self.setGeometry(100,100,300,200)
informatie = InformatieVenster()
class MenuKlasse(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
about = QtGui.QAction('About...', self)
about.setShortcut('Ctrl+A')
about.setStatusTip('Some text, haha')
self.connect(about, QtCore.SIGNAL('clicked()'), QtCore.SIGNAL(informatie.show()))
menubar = self.menuBar()
self.Menu1 = menubar.addMenu('&File')
self.Menu1.addAction(about)
Menu = MenuKlasse()
Venster = QtGui.QMainWindow()
Venster.menuBar().addMenu(Menu.Menu1)
Venster.setGeometry(200, 200, 300, 300);
size = Venster.geometry()
Venster.show()
qApp.exec_()
运行此程序时,会自动弹出“信息”窗口。但是...我只希望每次单击菜单中的“关于...”或使用分配的快捷方式时都会发生这种情况。
我如何改进我的代码,使我的问题成为历史?
问候!