pyuic5创建一个语法错误的python文件

时间:2018-07-04 09:24:24

标签: python pyqt pyqt5 pyuic

我正在使用QtDesigner 5.5.1构建简单的GUI,并且我想将.ui文件转换为可执行的.py文件。

我跑了:

pyuic5 -x interface.ui -o interface.py
chmod +x interface.py

我的脚本是:

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'platform.ui'
#
# Created by: PyQt5 UI code generator 5.11.2
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_main_menu(object):
    def setupUi(self, main_menu):
        main_menu.setObjectName("main_menu")
        main_menu.resize(1423, 800)
        main_menu.setMinimumSize(QtCore.QSize(1423, 800))
        main_menu.setMaximumSize(QtCore.QSize(1423, 800))
        main_menu.setStyleSheet("background-image: url(:/images/pics/background2.png);")
        self.centralwidget = QtWidgets.QWidget(main_menu)
        self.centralwidget.setObjectName("centralwidget")
        self.frameMain = QtWidgets.QFrame(self.centralwidget)
        self.frameMain.setGeometry(QtCore.QRect(0, 0, 1423, 800))
        self.frameMain.setStyleSheet("background-image: url(:/images/pics/large_main_background.png);")
        self.frameMain.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frameMain.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frameMain.setObjectName("frameMain")
        self.pushButton_6 = QtWidgets.QPushButton(self.frameMain)
        self.pushButton_6.setGeometry(QtCore.QRect(380, 430, 171, 51))
        font = QtGui.QFont()
        font.setFamily("Ubuntu Mono")
        font.setPointSize(13)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.pushButton_6.setFont(font)
        self.pushButton_6.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.pushButton_6.setStyleSheet("background-image: url(:/images/pics/button_background.jpg);")
        self.pushButton_6.setCheckable(False)
        self.pushButton_6.setObjectName("pushButton_6")
        self.pushButton_5 = QtWidgets.QPushButton(self.frameMain)
        self.pushButton_5.setGeometry(QtCore.QRect(640, 350, 171, 51))
        font = QtGui.QFont()
        font.setFamily("Ubuntu Mono")
        font.setPointSize(13)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.pushButton_5.setFont(font)
        self.pushButton_5.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.pushButton_5.setStyleSheet("background-image: url(:/images/pics/button_background.jpg);")
        self.pushButton_5.setCheckable(False)
        self.pushButton_5.setObjectName("pushButton_5")
        self.contextValButton = QtWidgets.QPushButton(self.frameMain)
        self.contextValButton.setGeometry(QtCore.QRect(380, 260, 171, 51))
        font = QtGui.QFont()
        font.setFamily("Ubuntu Mono")
        font.setPointSize(13)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.contextValButton.setFont(font)
        self.contextValButton.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.contextValButton.setAutoFillBackground(False)
        self.contextValButton.setStyleSheet("background-image: url(:/images/pics/button_background.jpg);")
        self.contextValButton.setCheckable(False)
        self.contextValButton.setObjectName("contextValButton")
        self.nonContextValButton = QtWidgets.QPushButton(self.frameMain)
        self.nonContextValButton.setGeometry(QtCore.QRect(380, 350, 171, 51))
        font = QtGui.QFont()
        font.setFamily("Ubuntu Mono")
        font.setPointSize(13)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.nonContextValButton.setFont(font)
        self.nonContextValButton.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.nonContextValButton.setStyleSheet("background-image: url(:/images/pics/button_background.jpg);")
        self.nonContextValButton.setCheckable(False)
        self.nonContextValButton.setObjectName("nonContextValButton")
        self.pushButton_3 = QtWidgets.QPushButton(self.frameMain)
        self.pushButton_3.setGeometry(QtCore.QRect(380, 520, 171, 51))
        font = QtGui.QFont()
        font.setFamily("Ubuntu Mono")
        font.setPointSize(13)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.pushButton_3.setFont(font)
        self.pushButton_3.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.pushButton_3.setStyleSheet("background-image: url(:/images/pics/button_background.jpg);")
        self.pushButton_3.setCheckable(False)
        self.pushButton_3.setObjectName("pushButton_3")
        self.pushButton_7 = QtWidgets.QPushButton(self.frameMain)
        self.pushButton_7.setGeometry(QtCore.QRect(640, 260, 171, 51))
        font = QtGui.QFont()
        font.setFamily("Ubuntu Mono")
        font.setPointSize(13)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.pushButton_7.setFont(font)
        self.pushButton_7.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.pushButton_7.setStyleSheet("background-image: url(:/images/pics/button_background.jpg);")
        self.pushButton_7.setCheckable(False)
        self.pushButton_7.setObjectName("pushButton_7")
        self.pushButton_8 = QtWidgets.QPushButton(self.frameMain)
        self.pushButton_8.setGeometry(QtCore.QRect(640, 430, 171, 51))
        font = QtGui.QFont()
        font.setFamily("Ubuntu Mono")
        font.setPointSize(13)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.pushButton_8.setFont(font)
        self.pushButton_8.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.pushButton_8.setStyleSheet("background-image: url(:/images/pics/button_background.jpg);")
        self.pushButton_8.setCheckable(False)
        self.pushButton_8.setObjectName("pushButton_8")
        self.pushButton_9 = QtWidgets.QPushButton(self.frameMain)
        self.pushButton_9.setGeometry(QtCore.QRect(640, 520, 171, 51))
        font = QtGui.QFont()
        font.setFamily("Ubuntu Mono")
        font.setPointSize(13)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.pushButton_9.setFont(font)
        self.pushButton_9.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.pushButton_9.setStyleSheet("background-image: url(:/images/pics/button_background.jpg);")
        self.pushButton_9.setCheckable(False)
        self.pushButton_9.setObjectName("pushButton_9")
        self.pushButton_16 = QtWidgets.QPushButton(self.frameMain)
        self.pushButton_16.setGeometry(QtCore.QRect(910, 260, 171, 51))
        font = QtGui.QFont()
        font.setFamily("Ubuntu Mono")
        font.setPointSize(13)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.pushButton_16.setFont(font)
        self.pushButton_16.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.pushButton_16.setStyleSheet("background-image: url(:/images/pics/button_background.jpg);")
        self.pushButton_16.setCheckable(False)
        self.pushButton_16.setObjectName("pushButton_16")
        self.pushButton_17 = QtWidgets.QPushButton(self.frameMain)
        self.pushButton_17.setGeometry(QtCore.QRect(910, 430, 171, 51))
        font = QtGui.QFont()
        font.setFamily("Ubuntu Mono")
        font.setPointSize(13)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.pushButton_17.setFont(font)
        self.pushButton_17.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.pushButton_17.setStyleSheet("background-image: url(:/images/pics/button_background.jpg);")
        self.pushButton_17.setCheckable(False)
        self.pushButton_17.setObjectName("pushButton_17")
        self.pushButton_18 = QtWidgets.QPushButton(self.frameMain)
        self.pushButton_18.setGeometry(QtCore.QRect(910, 520, 171, 51))
        font = QtGui.QFont()
        font.setFamily("Ubuntu Mono")
        font.setPointSize(13)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.pushButton_18.setFont(font)
        self.pushButton_18.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.pushButton_18.setStyleSheet("background-image: url(:/images/pics/button_background.jpg);")
        self.pushButton_18.setCheckable(False)
        self.pushButton_18.setObjectName("pushButton_18")
        self.pushButton_19 = QtWidgets.QPushButton(self.frameMain)
        self.pushButton_19.setGeometry(QtCore.QRect(910, 350, 171, 51))
        font = QtGui.QFont()
        font.setFamily("Ubuntu Mono")
        font.setPointSize(13)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.pushButton_19.setFont(font)
        self.pushButton_19.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.pushButton_19.setStyleSheet("background-image: url(:/images/pics/button_background.jpg);")
        self.pushButton_19.setCheckable(False)
        self.pushButton_19.setObjectName("pushButton_19")
        self.pushButton_6.raise_()
        self.pushButton_5.raise_()
        self.contextValButton.raise_()
        self.nonContextValButton.raise_()
        self.pushButton_3.raise_()
        self.pushButton_7.raise_()
        self.pushButton_8.raise_()
        self.pushButton_9.raise_()
        self.pushButton_16.raise_()
        self.pushButton_17.raise_()
        self.pushButton_18.raise_()
        self.pushButton_19.raise_()
        self.frameContextVal = QtWidgets.QFrame(self.centralwidget)
        self.frameContextVal.setGeometry(QtCore.QRect(0, 0, 1423, 800))
        self.frameContextVal.setStyleSheet("background-image: url(:/images/pics/cont_data_val_background.png);")
        self.frameContextVal.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frameContextVal.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frameContextVal.setObjectName("frameContextVal")
        self.backButton = QtWidgets.QPushButton(self.frameContextVal)
        self.backButton.setGeometry(QtCore.QRect(50, 710, 171, 51))
        font = QtGui.QFont()
        font.setFamily("Ubuntu Mono")
        font.setPointSize(13)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.backButton.setFont(font)
        self.backButton.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.backButton.setStyleSheet("background-image: url(:/images/pics/button_background.jpg);")
        self.backButton.setCheckable(False)
        self.backButton.setObjectName("backButton")
        self.backButton_2 = QtWidgets.QPushButton(self.frameContextVal)
        self.backButton_2.setGeometry(QtCore.QRect(140, 190, 171, 51))
        font = QtGui.QFont()
        font.setFamily("Ubuntu Mono")
        font.setPointSize(13)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.backButton_2.setFont(font)
        self.backButton_2.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.backButton_2.setStyleSheet("background-image: url(:/images/pics/button_background.jpg);")
        self.backButton_2.setCheckable(False)
        self.backButton_2.setObjectName("backButton_2")
        self.lcdNumber = QtWidgets.QLCDNumber(self.frameContextVal)
        self.lcdNumber.setGeometry(QtCore.QRect(970, 590, 371, 111))
        self.lcdNumber.setStyleSheet("background-image: url(:/images/pics/button_background.jpg);")
        self.lcdNumber.setObjectName("lcdNumber")
        self.label = QtWidgets.QLabel(self.frameContextVal)
        self.label.setGeometry(QtCore.QRect(970, 530, 281, 51))
        font = QtGui.QFont()
        font.setPointSize(18)
        font.setBold(True)
        font.setWeight(75)
        font.setKerning(True)
        font.setStyleStrategy(QtGui.QFont.PreferAntialias)
        self.label.setFont(font)
        self.label.setFocusPolicy(QtCore.Qt.TabFocus)
        self.label.setContextMenuPolicy(QtCore.Qt.NoContextMenu)
        self.label.setAutoFillBackground(False)
        self.label.setStyleSheet("background-color: rgba(255, 255, 255, 0);\n"
"background-image: url(:/images/pics/button_background.jpg);")
        self.label.setObjectName("label")
        main_menu.setCentralWidget(self.centralwidget)

        self.retranslateUi(main_menu)
        self.contextValButton.clicked.connect(self.frameContextVal.raise)
        self.backButton.clicked.connect(self.frameMain.raise)
        QtCore.QMetaObject.connectSlotsByName(main_menu)

    def retranslateUi(self, main_menu):
        _translate = QtCore.QCoreApplication.translate
        main_menu.setWindowTitle(_translate("main_menu", "MainWindow"))
        self.pushButton_6.setStatusTip(_translate("main_menu", "Takes you to a new window."))
        self.pushButton_6.setText(_translate("main_menu", "Decomposition"))
        self.pushButton_5.setStatusTip(_translate("main_menu", "Takes you to a new window."))
        self.pushButton_5.setText(_translate("main_menu", "Clustering Analysis"))
        self.contextValButton.setStatusTip(_translate("main_menu", "Takes you to a new window."))
        self.contextValButton.setText(_translate("main_menu", "Contextual \n"
"Validation"))
        self.nonContextValButton.setStatusTip(_translate("main_menu", "Takes you to a new window."))
        self.nonContextValButton.setText(_translate("main_menu", "Noncontextual \n"
" Validation"))
        self.pushButton_3.setStatusTip(_translate("main_menu", "Takes you to a new window."))
        self.pushButton_3.setText(_translate("main_menu", "Data Exploration"))
        self.pushButton_7.setStatusTip(_translate("main_menu", "Takes you to a new window."))
        self.pushButton_7.setText(_translate("main_menu", "Fusion"))
        self.pushButton_8.setStatusTip(_translate("main_menu", "Takes you to a new window."))
        self.pushButton_8.setText(_translate("main_menu", "Additional 1"))
        self.pushButton_9.setStatusTip(_translate("main_menu", "Takes you to a new window."))
        self.pushButton_9.setText(_translate("main_menu", "Additional 2"))
        self.pushButton_16.setStatusTip(_translate("main_menu", "Takes you to a new window."))
        self.pushButton_16.setText(_translate("main_menu", "Additional 3"))
        self.pushButton_17.setStatusTip(_translate("main_menu", "Takes you to a new window."))
        self.pushButton_17.setText(_translate("main_menu", "Additional 5"))
        self.pushButton_18.setStatusTip(_translate("main_menu", "Takes you to a new window."))
        self.pushButton_18.setText(_translate("main_menu", "Additional 6"))
        self.pushButton_19.setStatusTip(_translate("main_menu", "Takes you to a new window."))
        self.pushButton_19.setText(_translate("main_menu", "Additional 4"))
        self.backButton.setStatusTip(_translate("main_menu", "Takes you to a new window."))
        self.backButton.setText(_translate("main_menu", "Back to main"))
        self.backButton_2.setStatusTip(_translate("main_menu", "Takes you to a new window."))
        self.backButton_2.setText(_translate("main_menu", "Apply Test Function"))
        self.label.setText(_translate("main_menu", "Some Text Here"))

import img_rc

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    main_menu = QtWidgets.QMainWindow()
    ui = Ui_main_menu()
    ui.setupUi(main_menu)
    main_menu.show()
    sys.exit(app.exec_())

我得到的错误是:

  File "example.py", line 249
    self.contextValButton.clicked.connect(self.frameContextVal.raise)
                                                                   ^
SyntaxError: invalid syntax

0 个答案:

没有答案