python - 打开后没有任何事情发生

时间:2018-01-26 11:06:55

标签: python linux python-3.x pyqt4

今天我在OpenSuse上安装了PyQt4 Designer。

如果我创建了一个文件,请运行pyuic4 test.ui > test_ui.py 它会创建一个新文件。

现在问题: 如果我想运行代码,没有任何反应。我用python3 test_ui.py

打开了它

测试脚本的代码是:

# -*- coding: utf-8 -*-
# !/usr/bin/env python
# Form implementation generated from reading ui file 'test.ui'
#
# Created by: PyQt4 UI code generator 4.11.4

import sys
from PyQt4 import QtCore, QtGui

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s

try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)

class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName(_fromUtf8("Form"))
        Form.resize(473, 316)
        self.pushButton = QtGui.QPushButton(Form)
        self.pushButton.setGeometry(QtCore.QRect(10, 10, 461, 301))
        self.pushButton.setObjectName(_fromUtf8("pushButton"))

        self.retranslateUi(Form)
        QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.pushButton.close)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        Form.setWindowTitle(_translate("Form", "Form", None))
        self.pushButton.setText(_translate("Form", "Button", None))

print("Hello world!")等其他脚本有效。我认为原因是PyQt4。

感谢您的帮助!

0 个答案:

没有答案