[python]python2.7下pyqt4安装后测试代码

测试代码:

复制代码
# -*- coding: utf-8 -*-
 
# Form implementation generated from reading ui file 'ui-a.ui'
#
# Created: Wed Jun 12 17:14:40 2019
#      by: PyQt4 UI code generator 4.9.4
#
# WARNING! All changes made in this file will be lost!
 
from PyQt4 import QtCore, QtGui
 
try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    _fromUtf8 = lambda s: s
 
class Ui_firstMainWindow(object):
    def setupUi(self, firstMainWindow):
        firstMainWindow.setObjectName(_fromUtf8("firstMainWindow"))
        firstMainWindow.resize(556, 444)
        firstMainWindow.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
        self.centralwidget = QtGui.QWidget(firstMainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.queren = QtGui.QPushButton(self.centralwidget)
        self.queren.setGeometry(QtCore.QRect(430, 360, 93, 28))
        self.queren.setObjectName(_fromUtf8("queren"))
        firstMainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(firstMainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 556, 23))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        firstMainWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(firstMainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        firstMainWindow.setStatusBar(self.statusbar)
 
        self.retranslateUi(firstMainWindow)
        QtCore.QMetaObject.connectSlotsByName(firstMainWindow)
 
    def retranslateUi(self, firstMainWindow):
        firstMainWindow.setWindowTitle(QtGui.QApplication.translate("firstMainWindow", "UI设计师", None, QtGui.QApplication.UnicodeUTF8))
        self.queren.setText(QtGui.QApplication.translate("firstMainWindow", "确认", None, QtGui.QApplication.UnicodeUTF8))
 
if  __name__=="__main__":
    import  sys
    reload(sys)                                 #
    sys.setdefaultencoding( "utf-8" )           # 这两步是为了解决print中文报ascii编码错误
 
    app=QtGui.QApplication(sys.argv)
    widget= QtGui.QMainWindow()
    ui= Ui_firstMainWindow()
    ui.setupUi(widget)
    widget.show()
    sys.exit(app.exec_())

结果:

相关推荐
喵手几秒前
Python爬虫实战:地图 POI + 行政区反查实战 - 商圈热力数据准备完整方案(附CSV导出 + SQLite持久化存储)!
爬虫·python·爬虫实战·零基础python爬虫教学·地区poi·行政区反查·商圈热力数据采集
熊猫_豆豆6 分钟前
YOLOP车道检测
人工智能·python·算法
nimadan127 分钟前
**热门短剧小说扫榜工具2025推荐,精准捕捉爆款趋势与流量
人工智能·python
杜子不疼.10 分钟前
PyPTO:面向NPU的高效并行张量编程范式
开发语言
lly20240611 分钟前
C# 结构体(Struct)
开发语言
默默前行的虫虫12 分钟前
MQTT.fx实际操作
python
YMWM_21 分钟前
python3继承使用
开发语言·python
JMchen12322 分钟前
AI编程与软件工程的学科融合:构建新一代智能驱动开发方法学
驱动开发·python·软件工程·ai编程
Once_day37 分钟前
C++之《程序员自我修养》读书总结(1)
c语言·开发语言·c++·程序员自我修养