35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
import sys
|
|
from PyQt5 import QtWidgets
|
|
# 假设 Ui_MainWindow 和 Ui_Serial 是从 .ui 文件转换得到的
|
|
from LaserMethane import Ui_MainWindow
|
|
from serial import Ui_Serial # 根据实际情况调整导入路径
|
|
|
|
|
|
class PT_Serial(QtWidgets.QWidget, Ui_Serial): # 继承自 QWidget 或 QDialog 而不是直接继承 UI 类
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.setupUi(self)
|
|
|
|
|
|
class LaserMethanePyqt5(QtWidgets.QMainWindow, Ui_MainWindow):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.setupUi(self)
|
|
self.setWindowTitle('LaserMethane')
|
|
self.SerialWindow = PT_Serial() # 初始化次级窗口
|
|
self.init() # 确保 init 方法被调用进行信号与槽的连接
|
|
|
|
def init(self):
|
|
# 假设 actionSerial 是主界面中用于打开次级窗口的动作
|
|
self.actionSerial.triggered.connect(self.openSerialWindow)
|
|
|
|
def openSerialWindow(self):
|
|
self.SerialWindow.show()
|
|
|
|
|
|
# 执行
|
|
if __name__ == '__main__':
|
|
app = QtWidgets.QApplication(sys.argv)
|
|
myshow = LaserMethanePyqt5()
|
|
myshow.show()
|
|
sys.exit(app.exec_()) |