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

结果:

相关推荐
励志的小陈1 小时前
贪吃蛇(C语言实现,API)
c语言·开发语言
kishu_iOS&AI2 小时前
深度学习 —— 损失函数
人工智能·pytorch·python·深度学习·线性回归
Makoto_Kimur2 小时前
java开发面试-AI Coding速成
java·开发语言
好运的阿财2 小时前
OpenClaw工具拆解之canvas+message
人工智能·python·ai编程·openclaw·openclaw工具
laowangpython2 小时前
Gurobi求解器Matlab安装配置教程
开发语言·其他·matlab
wengqidaifeng2 小时前
python启航:1.基础语法知识
开发语言·python
观北海2 小时前
Windows 平台 Python 极简 ORB-SLAM3 Demo,从零实现实时视觉定位
开发语言·python·动态规划
FreakStudio2 小时前
做了个Claude Code CLI 电子宠物:程序员的实体监工代码搭子
python·单片机·嵌入式·面向对象·并行计算·电子diy·电子计算机
柴米油盐那点事儿2 小时前
python+mysql+bootstrap条件搜索分页
python·mysql·flask·bootstrap
AC赳赳老秦3 小时前
OpenClaw二次开发实战:编写专属办公自动化技能,适配个性化需求
linux·javascript·人工智能·python·django·测试用例·openclaw