-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest_pyqt5_UI.py
50 lines (43 loc) · 1.81 KB
/
test_pyqt5_UI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'test_pyqt5.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
import os
import sys
curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
sys.path.append(rootPath)
from PyQt5 import QtCore, QtGui, QtWidgets
'''
需要x-shell 的xmanager做图形回传
linux运行:env | grep DISPLAY
py文件编辑配置设置这个环境变量(每次都会变,如果直接在shell运行就不用设置)
DISPLAY=localhost:13.0
'''
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
self.lineEdit = QtWidgets.QLineEdit(Form)
self.lineEdit.setGeometry(QtCore.QRect(80, 130, 113, 20))
self.lineEdit.setObjectName("lineEdit")
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(220, 130, 75, 23))
self.pushButton.setObjectName("pushButton")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.pushButton.setText(_translate("Form", "PushButton"))
# python /opt/code/pythonstudy_space/07_pyqt5/test_pyqt5_UI.py
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
Window = QtWidgets.QWidget() # 创建一个窗口
ui = Ui_Form() # 获取ui对象
ui.setupUi(Window) # 表示ui界面,加载到此窗口上
Window.show() # 展示界面
sys.exit(app.exec_())