@@ -68,7 +68,91 @@ def create_input_field(parent, label_text, min_label_size=(120, 0)):
68
68
layout .addWidget (label )
69
69
layout .addWidget (line_edit )
70
70
return frame , line_edit
71
+ def pop_up_message (parent , message : str , page : int ):
72
+ """Create a popup message box with a given message."""
73
+ dialog = QtWidgets .QDialog (parent )
74
+ dialog .setWindowTitle ("Message" )
75
+ dialog .setFixedSize (350 , 100 )
76
+ dialog .setStyleSheet ("background-color: #f0f0f0;" )
77
+
78
+ layout = QtWidgets .QVBoxLayout (dialog )
79
+ layout .setSpacing (10 )
80
+ layout .setContentsMargins (15 , 15 , 15 , 15 )
81
+
82
+ label = QtWidgets .QLabel (message )
83
+ label .setStyleSheet ("font-size: 12px; color: #2c3e50;" )
84
+ label .setWordWrap (True )
85
+ layout .addWidget (label )
86
+
87
+ button_box = QtWidgets .QDialogButtonBox (
88
+ QtWidgets .QDialogButtonBox .Ok | QtWidgets .QDialogButtonBox .Cancel
89
+ )
90
+ button_box .setStyleSheet ("""
91
+ QPushButton {
92
+ background-color: #3498db;
93
+ color: white;
94
+ border-radius: 4px;
95
+ padding: 6px 12px;
96
+ min-width: 80px;
97
+ }
98
+ QPushButton:hover {
99
+ background-color: #2980b9;
100
+ }
101
+ QPushButton:pressed {
102
+ background-color: #1c6ea4;
103
+ }
104
+ """ )
105
+ layout .addWidget (button_box )
106
+
107
+ button_box .accepted .connect (dialog .accept )
108
+ button_box .rejected .connect (lambda : reject_clicked (dialog , parent , page ))
109
+
110
+ dialog .exec_ ()
71
111
112
+ def reject_clicked (dialog , parent , page ):
113
+ parent .setCurrentIndex (page )
114
+ dialog .reject ()
115
+
116
+ def pop_up_message_with_only_ok (parent , message : str , page : int ):
117
+ """Create a popup message box with only an OK button."""
118
+ dialog = QtWidgets .QDialog (parent )
119
+ dialog .setWindowTitle ("Message" )
120
+ dialog .setFixedSize (350 , 100 )
121
+ dialog .setStyleSheet ("background-color: #f0f0f0;" )
122
+
123
+ layout = QtWidgets .QVBoxLayout (dialog )
124
+ layout .setSpacing (10 )
125
+ layout .setContentsMargins (15 , 15 , 15 , 15 )
126
+
127
+ label = QtWidgets .QLabel (message )
128
+ label .setStyleSheet ("font-size: 12px; color: #2c3e50;" )
129
+ label .setWordWrap (True )
130
+ layout .addWidget (label )
131
+
132
+ button_box = QtWidgets .QDialogButtonBox (QtWidgets .QDialogButtonBox .Ok )
133
+ button_box .setStyleSheet ("""
134
+ QPushButton {
135
+ background-color: #3498db;
136
+ color: white;
137
+ border-radius: 4px;
138
+ padding: 6px 12px;
139
+ min-width: 80px;
140
+ }
141
+ QPushButton:hover {
142
+ background-color: #2980b9;
143
+ }
144
+ QPushButton:pressed {
145
+ background-color: #1c6ea4;
146
+ }
147
+ """ )
148
+ layout .addWidget (button_box )
149
+
150
+ button_box .accepted .connect (lambda : accepted_clicked ())
151
+ def accepted_clicked ():
152
+ parent .setCurrentIndex (page )
153
+ dialog .close ()
154
+
155
+ dialog .exec_ ()
72
156
def create_login_page (parent ,title , name_field_text = "Name :" , password_field_text = "Password :" , submit_text = "Submit" ,):
73
157
"""Create a login page with a title, name and password fields, and a submit button."""
74
158
page = QtWidgets .QWidget (parent )
0 commit comments