更新时间:2023-01-28 15:28:09
a Bar
对象,并调用 show
方法:
You need to instantiate a Bar
object, and call its show
method:
def main():
app = QtGui.QApplication(sys.argv)
ex = Example()
bar = Bar()
bar.show()
sys.exit(app.exec_())
如果你想在一个窗口中的按钮和状态栏,将所有的小部件放在 QMainWindow
:
import sys
from PyQt4 import QtGui, QtCore
class Bar(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.initUI()
def initUI(self):
self.setGeometry(300,300,200,200)
self.b1 = QtGui.QPushButton("Button", self)
self.b1.move(100,100)
self.setWindowTitle("Example")
self.statusBar().showMessage("Statusbar")
def main():
app = QtGui.QApplication(sys.argv)
bar = Bar()
bar.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()