@@ -37,6 +37,21 @@ def run(self):
37
37
time .sleep (3 )
38
38
39
39
40
+ class MDialogExample (QtWidgets .QDialog ):
41
+ def __init__ (self , parent = None ):
42
+ super (MDialogExample , self ).__init__ (parent = parent )
43
+ main_lay = QtWidgets .QVBoxLayout ()
44
+ button = MPushButton ("Show Message" )
45
+ button .clicked .connect (self .slot_show_message )
46
+
47
+ main_lay .addWidget (MLabel ("This is a dialog in DCC. Click the button to show a message." ))
48
+ main_lay .addWidget (button )
49
+ self .setLayout (main_lay )
50
+
51
+ def slot_show_message (self ):
52
+ MToast .info (parent = self , text = "This is a message" )
53
+
54
+
40
55
class ToastExample (QtWidgets .QWidget , MFieldMixin ):
41
56
def __init__ (self , parent = None ):
42
57
super (ToastExample , self ).__init__ (parent )
@@ -78,6 +93,12 @@ def _init_ui(self):
78
93
main_lay .addWidget (MLabel ("不同的提示状态:成功、失败、加载中。默认2秒后消失" ))
79
94
main_lay .addWidget (loading_button )
80
95
96
+ main_lay .addWidget (MDivider ("Open Dialog" ))
97
+ button_open_dialog = MPushButton ("Open Dialog" )
98
+ button_open_dialog .clicked .connect (self .slot_open_dialog )
99
+ main_lay .addWidget (button_open_dialog )
100
+ main_lay .addWidget (MLabel ("模拟在DCC 里面弹出我们开发的工具窗口" ))
101
+
81
102
main_lay .addStretch ()
82
103
self .setLayout (main_lay )
83
104
@@ -97,6 +118,9 @@ def slot_finished(self):
97
118
self .msg .close ()
98
119
MToast .success ("加载成功" , self )
99
120
121
+ def slot_open_dialog (self ):
122
+ dialog = MDialogExample (self )
123
+ dialog .exec_ ()
100
124
101
125
if __name__ == "__main__" :
102
126
# Import local modules
0 commit comments