summaryrefslogtreecommitdiff
path: root/assignment_list_pyqt/add_group_form.py
diff options
context:
space:
mode:
authorLouie Shprung <lshprung@scu.edu>2023-12-21 13:17:39 -0800
committerLouie Shprung <lshprung@scu.edu>2023-12-21 13:17:39 -0800
commit65d8cbafe34b946d450ce46703e6449eb9962741 (patch)
tree9cb2bfa4857507207e8740478e5d23d4421ad784 /assignment_list_pyqt/add_group_form.py
parent11373742d701166f2580cfe67015eac012cda1a9 (diff)
Rename src directory to unique name to avoid install issues
Diffstat (limited to 'assignment_list_pyqt/add_group_form.py')
-rw-r--r--assignment_list_pyqt/add_group_form.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/assignment_list_pyqt/add_group_form.py b/assignment_list_pyqt/add_group_form.py
new file mode 100644
index 0000000..b6cb804
--- /dev/null
+++ b/assignment_list_pyqt/add_group_form.py
@@ -0,0 +1,47 @@
+import os
+import sys
+from PyQt5 import uic
+from PyQt5.QtWidgets import QApplication, QDialog, QMessageBox
+
+import assignment_list_pyqt.globals as Globals
+from assignment_list_pyqt.group import Group
+import assignment_list_pyqt.db_sqlite as DB
+
+class addGroupForm(QDialog):
+ """
+ Implemented so that it can be used for adding and editing groups
+ """
+ def __init__(self):
+ super().__init__()
+ uic.loadUi(os.path.join(os.path.dirname(os.path.abspath(__file__)),
+ "add_group_form.ui"), self)
+ self.initializeUI()
+
+ def initializeUI(self):
+ self.displayWidgets()
+ self.exec()
+
+ def displayWidgets(self):
+ self.buttonBox.rejected.connect(self.close)
+ self.buttonBox.accepted.connect(self.handleSubmit)
+
+ def handleSubmit(self):
+ 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",
+ "Name cannot be blank",
+ QMessageBox.Close,
+ QMessageBox.Close)
+ return
+
+ new_id = DB.insertGroup(Group(0, name_text, column_text, link_text))
+ Globals.groups.append(Group(new_id, name_text, column_text, link_text))
+ self.close()
+
+if __name__ == "__main__":
+ app = QApplication(sys.argv)
+ window = addGroupForm()
+ sys.exit(app.exec_())