3333
3434class Example (QtCore .QObject ):
3535 """ Example showing off the notifications """
36- notify = QtCore .pyqtSignal (str ,str ,int ,str )
36+ notify = QtCore .pyqtSignal (['QString' , 'QString' , int ],
37+ ['QString' , 'QString' , int , 'QString' ])
3738
3839 def __init__ (self ):
3940 super (Example ,self ).__init__ ()
@@ -90,6 +91,10 @@ def __setup_widget(self):
9091 self .exitduration = QtWidgets .QSpinBox (display_widget )
9192 self .exitduration .setRange (100 , 1000 )
9293 self .exitduration .setSingleStep (50 )
94+
95+ self .buttontext_label = QtWidgets .QLabel ("Button text" , display_widget )
96+ self .buttontext_textbox = QtWidgets .QLineEdit (display_widget )
97+
9398 # Send button
9499 send_button = QtWidgets .QPushButton ("Send" , display_widget )
95100
@@ -100,6 +105,7 @@ def __setup_widget(self):
100105 inputLayout .addRow (self .entryduration_label , self .entryduration )
101106 inputLayout .addRow (exiteffect_label , self .exit_dropdown )
102107 inputLayout .addRow (self .exitduration_label , self .exitduration )
108+ inputLayout .addRow (self .buttontext_label , self .buttontext_textbox )
103109 inputLayout .addRow (QtWidgets .QWidget (), send_button )
104110
105111 self .entryduration_label .setDisabled (True )
@@ -112,12 +118,15 @@ def __setup_widget(self):
112118 display_widget .layout ().addLayout (inputLayout )
113119
114120 self .message_textbox .returnPressed .connect (send_button .click )
121+ self .buttontext_textbox .returnPressed .connect (send_button .click )
115122 send_button .clicked .connect (self .__submit_message )
116123 return display_widget
117124
118125 def __setup_notification_area (self , targetWidget ):
119126 notification_area = QNotifications .QNotificationArea (targetWidget )
120- self .notify .connect (notification_area .display )
127+ self .notify ['QString' , 'QString' , int ].connect (notification_area .display )
128+ self .notify ['QString' , 'QString' , int , 'QString' ].connect (
129+ notification_area .display )
121130 return notification_area
122131
123132 def __process_combo_change (self , val ):
@@ -153,7 +162,13 @@ def __submit_message(self):
153162 self .exitduration .value ())
154163 else :
155164 self .notification_area .setExitEffect (None )
156- self .notify .emit (textvalue , typevalue , duration , None )
165+
166+ buttontext = self .buttontext_textbox .text ().strip ()
167+ if buttontext :
168+ self .notify ['QString' , 'QString' , int , 'QString' ].emit (
169+ textvalue , typevalue , duration , buttontext )
170+ else :
171+ self .notify .emit (textvalue , typevalue , duration )
157172
158173if __name__ == "__main__" :
159174 app = QtWidgets .QApplication (sys .argv )
0 commit comments