from PyQt5.QtWidgets import QApplication, QMainWindow, QDialog
from qtui.setparamdialog import Ui_Dialog #designer.exe导出的ui对应的python文件
# 创建主类
class MyDialog(QDialog, Ui_Dialog):
def __init__(self, parent=None):
super(MyDialog, self).__init__(parent)
self.setupUi(self)
self.data = {}
def set_data(self, data):
self.data = data
def get_data(self):
return self.data
# 使用dialog
self.dialog = MyDialog()
self.dialog.set_data({msg="1"})
self.dialog.show()
action = self.dialog.exec_() # 返回dialog的操作,取消0或者确定1,看dialog是哪一种类型
print("action =", action)
data = self.dialog.get_data() # 获取自定义数据
网友评论