This repository has been archived on 2022-12-22. You can view files and clone it, but cannot push or open issues/pull-requests.
Concorde-IDE/gui_handler.py

40 lines
1.7 KiB
Python
Raw Normal View History

from PySide6 import QtWidgets
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()
2022-03-19 05:45:51 +01:00
def __del__(self):
#TODO: whatever needs to be done here
2022-03-19 05:45:51 +01:00
pass
2022-03-19 05:45:51 +01:00
def set_title(self, title):
self.window.setWindowTitle(title)
def get_size(self):
#TODO: implement
util.warn("Not implemented!")
2022-03-19 05:45:51 +01:00
return None
def set_size(self, size_x, size_y):
self.window.resize(size_x, size_y)
2022-03-19 05:45:51 +01:00
def update_menus(self, menu_dict):
#TODO: implement
util.warn("Not implemented!")
#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
# - make a generic wrapper for window mainloop that will always run in the main thread while the actual main control flow of the program gets moved to another thread
# There are some issues with these workarounds though; mainly that QT isn't thread safe.
# I really want to keep QT running in its own thread because I want to retain the ability to arbitrarily spawn and manipulate windows while other windows are running.
# Another issue that is probably easily worked around / fixed is that app.exec() will return once all running windows are closed.
def fixme_window_mainloop_workaround_to_just_get_a_window_started_really_should_not_be_implemented_this_way_for_reasons_stated_in_the_comment_above_the_definition_of_this_function():
app.exec()