grapher/gui.py

48 lines
1.5 KiB
Python
Raw Normal View History

2025-01-09 22:33:04 +01:00
from imgui_bundle import imgui, immapp
2025-01-05 01:01:39 +01:00
import glfw
import OpenGL.GL as gl
from datatypes import *
from view import View
class GUI(object):
def __init__(self):
super().__init__()
2025-01-09 22:33:04 +01:00
# self.io = imgui.get_io()
2025-01-05 01:01:39 +01:00
# Global GUI Setting
2025-01-09 22:33:04 +01:00
'''win_w, win_h = glfw.get_window_size(self.window)
2025-01-05 01:01:39 +01:00
fb_w, fb_h = glfw.get_framebuffer_size(self.window)
font_scaling_factor = max(float(fb_w) / win_w, float(fb_h) / win_h)
font_size_in_pixels = 30
self.io.fonts.add_font_from_file_ttf("assets/MPLUSRounded1c-Regular.ttf", font_size_in_pixels * font_scaling_factor)
2025-01-09 22:33:04 +01:00
self.io.font_global_scale /= font_scaling_factor'''
2025-01-05 01:01:39 +01:00
self.view = View()
def header(self):
imgui.set_next_window_size(io.display_size.x, io.display_size.y*0.03)
imgui.set_next_window_position(0, io.display_size.y*0.02)
with imgui.begin("HEADER", False, imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_COLLAPSE | imgui.WINDOW_NO_TITLE_BAR):
imgui.set_window_font_scale(1.3)
text = "Student Analyzer"
ww = imgui.get_window_size().x
tw = imgui.calc_text_size(text).x
imgui.set_cursor_pos_x((ww - tw) * 0.5)
imgui.text("Student Analyzer")
2025-01-09 22:33:04 +01:00
def __call__(self):
2025-01-05 01:01:39 +01:00
self.view()
if __name__ == "__main__":
2025-01-09 22:33:04 +01:00
immapp.run(
gui_function=GUI(),
window_title="Student Analyzer",
window_size_auto=True,
with_implot=True,
with_markdown=True
)