From e8c189b0bcc137146070e8985b2a42bbafebb490 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Mon, 11 Oct 2021 00:34:13 -0500 Subject: [PATCH] Simple events system built into __builtins__ --- .../pyfm-0.0.1/PyFM/new/pyfm/__builtins__.py | 34 +++++++++++++++++++ .../pyfm-0.0.1/PyFM/new/pyfm/__init__.py | 3 +- .../PyFM/new/pyfm/signal_classes/Signals.py | 1 + .../pyfm/signal_classes/mixins/TabMixin.py | 3 ++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/versions/pyfm-0.0.1/PyFM/new/pyfm/__builtins__.py diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/__builtins__.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/__builtins__.py new file mode 100644 index 0000000..28f66d3 --- /dev/null +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/__builtins__.py @@ -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 diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/__init__.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/__init__.py index 5f81b40..d4c65f3 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/__init__.py +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/__init__.py @@ -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() diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/Signals.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/Signals.py index 323d1b7..05621e3 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/Signals.py +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/Signals.py @@ -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): diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/TabMixin.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/TabMixin.py index b00d450..1352665 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/TabMixin.py +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/TabMixin.py @@ -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()