Simple events system built into __builtins__

This commit is contained in:
itdominator 2021-10-11 00:34:13 -05:00
parent 6e2f571466
commit e8c189b0bc
4 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,34 @@
import builtins
class Builtins:
# Makeshift "events" type system FIFO
def push_gui_event(event):
gui_events.append(event)
def push_fm_event(event):
fm_events.append(event)
def pop_gui_event():
gui_events.pop(0)
def pop_fm_event():
fm_events.pop(0)
def read_gui_event():
return gui_events[0]
def read_fm_event():
return fm_events[0]
builtins.gui_events = []
builtins.fm_events = []
# NOTE: Just reminding myself we can add to builtins two different ways...
__builtins__.update({"push_gui_event": push_gui_event})
__builtins__.update({"push_fm_event": push_fm_event})
builtins.pop_gui_event = pop_gui_event
builtins.pop_fm_event = pop_fm_event
builtins.read_gui_event = read_gui_event
builtins.read_fm_event = read_fm_event

View File

@ -8,9 +8,10 @@ import inspect
# Application imports
from utils import Settings
from signal_classes import Signals
from __builtins__ import Builtins
class Main:
class Main(Builtins):
def __init__(self, args):
settings = Settings()

View File

@ -42,6 +42,7 @@ class Signals(WindowMixin, PaneMixin):
self.window.show()
self.generate_windows(self.state)
def generate_windows(self, data = None):
if data:
for j, value in enumerate(data):

View File

@ -37,6 +37,9 @@ class TabMixin(WidgetMixin):
notebook.show_all()
notebook.set_current_page(index)
# FIXME: set_tab_reorderable doesn't seem to work...
# notebook.set_tab_reorderable(tab, True)
def close_tab(self, widget, eve):
notebook = widget.get_parent().get_parent()
page = notebook.get_current_page()