-
Notifications
You must be signed in to change notification settings - Fork 0
MeMa Page Framework
MeMa's interface stucture is optimized around ease of expansion and ease of modification. Each page is it's own sub-class of the content frame superclass in codebank/mema_content_frame.py, and should be created in it's own file, similar to the State Design Pattern, however instead of states, MeMa uses pages. This might bring the question ...
In MeMa, a page is a frame that displays content to the user. In order to maintain integrity with expansion, the MeMa Page Framework doesn't facilitate direct input through the page, as this can become inaccessible if there isn't a direct physical button mapping.
So, this in turn will beg the question: How can I manage inputs? Well, in the framework, inputs are handled through a simplecallbackfunction that will get called when a button gets pressed, the user says something or the dial is rotated on the machine. These are passed to thepagethroughjson-styledictionaries, representing what was done, and through what means.
The MeMa Page Framework has several notable advantages over direct application design, One of these is that the process of updating the buttons has been abstracted to a single function where you pass the new button names, callbacks and a boolean representing whether or not to read the new buttons aloud to the user.
The Framework still facilitates and caters for all Tkinter widgets, meaning that you can still access direct widget creation, modification and deletion. Alongside this, it helps maintain individual responsibility between pages, and ease of transition between pages. In short, the page framework should make it fast and easy to expand on and add to the MeMa System.
MeMa Pages are created and hosted within the
main_windowclass, which essentially acts as an interface between theio_handlerand the currentpage. Themain_windowis also responsible for switching between pages and controlling thebutton_frameand requests to thebutton_framefrom the currentpage.
This is code:
class content_new_user(content_frame):
def __init__(self, parent, *args, **kwargs)-> None:
# Calling the Superclass Constructor
content_frame.__init__(self, *args, **kwargs)
# Setting the parent of the Frame
self.parent = parent
def setup_gui(self) -> None:
# Create GUI elements here, since content_frame inherits directly
# from tk.Frame, we can set widget masters to self. e.g.
#
# label = Label(self, text = "Example")
# label.pack()
def callback(self, callback_request: dict[str:str]) -> None:
# Handle callback requests here
pass