grapher/view.py

66 lines
1.5 KiB
Python
Raw Permalink Normal View History

2025-01-09 22:33:04 +01:00
from imgui_bundle import imgui, ImVec2
2025-01-05 01:01:39 +01:00
from datatypes import *
from main_menu import MainMenu
2025-01-09 22:33:04 +01:00
from database_editor import DatabaseEditor
2025-01-05 01:01:39 +01:00
2025-01-09 22:33:04 +01:00
from student_info import StudentInfo
2025-01-05 01:01:39 +01:00
def set_layout(size: tuple, pos: tuple) -> None:
io = imgui.get_io()
2025-01-09 22:33:04 +01:00
size = imgui.ImVec2(*size)
pos = imgui.ImVec2(*pos)
imgui.set_next_window_size(size)
imgui.set_next_window_pos(pos)
2025-01-05 01:01:39 +01:00
class GrapherLayout:
def __init__(self):
super().__init__()
2025-01-09 22:33:04 +01:00
self.student_info = StudentInfo()
def set_layout(self):
pass
2025-01-05 01:01:39 +01:00
def __call__(self):
2025-01-09 22:33:04 +01:00
self.student_info()
2025-01-08 11:38:31 +01:00
2025-01-05 01:01:39 +01:00
class EditorLayout:
def __init__(self):
super().__init__()
2025-01-09 22:33:04 +01:00
self.database_editor = DatabaseEditor()
2025-01-05 01:01:39 +01:00
2025-01-09 22:33:04 +01:00
def set_layout(self):
pass
2025-01-05 01:01:39 +01:00
2025-01-09 22:33:04 +01:00
def __call__(self):
self.database_editor()
2025-01-05 01:01:39 +01:00
class View:
def __init__(self):
super().__init__()
self.current = LayoutOptions.GRAPHER
self.main_menu = MainMenu()
self.editor = EditorLayout()
self.grapher = GrapherLayout()
2025-01-09 22:33:04 +01:00
def switch_context(self, ctx: LayoutOptions) -> None:
match ctx:
case LayoutOptions.EDITOR:
self.editor.set_layout()
case LayoutOptions.GRAPHER:
self.grapher.set_layout()
2025-01-05 01:01:39 +01:00
def __call__(self):
option = self.main_menu()
if option:
self.current = option
if self.current == LayoutOptions.EDITOR:
self.editor()
if self.current == LayoutOptions.GRAPHER:
self.grapher()