Create a login page with a title, name and password fields, and a submit button.
(
parent,
title,
name_field_text="Name :",
password_field_text="Password :",
submit_text="Submit",
)
| 327 | |
| 328 | |
| 329 | def create_login_page( |
| 330 | parent, |
| 331 | title, |
| 332 | name_field_text="Name :", |
| 333 | password_field_text="Password :", |
| 334 | submit_text="Submit", |
| 335 | ): |
| 336 | """Create a login page with a title, name and password fields, and a submit button.""" |
| 337 | page, main_layout = create_page_with_header(parent, title) |
| 338 | |
| 339 | # Content frame |
| 340 | content_frame = create_styled_frame(page) |
| 341 | content_frame.setSizePolicy( |
| 342 | QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding |
| 343 | ) |
| 344 | content_layout = QtWidgets.QVBoxLayout(content_frame) |
| 345 | |
| 346 | # Form frame |
| 347 | form_frame = create_styled_frame( |
| 348 | content_frame, |
| 349 | min_size=(340, 200), |
| 350 | style="background-color: #ffffff; border-radius: 15px; padding: 10px;", |
| 351 | ) |
| 352 | form_layout = QtWidgets.QVBoxLayout(form_frame) |
| 353 | form_layout.setSpacing(20) |
| 354 | |
| 355 | # Input fields |
| 356 | name_frame, name_edit = create_input_field(form_frame, name_field_text) |
| 357 | password_frame, password_edit = create_input_field(form_frame, password_field_text) |
| 358 | |
| 359 | # Submit button |
| 360 | button_frame = create_styled_frame(form_frame, style="padding: 7px;") |
| 361 | button_layout = QtWidgets.QVBoxLayout(button_frame) |
| 362 | button_layout.setSpacing(60) |
| 363 | submit_button = create_styled_button(button_frame, submit_text, min_size=(150, 0)) |
| 364 | button_layout.addWidget(submit_button, 0, QtCore.Qt.AlignHCenter) |
| 365 | |
| 366 | form_layout.addWidget(name_frame) |
| 367 | form_layout.addWidget(password_frame) |
| 368 | form_layout.addWidget(button_frame) |
| 369 | |
| 370 | content_layout.addWidget( |
| 371 | form_frame, 0, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter |
| 372 | ) |
| 373 | main_layout.addWidget(content_frame) |
| 374 | |
| 375 | return page, name_edit, password_edit, submit_button |
| 376 | |
| 377 | |
| 378 | def on_login_button_clicked(parent, name_field, password_field): |
no test coverage detected