Compare commits

..

No commits in common. "8c4f0a02bcabfc1c71566ff093115c293eeca529" and "bcd9d00a47c746f302c96ed9c6cdc75b84dbe5f7" have entirely different histories.

2 changed files with 9 additions and 16 deletions

View File

@ -28,8 +28,15 @@ configuration = Config(configuration_file_path, default_configuration)
# It seems like opening multiple instances already works as intended
main_window = gui_handler.Window(title="Concorde IDE", size=(configuration.get_configuration_value("window size")["x"], configuration.get_configuration_value("window size")["y"]))
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

16
util.py
View File

@ -1,4 +1,4 @@
import sys, traceback, threading
import sys, traceback
EXIT_SUCCESS=0
EXIT_ERROR=1
@ -30,12 +30,10 @@ def error(message, is_exception=True, handle_gracefully=True):
#TODO: make thread safe
class Communication:
def __init__(self):
self.lock = threading.Lock()
self.__messages = {}
# send a message tagged with name and containing content, adds to the beginning of the list of messages with the same tag by default, a function to run as an additional action can be provided
def send(self, name, content, reverse_order=True, additional_action=None):
self.lock.acquire()
if name in self.__messages:
if reverse_order:
self.__messages[name] = [content] + self.__messages[name]
@ -47,44 +45,32 @@ class Communication:
pass
else:
additional_action()
self.lock.release()
# get the content of the first message tagged with name, removes the returned message by default
def get(self, name, remove=True):
self.lock.acquire()
if name in self.__messages and len(self.__messages[name])>0:
if remove:
content = self.__messages[name].pop(0)
if len(self.__messages[name])==0:
del self.__messages[name]
self.lock.release()
return content
else:
self.lock.release()
return self.__messages[name][0]
else:
self.lock.release()
return None
# get the contents for all messages tagged with name
def get_all(self, name, clear=False):
self.lock.acquire()
if name in self.__messages and len(self.__messages[name])>0:
contents = self.__messages[name]
if clear:
del self.__messages[name]
self.lock.release()
return contents
else:
self.lock.release()
return None
# deletes all messages tagged with name
def clear(self, name):
self.lock.acquire()
if name in self.__messages:
del self.__messages[name]
self.lock.release()
def __del__(self):
if len(self.__messages)>0: