From 9a8d1839f23f0cccf4eb7ff91ce575d863d020f6 Mon Sep 17 00:00:00 2001 From: Louie Shprung Date: Wed, 20 Dec 2023 11:55:47 -0800 Subject: Created UI file for main window --- src/main.py | 118 +++++++++++++++++----------------- src/main.ui | 207 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 266 insertions(+), 59 deletions(-) create mode 100644 src/main.ui (limited to 'src') diff --git a/src/main.py b/src/main.py index fed6830..9e6f4c0 100644 --- a/src/main.py +++ b/src/main.py @@ -1,7 +1,9 @@ #!/usr/bin/python3 +import os import sys import time -from PyQt5.QtWidgets import QAction, QApplication, QGridLayout, QHBoxLayout, QLabel, QMainWindow, QMenu, QMessageBox, QScrollArea, QToolBar, QVBoxLayout, QWidget +from PyQt5 import uic +from PyQt5.QtWidgets import QAction, QApplication, QGridLayout, QHBoxLayout, QLabel, QMainWindow, QMenu, QMessageBox, QScrollArea, QVBoxLayout, QWidget from PyQt5.QtGui import QCursor, QFont from PyQt5.QtCore import QDate, Qt from src.config import Config @@ -17,12 +19,13 @@ from src.rules_dialog import RulesDialog class AssignmentList(QMainWindow): def __init__(self): super().__init__() + uic.loadUi(os.path.join("src", "main.ui"), self) self.initializeUI() def initializeUI(self): - self.resize(640, 480) - self.setWindowTitle("Assignment List") + #self.resize(640, 480) + #self.setWindowTitle("Assignment List") self.createMenu() self.createToolbar() Config() @@ -31,72 +34,69 @@ class AssignmentList(QMainWindow): self.show() def createMenu(self): - menu_bar = self.menuBar() - file_menu = menu_bar.addMenu("File") - edit_menu = menu_bar.addMenu("Edit") - help_menu = menu_bar.addMenu("Help") - - self.preferences_act = QAction("Preferences", self) - self.preferences_act.setShortcut("Alt+Return") - self.preferences_act.triggered.connect(self.preferences) - file_menu.addAction(self.preferences_act) - self.reload_act = QAction("Reload", self) - self.reload_act.setShortcut("F5") - self.reload_act.triggered.connect(self.reload) - file_menu.addAction(self.reload_act) - file_menu.addSeparator() - exit_act = QAction("Exit", self) - exit_act.setShortcut("Ctrl+Q") - exit_act.triggered.connect(self.close) - file_menu.addAction(exit_act) - - self.add_group_act = QAction("Add Group", self) - self.add_group_act.triggered.connect(self.addGroup) - edit_menu.addAction(self.add_group_act) - edit_menu.addSeparator() - self.clean_hidden_act = QAction("Permanently Delete Removed Groups and Entries", self) - self.clean_hidden_act.triggered.connect(self.cleanHidden) - edit_menu.addAction(self.clean_hidden_act) - - about_act = QAction("About", self) - about_act.triggered.connect(self.aboutDialog) - help_menu.addAction(about_act) + #menu_bar = self.menuBar() + #file_menu = menu_bar.addMenu("File") + #edit_menu = menu_bar.addMenu("Edit") + #help_menu = menu_bar.addMenu("Help") + + #self.preferences_act = QAction("Preferences", self) + #self.preferences_act.setShortcut("Alt+Return") + self.actionPreferences.triggered.connect(self.preferences) + #file_menu.addAction(self.preferences_act) + #self.reload_act = QAction("Reload", self) + #self.reload_act.setShortcut("F5") + self.actionReload.triggered.connect(self.reload) + #file_menu.addAction(self.reload_act) + #file_menu.addSeparator() + #exit_act = QAction("Exit", self) + #exit_act.setShortcut("Ctrl+Q") + self.actionExit.triggered.connect(self.close) + #file_menu.addAction(exit_act) + + #self.add_group_act = QAction("Add Group", self) + self.actionAdd_Group.triggered.connect(self.addGroup) + #self.actionAdd_Group.addAction(self.add_group_act) + #edit_menu.addSeparator() + #self.clean_hidden_act = QAction("Permanently Delete Removed Groups and Entries", self) + self.actionClean_Hidden.triggered.connect(self.cleanHidden) + #edit_menu.addAction(self.clean_hidden_act) + + #about_act = QAction("About", self) + self.actionAbout.triggered.connect(self.aboutDialog) + #help_menu.addAction(about_act) def createToolbar(self): - tool_bar = QToolBar("Toolbar") - self.addToolBar(tool_bar) - - tool_bar.addAction(self.add_group_act) + self.toolBar.addAction(self.actionAdd_Group) def setupDB(self): DB.initDB() def displayWidgets(self): - main_widget_scroll_area = QScrollArea(self) - main_widget_scroll_area.setWidgetResizable(True) - main_widget = QWidget() - self.setCentralWidget(main_widget_scroll_area) - - title = QLabel(time.strftime("%A, %b %d %Y")) - title.setFont(QFont("Arial", 17)) - title.setTextInteractionFlags(Qt.TextSelectableByMouse) - - title_h_box = QHBoxLayout() - title_h_box.addStretch() - title_h_box.addWidget(title) - title_h_box.addStretch() - - self.groups_layout = QGridLayout() - self.groups_layout.setContentsMargins(20, 5, 20, 5) + #main_widget_scroll_area = QScrollArea(self) + #main_widget_scroll_area.setWidgetResizable(True) + #main_widget = QWidget() + #self.setCentralWidget(main_widget_scroll_area) + + self.title.setText(time.strftime("%A, %b %d %Y")) + #self.title.setFont(QFont("Arial", 17)) + #self.title.setTextInteractionFlags(Qt.TextSelectableByMouse) + + #title_h_box = QHBoxLayout() + #title_h_box.addStretch() + #title_h_box.addWidget(title) + #title_h_box.addStretch() + + #self.groups_layout = QGridLayout() + #self.groups_layout.setContentsMargins(20, 5, 20, 5) self.drawGroups() - v_box = QVBoxLayout() - v_box.addLayout(title_h_box) - v_box.addLayout(self.groups_layout) - v_box.addStretch() + #v_box = QVBoxLayout() + #v_box.addLayout(title_h_box) + #v_box.addLayout(self.groups_layout) + #v_box.addStretch() - main_widget.setLayout(v_box) - main_widget_scroll_area.setWidget(main_widget) + #main_widget.setLayout(v_box) + #main_widget_scroll_area.setWidget(main_widget) def addGroup(self): """ diff --git a/src/main.ui b/src/main.ui new file mode 100644 index 0000000..bc3c0fb --- /dev/null +++ b/src/main.ui @@ -0,0 +1,207 @@ + + + MainWindow + + + + 0 + 0 + 640 + 480 + + + + Assignment List + + + + + + + true + + + + + 0 + 0 + 620 + 421 + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + Arial + 17 + + + + [DATE] + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 20 + + + 5 + + + 20 + + + 5 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + 0 + 0 + 640 + 22 + + + + + File + + + + + + + + + Edit + + + + + + + + Help + + + + + + + + + + toolBar + + + TopToolBarArea + + + false + + + + + Preferences + + + Alt+Return + + + + + Reload + + + F5 + + + + + Exit + + + Ctrl+Q + + + + + Add Group + + + + + Permanently Delete Removed Groups and Entries + + + + + About + + + + + + -- cgit From bf4372d2cd3c13fe1e5d254da3d92436da9eef6a Mon Sep 17 00:00:00 2001 From: Louie Shprung Date: Thu, 21 Dec 2023 09:34:04 -0800 Subject: Created UI file for add_entry_window --- src/add_entry_form.py | 61 +++-------------- src/add_entry_form.ui | 185 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.py | 51 +------------- 3 files changed, 195 insertions(+), 102 deletions(-) create mode 100644 src/add_entry_form.ui (limited to 'src') diff --git a/src/add_entry_form.py b/src/add_entry_form.py index 9550108..ff66a19 100644 --- a/src/add_entry_form.py +++ b/src/add_entry_form.py @@ -1,7 +1,8 @@ +import os import sys -from PyQt5.QtWidgets import QApplication, QCheckBox, QDateTimeEdit, QDialog, QFormLayout, QHBoxLayout, QLabel, QLineEdit, QMessageBox, QPushButton -from PyQt5.QtGui import QFont -from PyQt5.QtCore import QDate, Qt +from PyQt5 import uic +from PyQt5.QtWidgets import QApplication, QDialog, QMessageBox +from PyQt5.QtCore import QDate from src.entry import Entry import src.globals as Globals import src.db_sqlite as DB @@ -9,63 +10,17 @@ import src.db_sqlite as DB class addEntryForm(QDialog): def __init__(self, parent): super().__init__() + uic.loadUi(os.path.join("src", "add_entry_form.ui"), self) self.initializeUI(parent) def initializeUI(self, parent): - self.resize(400, 1) - self.setWindowTitle("Add Entry") self.displayWidgets(parent) self.exec() def displayWidgets(self, parent): - entry_form_layout = QFormLayout() - - title = QLabel("Add Entry") - title.setFont(QFont("Arial", 18)) - title.setAlignment(Qt.AlignCenter) - entry_form_layout.addRow(title) - - self.new_entry_desc = QLineEdit() - entry_form_layout.addRow("Description:", self.new_entry_desc) - - self.due_hbox = QHBoxLayout() - self.new_entry_due = QDateTimeEdit(QDate.currentDate()) - self.new_entry_due.setDisplayFormat("MM/dd/yyyy") - self.due_hbox.addWidget(self.new_entry_due) - self.new_entry_due_checkbox = QCheckBox() - self.new_entry_due_checkbox.setChecked(True) - self.due_hbox.addWidget(self.new_entry_due_checkbox) - entry_form_layout.addRow("Due Date:", self.due_hbox) - - self.new_entry_due_alt = QLineEdit() - entry_form_layout.addRow("Due Date (Alt):", self.new_entry_due_alt) - - self.new_entry_link = QLineEdit() # TODO see if there is a widget specifically for URLs - entry_form_layout.addRow("Link:", self.new_entry_link) - - # TODO: - # depends - - self.new_entry_color = QLineEdit() - entry_form_layout.addRow("Color:", self.new_entry_color) - - self.new_entry_highlight = QLineEdit() - entry_form_layout.addRow("Highlight:", self.new_entry_highlight) - - # 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(lambda: self.handleSubmit(parent)) - buttons_h_box.addWidget(submit_button) - buttons_h_box.addStretch() - - entry_form_layout.addRow(buttons_h_box) - - self.setLayout(entry_form_layout) + self.new_entry_due.setDate(QDate.currentDate()) + self.buttonBox.rejected.connect(self.close) + self.buttonBox.accepted.connect(lambda: self.handleSubmit(parent)) def handleSubmit(self, parent): # Check that the new entry is not blank diff --git a/src/add_entry_form.ui b/src/add_entry_form.ui new file mode 100644 index 0000000..3f8f9e7 --- /dev/null +++ b/src/add_entry_form.ui @@ -0,0 +1,185 @@ + + + Dialog + + + + 0 + 0 + 400 + 266 + + + + Add Entry + + + + + + + + Description: + + + + + + + + + + + Arial + 18 + + + + Add Entry + + + Qt::AlignCenter + + + + + + + Due Date: + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + MM/dd/yyyy + + + + + + + true + + + + + + true + + + + + + + + + + Due Date (Alt): + + + + + + + + + + Link: + + + + + + + + + + Color: + + + + + + + + + + Highlight: + + + + + + + + + + + + Qt::RightToLeft + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + true + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/main.py b/src/main.py index 9e6f4c0..91ddeca 100644 --- a/src/main.py +++ b/src/main.py @@ -3,8 +3,8 @@ import os import sys import time from PyQt5 import uic -from PyQt5.QtWidgets import QAction, QApplication, QGridLayout, QHBoxLayout, QLabel, QMainWindow, QMenu, QMessageBox, QScrollArea, QVBoxLayout, QWidget -from PyQt5.QtGui import QCursor, QFont +from PyQt5.QtWidgets import QAction, QApplication, QMainWindow, QMenu, QMessageBox, QVBoxLayout +from PyQt5.QtGui import QCursor from PyQt5.QtCore import QDate, Qt from src.config import Config from src.preferences_dialog import PreferencesDialog @@ -24,8 +24,6 @@ class AssignmentList(QMainWindow): self.initializeUI() def initializeUI(self): - #self.resize(640, 480) - #self.setWindowTitle("Assignment List") self.createMenu() self.createToolbar() Config() @@ -34,36 +32,14 @@ class AssignmentList(QMainWindow): self.show() def createMenu(self): - #menu_bar = self.menuBar() - #file_menu = menu_bar.addMenu("File") - #edit_menu = menu_bar.addMenu("Edit") - #help_menu = menu_bar.addMenu("Help") - - #self.preferences_act = QAction("Preferences", self) - #self.preferences_act.setShortcut("Alt+Return") self.actionPreferences.triggered.connect(self.preferences) - #file_menu.addAction(self.preferences_act) - #self.reload_act = QAction("Reload", self) - #self.reload_act.setShortcut("F5") self.actionReload.triggered.connect(self.reload) - #file_menu.addAction(self.reload_act) - #file_menu.addSeparator() - #exit_act = QAction("Exit", self) - #exit_act.setShortcut("Ctrl+Q") self.actionExit.triggered.connect(self.close) - #file_menu.addAction(exit_act) - #self.add_group_act = QAction("Add Group", self) self.actionAdd_Group.triggered.connect(self.addGroup) - #self.actionAdd_Group.addAction(self.add_group_act) - #edit_menu.addSeparator() - #self.clean_hidden_act = QAction("Permanently Delete Removed Groups and Entries", self) self.actionClean_Hidden.triggered.connect(self.cleanHidden) - #edit_menu.addAction(self.clean_hidden_act) - #about_act = QAction("About", self) self.actionAbout.triggered.connect(self.aboutDialog) - #help_menu.addAction(about_act) def createToolbar(self): self.toolBar.addAction(self.actionAdd_Group) @@ -72,32 +48,9 @@ class AssignmentList(QMainWindow): DB.initDB() def displayWidgets(self): - #main_widget_scroll_area = QScrollArea(self) - #main_widget_scroll_area.setWidgetResizable(True) - #main_widget = QWidget() - #self.setCentralWidget(main_widget_scroll_area) - self.title.setText(time.strftime("%A, %b %d %Y")) - #self.title.setFont(QFont("Arial", 17)) - #self.title.setTextInteractionFlags(Qt.TextSelectableByMouse) - - #title_h_box = QHBoxLayout() - #title_h_box.addStretch() - #title_h_box.addWidget(title) - #title_h_box.addStretch() - - #self.groups_layout = QGridLayout() - #self.groups_layout.setContentsMargins(20, 5, 20, 5) self.drawGroups() - #v_box = QVBoxLayout() - #v_box.addLayout(title_h_box) - #v_box.addLayout(self.groups_layout) - #v_box.addStretch() - - #main_widget.setLayout(v_box) - #main_widget_scroll_area.setWidget(main_widget) - def addGroup(self): """ Open the 'addGroup' form -- cgit From 952bba169a05d2c93ac57719cbe0f55e9cebecc7 Mon Sep 17 00:00:00 2001 From: Louie Shprung Date: Thu, 21 Dec 2023 09:53:49 -0800 Subject: edit_entry_window uses add_entry_window UI file --- src/edit_entry_form.py | 88 ++++++++++++++------------------------------------ 1 file changed, 25 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/edit_entry_form.py b/src/edit_entry_form.py index 55c388c..c1d3664 100644 --- a/src/edit_entry_form.py +++ b/src/edit_entry_form.py @@ -1,12 +1,14 @@ +import os import sys -from PyQt5.QtWidgets import QApplication, QCheckBox, QDateTimeEdit, QDialog, QFormLayout, QHBoxLayout, QLabel, QLineEdit, QMessageBox, QPushButton -from PyQt5.QtGui import QFont -from PyQt5.QtCore import QDate, Qt +from PyQt5 import uic +from PyQt5.QtWidgets import QApplication, QDialog, QMessageBox +from PyQt5.QtCore import QDate import src.globals as Globals from src.entry import Entry import src.db_sqlite as DB +# Reuses the add_entry_form UI file class editEntryForm(QDialog): """ Form to edit/update an entry @@ -14,82 +16,42 @@ class editEntryForm(QDialog): def __init__(self, id): self.id = id super().__init__() + uic.loadUi(os.path.join("src", "add_entry_form.ui"), self) self.initializeUI() def initializeUI(self): - self.resize(400, 1) self.setWindowTitle("Edit Entry") self.displayWidgets() self.exec() def displayWidgets(self): - entry_form_layout = QFormLayout() entry = list(filter(lambda e: e.id == self.id, Globals.entries))[0] - title = QLabel("Edit Entry") - title.setFont(QFont("Arial", 18)) - title.setAlignment(Qt.AlignCenter) - entry_form_layout.addRow(title) - - self.entry_desc = QLineEdit() - self.entry_desc.setText(entry.desc) - entry_form_layout.addRow("Description:", self.entry_desc) - - self.due_hbox = QHBoxLayout() - self.entry_due = QDateTimeEdit(QDate.currentDate()) - self.entry_due.setDisplayFormat("MM/dd/yyyy") - if entry.due: - self.entry_due.setDate(entry.due) - self.due_hbox.addWidget(self.entry_due) - self.entry_due_checkbox = QCheckBox() + self.title.setText("Edit Entry") + self.new_entry_desc.setText(entry.desc) + self.new_entry_due.setDate(QDate.currentDate()) if entry.due: - self.entry_due_checkbox.setChecked(True) + self.new_entry_due.setDate(entry.due) + self.new_entry_due_checkbox.setChecked(True) else: - self.entry_due_checkbox.setChecked(False) - self.due_hbox.addWidget(self.entry_due_checkbox) - entry_form_layout.addRow("Due Date:", self.due_hbox) - - self.entry_due_alt = QLineEdit() - self.entry_due_alt.setText(entry.due_alt) - entry_form_layout.addRow("Due Date (Alt):", self.entry_due_alt) - - self.entry_link = QLineEdit() # TODO see if there is a widget specifically for URLs - self.entry_link.setText(entry.link) - entry_form_layout.addRow("Link:", self.entry_link) - - self.entry_color = QLineEdit() - self.entry_color.setText(entry.color) - entry_form_layout.addRow("Color:", self.entry_color) - - self.entry_highlight = QLineEdit() - self.entry_highlight.setText(entry.highlight) - entry_form_layout.addRow("Highlight:", self.entry_highlight) - - # 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() - - entry_form_layout.addRow(buttons_h_box) - - self.setLayout(entry_form_layout) + self.new_entry_due_checkbox.setChecked(False) + self.new_entry_due_alt.setText(entry.due_alt) + self.new_entry_link.setText(entry.link) + self.new_entry_color.setText(entry.color) + self.new_entry_highlight.setText(entry.highlight) + self.buttonBox.rejected.connect(self.close) + self.buttonBox.accepted.connect(self.handleSubmit) def handleSubmit(self): - desc_text = self.entry_desc.text() - if self.entry_due_checkbox.isChecked(): - due_text = self.entry_due.date() # due_text is a QDate + desc_text = self.new_entry_desc.text() + if self.new_entry_due_checkbox.isChecked(): + due_text = self.new_entry_due.date() # due_text is a QDate else: due_text = "" # due is unchecked - due_alt_text = self.entry_due_alt.text() - link_text = self.entry_link.text() - color_text = self.entry_color.text() - highlight_text = self.entry_highlight.text() + due_alt_text = self.new_entry_due_alt.text() + link_text = self.new_entry_link.text() + color_text = self.new_entry_color.text() + highlight_text = self.new_entry_highlight.text() if not desc_text: QMessageBox.warning(self, "Error Message", -- cgit From 296957cd555e638aa826cdabd42e36964862c27d Mon Sep 17 00:00:00 2001 From: Louie Shprung Date: Thu, 21 Dec 2023 10:09:03 -0800 Subject: Created UI file for add_group_form --- src/add_group_form.py | 42 +++------------- src/add_group_form.ui | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+), 36 deletions(-) create mode 100644 src/add_group_form.ui (limited to 'src') diff --git a/src/add_group_form.py b/src/add_group_form.py index b7144d0..0d35777 100644 --- a/src/add_group_form.py +++ b/src/add_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 @@ -13,46 +13,16 @@ class addGroupForm(QDialog): """ def __init__(self): super().__init__() + uic.loadUi(os.path.join("src", "add_group_form.ui"), self) self.initializeUI() def initializeUI(self): - self.resize(400, 1) - self.setWindowTitle("Add Group") self.displayWidgets() self.exec() def displayWidgets(self): - group_form_layout = QFormLayout() - - title = QLabel("Add Group") - title.setFont(QFont("Arial", 18)) - title.setAlignment(Qt.AlignCenter) - group_form_layout.addRow(title) - - self.new_group_name = QLineEdit() - group_form_layout.addRow("Name:", self.new_group_name) - - self.new_group_column = QComboBox() - self.new_group_column.addItems(["Left", "Right"]) - group_form_layout.addRow("Column:", self.new_group_column) - - self.new_group_link = QLineEdit() # TODO see if there is a widget specifically for URLs - group_form_layout.addRow("Link:", self.new_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.buttonBox.rejected.connect(self.close) + self.buttonBox.accepted.connect(self.handleSubmit) def handleSubmit(self): name_text = self.new_group_name.text() diff --git a/src/add_group_form.ui b/src/add_group_form.ui new file mode 100644 index 0000000..c3c5c80 --- /dev/null +++ b/src/add_group_form.ui @@ -0,0 +1,131 @@ + + + Dialog + + + + 0 + 0 + 400 + 172 + + + + Add Entry + + + + + + + + + Arial + 18 + + + + Add Group + + + Qt::AlignCenter + + + + + + + Name: + + + + + + + + + + Column: + + + + + + + + Left + + + + + Right + + + + + + + + Link: + + + + + + + + + + + + Qt::RightToLeft + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + true + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + -- cgit From 136bb96267b470420bf347bb4e993abfbfa17e9c Mon Sep 17 00:00:00 2001 From: Louie Shprung Date: Thu, 21 Dec 2023 10:13:55 -0800 Subject: edit_group_form uses add_group_form UI file --- src/edit_group_form.py | 53 +++++++++++++------------------------------------- 1 file changed, 13 insertions(+), 40 deletions(-) (limited to 'src') 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", -- cgit From b1b3c4e8bc3fb58d77cd7c6aa5de6cc7e4690fb6 Mon Sep 17 00:00:00 2001 From: Louie Shprung Date: Thu, 21 Dec 2023 10:55:46 -0800 Subject: Created UI file for preferences_dialog --- src/preferences_dialog.py | 51 ++++-------------- src/preferences_dialog.ui | 128 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+), 42 deletions(-) create mode 100644 src/preferences_dialog.ui (limited to 'src') diff --git a/src/preferences_dialog.py b/src/preferences_dialog.py index 7f39fb7..e6d4187 100644 --- a/src/preferences_dialog.py +++ b/src/preferences_dialog.py @@ -1,5 +1,7 @@ +import os import sys -from PyQt5.QtWidgets import QApplication, QDialog, QFileDialog, QFormLayout, QHBoxLayout, QLineEdit, QPushButton, QTabWidget, QVBoxLayout, QWidget +from PyQt5 import uic +from PyQt5.QtWidgets import QApplication, QDialog, QFileDialog from src.config import Config class PreferencesDialog(QDialog): @@ -8,6 +10,7 @@ class PreferencesDialog(QDialog): """ def __init__(self): super().__init__() + uic.loadUi(os.path.join("src", "preferences_dialog.ui"), self) # class globals self.config = Config() @@ -15,58 +18,22 @@ class PreferencesDialog(QDialog): self.initializeUI() def initializeUI(self): - self.resize(500, 320) - self.setWindowTitle("Preferences") self.displayWidgets() self.exec() def displayWidgets(self): # TODO make this a scrollable window # FIXME could use some work on sizing - main_layout = QVBoxLayout() - tab_bar = QTabWidget(self) - paths_tab = self.pathsTabLayout() + self.pathsTabLayout() - tab_bar.addTab(paths_tab, "Paths") - main_layout.addWidget(tab_bar) - main_layout.addStretch() - - buttons_hbox = QHBoxLayout() - buttons_hbox.addStretch() - - close_button = QPushButton("Close", self) - close_button.clicked.connect(self.close) - buttons_hbox.addWidget(close_button) - - apply_button = QPushButton("Apply", self) - apply_button.clicked.connect(self.apply) - buttons_hbox.addWidget(apply_button) - - reload_button = QPushButton("Reload", self) - reload_button.clicked.connect(self.reload) - buttons_hbox.addWidget(reload_button) - - main_layout.addLayout(buttons_hbox) - self.setLayout(main_layout) + self.close_button.clicked.connect(self.close) + self.apply_button.clicked.connect(self.apply) + self.reload_button.clicked.connect(self.reload) def pathsTabLayout(self): - output = QWidget() - output_layout = QFormLayout() - - # Dialog for setting the database file path - db_path_hbox = QHBoxLayout() - self.db_path_edit = QLineEdit() if "paths" in self.config.config: self.db_path_edit.setText(self.config.config["paths"]["db_path"]) - db_path_hbox.addWidget(self.db_path_edit) - db_path_button = QPushButton("...") - db_path_button.setMaximumWidth(25) - db_path_button.clicked.connect(self.dbPathDialog) - db_path_hbox.addWidget(db_path_button) - output_layout.addRow("Database File:", db_path_hbox) - - output.setLayout(output_layout) - return output + self.db_path_button.clicked.connect(self.dbPathDialog) def dbPathDialog(self): file_dialog = QFileDialog(self) diff --git a/src/preferences_dialog.ui b/src/preferences_dialog.ui new file mode 100644 index 0000000..244eb26 --- /dev/null +++ b/src/preferences_dialog.ui @@ -0,0 +1,128 @@ + + + Dialog + + + + 0 + 0 + 500 + 320 + + + + Preferences + + + + + + + + 0 + + + + Paths + + + + + + + + + + + Database File: + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + 25 + 16777215 + + + + ... + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Close + + + + + + + Apply + + + + + + + Reload + + + + + + + + + + + + -- cgit