(
parent, title, submit_text="Submit", update_btn: bool = False
)
| 500 | |
| 501 | |
| 502 | def create_add_employee_page( |
| 503 | parent, title, submit_text="Submit", update_btn: bool = False |
| 504 | ): |
| 505 | page, main_layout = create_page_with_header(parent, title) |
| 506 | |
| 507 | content_frame = create_styled_frame(page) |
| 508 | content_frame.setSizePolicy( |
| 509 | QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding |
| 510 | ) |
| 511 | content_layout = QtWidgets.QVBoxLayout(content_frame) |
| 512 | |
| 513 | form_frame = create_styled_frame( |
| 514 | content_frame, |
| 515 | min_size=(340, 200), |
| 516 | style="background-color: #ffffff; border-radius: 15px; padding: 10px;", |
| 517 | ) |
| 518 | form_layout = QtWidgets.QVBoxLayout(form_frame) |
| 519 | form_layout.setSpacing(10) |
| 520 | |
| 521 | # Define input fields |
| 522 | fields = ["Name :", "Password :", "Salary :", "Position :"] |
| 523 | name_edit = None |
| 524 | password_edit = None |
| 525 | salary_edit = None |
| 526 | position_edit = None |
| 527 | edits = [] |
| 528 | |
| 529 | for i, field in enumerate(fields): |
| 530 | field_frame, field_edit = create_input_field(form_frame, field) |
| 531 | form_layout.addWidget(field_frame) |
| 532 | if i == 0: |
| 533 | name_edit = field_edit |
| 534 | elif i == 1: |
| 535 | password_edit = field_edit |
| 536 | elif i == 2: |
| 537 | salary_edit = field_edit |
| 538 | elif i == 3: |
| 539 | position_edit = field_edit |
| 540 | edits.append(field_edit) |
| 541 | # Submit button |
| 542 | button_frame = create_styled_frame(form_frame, style="padding: 7px;") |
| 543 | button_layout = QtWidgets.QVBoxLayout(button_frame) |
| 544 | if update_btn: |
| 545 | update_button = create_styled_button(button_frame, "Update", min_size=(100, 50)) |
| 546 | button_layout.addWidget(update_button, 0, QtCore.Qt.AlignHCenter) |
| 547 | else: |
| 548 | submit_button = create_styled_button( |
| 549 | button_frame, submit_text, min_size=(100, 50) |
| 550 | ) |
| 551 | button_layout.addWidget(submit_button, 0, QtCore.Qt.AlignHCenter) |
| 552 | |
| 553 | form_layout.addWidget(button_frame) |
| 554 | content_layout.addWidget( |
| 555 | form_frame, 0, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter |
| 556 | ) |
| 557 | main_layout.addWidget(content_frame) |
| 558 | back_btn = QtWidgets.QPushButton("Back", content_frame) |
| 559 | back_btn.setStyleSheet(""" |
no test coverage detected