""" Student Analyzer Application This script initializes and runs the Student Analyzer application, which provides an interface for managing student data, class records, and submissions. It uses the Hello ImGui framework for UI rendering and integrates a database to store and manipulate student information. Modules: - Custom Imports: Imports internal models and application state. - Layouts: Defines different UI layouts for the analyzer and database editor. - External Libraries: Uses imgui_bundle and Hello ImGui for UI rendering. - Built-in Libraries: Uses shelve for persistent state storage and typing for type hints. """ # Custom from model import * # Importing database models like Class, Student, Lecture, and Submission from appstate import AppState, LOG_ERROR # Application state management # Layouts from analyzer import analyzer_layout # Main layout for the analyzer from database import database_editor_layout # Alternative layout for database editing # External from imgui_bundle import imgui, immapp, hello_imgui, ImVec2 # ImGui-based UI framework # Built-in import shelve # Persistent key-value storage from typing import List # Type hinting def menu_bar(runner_params: hello_imgui.RunnerParams) -> None: """Defines the application's menu bar.""" try: hello_imgui.show_app_menu(runner_params) hello_imgui.show_view_menu(runner_params) if imgui.begin_menu("File"): clicked, _ = imgui.menu_item("Open", "", False) if clicked: pass # TODO: Implement file opening logic imgui.end_menu() except Exception as e: LOG_ERROR(f"menu_bar {e}") def status_bar(app_state: AppState) -> None: """Displays the status bar information.""" try: imgui.text("Student Analyzer by @DerGrumpf") except Exception as e: LOG_ERROR(f"status_bar {e}") def main() -> None: """Main function to initialize and run the application.""" app_state = AppState() # Load Database try: with shelve.open("state") as state: v = state.get("DB") # Retrieve stored database connection info if v: db.init(v) db.connect() db.create_tables([Class, Student, Lecture, Submission, Group]) # Ensure tables exist app_state.update() except Exception as e: LOG_ERROR(f"Database Initialization {e}") # Set Window Parameters runner_params = hello_imgui.RunnerParams() runner_params.app_window_params.window_title = "Analyzer" runner_params.imgui_window_params.menu_app_title = "Analyzer" runner_params.app_window_params.window_geometry.size = (1000, 900) runner_params.app_window_params.restore_previous_geometry = True runner_params.app_window_params.borderless = True runner_params.app_window_params.borderless_movable = True runner_params.app_window_params.borderless_resizable = True runner_params.app_window_params.borderless_closable = True # Configure UI Elements runner_params.imgui_window_params.show_menu_bar = True runner_params.imgui_window_params.show_menu_app = False runner_params.imgui_window_params.show_menu_view = False runner_params.imgui_window_params.show_status_bar = True runner_params.callbacks.show_menus = lambda: menu_bar(runner_params) runner_params.callbacks.show_status = lambda: status_bar(app_state) # Application layout runner_params.imgui_window_params.default_imgui_window_type = ( hello_imgui.DefaultImGuiWindowType.provide_full_screen_dock_space ) runner_params.imgui_window_params.enable_viewports = True runner_params.docking_params = analyzer_layout(app_state) runner_params.alternative_docking_layouts = [ database_editor_layout(app_state) ] # Save App Settings runner_params.ini_folder_type = hello_imgui.IniFolderType.app_user_config_folder runner_params.ini_filename = "Analyzer/Analyzer.ini" runner_params.docking_params.layout_condition = hello_imgui.DockingLayoutCondition.application_start # Run the Application add_ons_params = immapp.AddOnsParams() add_ons_params.with_markdown = True add_ons_params.with_implot = True add_ons_params.with_implot3d = True immapp.run(runner_params, add_ons_params) if __name__ == "__main__": main()