[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_())

结果:

相关推荐
CSDN_RTKLIB20 小时前
【One Definition Rule】类重复定义解决思路
开发语言·c++
智航GIS20 小时前
9.5 XML 处理指南
xml·前端·python
Data_agent20 小时前
微店店铺所有商品API接口指南
java·大数据·服务器·windows·python
落羽凉笙20 小时前
【Python基础】第2章学习笔记:从Python历史到IPO编程模式,含习题详解
开发语言·笔记·后端·python·学习
小途软件20 小时前
基于图像生成的虚拟现实体验
java·人工智能·pytorch·python·深度学习·语言模型
reesn20 小时前
FP8模型反量化讲解
人工智能·python·深度学习
刘975320 小时前
【第24】天24c#今日小结
开发语言·c#
luoluoal20 小时前
基于python的某在线中药店销售数据统计与分析系统(源码+文档)
python·mysql·django·毕业设计·源码
Amelia11111120 小时前
day45
python