added menus

master
Milan Suman 2022-03-19 18:35:10 +05:30
parent 93828490db
commit 74b554015c
2 changed files with 34 additions and 10 deletions

View File

@ -3,19 +3,19 @@ import util
app = QtWidgets.QApplication([]) app = QtWidgets.QApplication([])
class Window: class Window(QtWidgets.QMainWindow):
def __init__(self, title="Concorde", size_x=640, size_y=480): def __init__(self, size=(640, 480), title="Concorde"):
self.window = QtWidgets.QWidget() super().__init__()
self.window.setWindowTitle(title) self.setWindowTitle(title)
self.window.resize(size_x, size_y) self.resize(size[0], size[1])
self.window.show() self.show()
def __del__(self): def __del__(self):
#TODO: whatever needs to be done here #TODO: whatever needs to be done here
pass pass
def set_title(self, title): def set_title(self, title):
self.window.setWindowTitle(title) self.setWindowTitle(title)
def get_size(self): def get_size(self):
#TODO: implement #TODO: implement
@ -23,11 +23,28 @@ class Window:
return None return None
def set_size(self, size_x, size_y): 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): def update_menus(self, menu_dict):
#TODO: implement menu = self.menuBar()
util.warn("Not implemented!") #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: #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 # - create the QtWidgets.QApplication inside a thread and run all QT stuff inside that thread

View File

@ -26,11 +26,18 @@ configuration = Config(configuration_file_path, default_configuration)
# PROGRAM MAIN WINDOW # PROGRAM MAIN WINDOW
################################################################################ ################################################################################
# It seems like opening multiple instances already works as intended
main_window = gui_handler.Window() main_window = gui_handler.Window()
main_window2 = gui_handler.Window()
main_window.set_title("Concorde IDE") 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_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_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: 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 #TODO: check if the GUI encountered an error in a toolkit agnostic way