diff options
author | Louie Shprung <lshprung@scu.edu> | 2023-12-21 10:13:55 -0800 |
---|---|---|
committer | Louie Shprung <lshprung@scu.edu> | 2023-12-21 10:13:55 -0800 |
commit | 136bb96267b470420bf347bb4e993abfbfa17e9c (patch) | |
tree | 0cac97cae808e5ff400ec415aa9618405def34d3 | |
parent | 296957cd555e638aa826cdabd42e36964862c27d (diff) |
edit_group_form uses add_group_form UI file
-rw-r--r-- | src/edit_group_form.py | 53 |
1 files changed, 13 insertions, 40 deletions
diff --git a/src/edit_group_form.py b/src/edit_group_form.py index c4a8622..e29a0fb 100644 --- a/src/edit_group_form.py +++ b/src/edit_group_form.py @@ -1,7 +1,7 @@ +import os import sys -from PyQt5.QtWidgets import QApplication, QComboBox, QDialog, QFormLayout, QHBoxLayout, QLabel, QLineEdit, QMessageBox, QPushButton -from PyQt5.QtGui import QFont -from PyQt5.QtCore import Qt +from PyQt5 import uic +from PyQt5.QtWidgets import QApplication, QDialog, QMessageBox import src.globals as Globals from src.group import Group @@ -14,55 +14,28 @@ class editGroupForm(QDialog): def __init__(self, id): self.id = id super().__init__() + uic.loadUi(os.path.join("src", "add_group_form.ui"), self) self.initializeUI() def initializeUI(self): - self.resize(400, 1) self.setWindowTitle("Edit Group") self.displayWidgets() self.exec() def displayWidgets(self): - group_form_layout = QFormLayout() group = list(filter(lambda g: g.id == self.id, Globals.groups))[0] - title = QLabel("Edit Group") - title.setFont(QFont("Arial", 18)) - title.setAlignment(Qt.AlignCenter) - group_form_layout.addRow(title) - - self.group_name = QLineEdit() - self.group_name.setText(group.name) - group_form_layout.addRow("Name:", self.group_name) - - self.group_column = QComboBox() - self.group_column.addItems(["Left", "Right"]) - self.group_column.setCurrentIndex(0 if group.column.lower() == "left" else 1) - group_form_layout.addRow("Column:", self.group_column) - - self.group_link = QLineEdit() # TODO see if there is a widget specifically for URLs - self.group_link.setText(group.link) - group_form_layout.addRow("Link:", self.group_link) - - # Submit and cancel buttons - buttons_h_box = QHBoxLayout() - buttons_h_box.addStretch() - close_button = QPushButton("Cancel") - close_button.clicked.connect(self.close) - buttons_h_box.addWidget(close_button) - submit_button = QPushButton("Submit") - submit_button.clicked.connect(self.handleSubmit) - buttons_h_box.addWidget(submit_button) - buttons_h_box.addStretch() - - group_form_layout.addRow(buttons_h_box) - - self.setLayout(group_form_layout) + self.title.setText("Edit Group") + self.new_group_name.setText(group.name) + self.new_group_column.setCurrentIndex(0 if group.column.lower() == "left" else 1) + self.new_group_link.setText(group.link) + self.buttonBox.rejected.connect(self.close) + self.buttonBox.accepted.connect(self.handleSubmit) def handleSubmit(self): - name_text = self.group_name.text() - column_text = self.group_column.currentText() - link_text = self.group_link.text() + name_text = self.new_group_name.text() + column_text = self.new_group_column.currentText() + link_text = self.new_group_link.text() if not name_text: QMessageBox.warning(self, "Error Message", |