37,721
社区成员
发帖
与我相关
我的任务
分享
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'vbtest.ui'
#
# Created: Sat Aug 25 01:47:58 2018
# by: PyQt5 UI code generator 5.3.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
from PyQt5 import sip # 解决找不到的包问题
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(192, 145)
self.label1 = QtWidgets.QLabel(Form)
self.label1.setGeometry(QtCore.QRect(70, 30, 81, 21))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label1.setFont(font)
self.label1.setObjectName("label1")
self.Button1 = QtWidgets.QPushButton(Form)
self.Button1.setGeometry(QtCore.QRect(40, 80, 115, 23))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.Button1.setFont(font)
self.Button1.setObjectName("Button1")
self.retranslateUi(Form)
self.Button1.clicked.connect(self.changeButtonText)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "这是标题"))
self.label1.setText(_translate("Form", "这是标签"))
self.Button1.setText(_translate("Form", "单击切换"))
# 自己添加的内容
def changeButtonText(self):
if self.Button1.text()==u'单击切换':
self.Button1.setText(u'单击切换回来')
else:
self.Button1.setText(u'单击切换')
if __name__=='__main__':
app=QtWidgets.QApplication(sys.argv) #QWidget: Must construct a QApplication before a QWidget
ui=Ui_Form()
Main=QtWidgets.QMainWindow()
ui.setupUi(Main)
Main.show()
app.exec_()
# -*- coding: utf-8 -*-
from distutils.core import setup
import py2exe
options = {"py2exe":{"compressed": 9, #压缩
"optimize": 2,
"dll_excludes": ["MSVCP90.dll",],
# "bundle_files": 1
}}
setup(
console=["slottest.py"],
options=options,
zipfile=None)