grapher/student_editor.py

42 lines
1.4 KiB
Python

from model import *
from imgui_bundle import imgui
class StudentEditor:
def __init__(self):
super().__init__()
self.prename = str()
self.surname = str()
self.sex = True
self.current = 0
def __call__(self):
with imgui.begin("Student Editor", False, imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_COLLAPSE):
imgui.text("Add Student")
_, self.prename = imgui.input_text("First Name", self.prename)
_, self.surname = imgui.input_text("Last Name", self.surname)
with imgui.begin_group():
if imgui.radio_button("Male", self.sex):
self.sex = True
imgui.same_line()
if imgui.radio_button("Female", not self.sex):
self.sex = False
classes = Class.select()
if classes:
_, self.current = imgui.combo("Classes", self.current, [c.name for c in classes])
if imgui.button("Confirm") and classes:
Student.create(
prename=self.prename,
surname=self.surname,
sex='Male' if self.sex else 'Female',
class_id = classes[self.current]
)
self.prename = str()
self.surname = str()