diff --git a/gui_handler.py b/gui_handler.py index 25ee200..9e119a9 100644 --- a/gui_handler.py +++ b/gui_handler.py @@ -3,19 +3,19 @@ import util app = QtWidgets.QApplication([]) -class Window: - def __init__(self, title="Concorde", size_x=640, size_y=480): - self.window = QtWidgets.QWidget() - self.window.setWindowTitle(title) - self.window.resize(size_x, size_y) - self.window.show() +class Window(QtWidgets.QMainWindow): + def __init__(self, size=(640, 480), title="Concorde"): + super().__init__() + self.setWindowTitle(title) + self.resize(size[0], size[1]) + self.show() def __del__(self): #TODO: whatever needs to be done here pass def set_title(self, title): - self.window.setWindowTitle(title) + self.setWindowTitle(title) def get_size(self): #TODO: implement @@ -23,11 +23,28 @@ class Window: return None def set_size(self, size_x, size_y): - self.window.resize(size_x, size_y) + self.resize(size_x, size_y) def update_menus(self, menu_dict): - #TODO: implement - util.warn("Not implemented!") + menu = self.menuBar() + #Looping through entire menu_dict + for topmenu, submenu in menu_dict.items(): + #making top level menu + menu_item = menu.addMenu(topmenu) + + #adding menu items (populating menu) + for inner, data in submenu.items(): + #Adding submenu and populating it + if type(data) == dict: + sub = menu_item.addMenu(inner) + for label, func in data.items(): + sub.addAction(label) + #Adding separators + elif inner == None: + menu_item.addSeparator() + else: + menu_item.addAction(inner) + #TODO: This needs to run in a thread but Qt really doesn't want it to. There are two ways around this: # - create the QtWidgets.QApplication inside a thread and run all QT stuff inside that thread diff --git a/main.py b/main.py index 0d7ba07..70f34a2 100644 --- a/main.py +++ b/main.py @@ -26,11 +26,18 @@ configuration = Config(configuration_file_path, default_configuration) # PROGRAM MAIN WINDOW ################################################################################ +# It seems like opening multiple instances already works as intended + main_window = gui_handler.Window() +main_window2 = gui_handler.Window() main_window.set_title("Concorde IDE") +main_window2.set_title("Another window") main_window.set_size(configuration.get_configuration_value("window size")["x"], configuration.get_configuration_value("window size")["y"]) +main_window2.set_size(400, 500) main_window.update_menus(gui_helper.menu_structure) +main_window2.update_menus(gui_helper.menu_structure) + #TODO: get resolution of main window on exit and save it back to the configuration #TODO: check if the GUI encountered an error in a toolkit agnostic way