search

Home  >  Q&A  >  body text

这个python 程序怎么输出窗口运行

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_MainWindow(object):

def setupUi(self, MainWindow):
    MainWindow.setObjectName("MainWindow")
    MainWindow.resize(472, 239)
    self.centralwidget = QtWidgets.QWidget(MainWindow)
    self.centralwidget.setObjectName("centralwidget")
    self.pushButton = QtWidgets.QPushButton(self.centralwidget)
    self.pushButton.setGeometry(QtCore.QRect(90, 130, 75, 23))
    self.pushButton.setObjectName("pushButton")
    self.timeEdit = QtWidgets.QTimeEdit(self.centralwidget)
    self.timeEdit.setGeometry(QtCore.QRect(170, 60, 131, 41))
    self.timeEdit.setObjectName("timeEdit")
    self.label = QtWidgets.QLabel(self.centralwidget)
    self.label.setGeometry(QtCore.QRect(240, 150, 191, 41))
    self.label.setObjectName("label")
    MainWindow.setCentralWidget(self.centralwidget)
    self.statusbar = QtWidgets.QStatusBar(MainWindow)
    self.statusbar.setObjectName("statusbar")
    MainWindow.setStatusBar(self.statusbar)
    self.menuBar = QtWidgets.QMenuBar(MainWindow)
    self.menuBar.setGeometry(QtCore.QRect(0, 0, 472, 23))
    self.menuBar.setObjectName("menuBar")
    self.menu = QtWidgets.QMenu(self.menuBar)
    self.menu.setObjectName("menu")
    MainWindow.setMenuBar(self.menuBar)
    self.action33 = QtWidgets.QAction(MainWindow)
    self.action33.setObjectName("action33")
    self.action_2 = QtWidgets.QAction(MainWindow)
    self.action_2.setObjectName("action_2")
    self.menu.addAction(self.action_2)
    self.menuBar.addAction(self.menu.menuAction())

    self.retranslateUi(MainWindow)
    QtCore.QMetaObject.connectSlotsByName(MainWindow)

def retranslateUi(self, MainWindow):
    _translate = QtCore.QCoreApplication.translate
    MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
    self.pushButton.setText(_translate("MainWindow", "PushButton"))
    self.label.setText(_translate("MainWindow", "15454541"))
    self.menu.setTitle(_translate("MainWindow", "菜单"))
    self.action33.setText(_translate("MainWindow", "打开"))
    self.action_2.setText(_translate("MainWindow", "打开"))
PHP中文网PHP中文网2777 days ago670

reply all(1)I'll reply

  • 高洛峰

    高洛峰2017-04-18 10:24:36

    if name == "__main__":

    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())

    reply
    0
  • Cancelreply