Source code for interface.compile

"""
Frontend Compile Page File for AGE-ABM Visual Interface
@Author Meghan Ireland
@Co-Authors Max Hall and Matthew Fleischman

"""

import tkinter as tk
import customtkinter

[docs] class Compile: """Defines widgets and functionality of compile page. """ def __init__(self, ec_app_ui): """Defines the variables and widgets for compile page. """ self.ec_app_ui = ec_app_ui ### Titles ### self.label_compile_title = tk.Label(self.ec_app_ui.title_frame, text="Download Model" , font=self.ec_app_ui.font1,bg=self.ec_app_ui.title_colour , fg=self.ec_app_ui.label_text_colour) ### Labels ### self.label_compile_filename = tk.Label(self.ec_app_ui.page_frame, text="Model File Name:" , font=self.ec_app_ui.font2,bg=self.ec_app_ui.frame_colour , fg=self.ec_app_ui.label_text_colour) ### Entry ### self.entry_compile_filename = customtkinter.CTkEntry(self.ec_app_ui.page_frame , font = self.ec_app_ui.font2, height=self.ec_app_ui.entry_height , width = self.ec_app_ui.entry_width,fg_color = self.ec_app_ui.entry_colour , text_color = self.ec_app_ui.entry_text_colour) ### Buttons ### self.button_compile_generate_model = customtkinter.CTkButton(self.ec_app_ui.page_frame , hover_color=self.ec_app_ui.highlight_colour, text="✔️ Generate Model" , command=self.btn_compile_generate_model, fg_color=self.ec_app_ui.comp_btn_colour , font = self.ec_app_ui.font2, height=self.ec_app_ui.entry_height , width = self.ec_app_ui.entry_width)
[docs] def clear_compile(self): """Clears the visual elements of the page """ self.label_compile_title.grid_forget() self.label_compile_filename.grid_forget() self.entry_compile_filename.grid_forget() self.button_compile_generate_model.grid_forget()
[docs] def compile_tab_btn(self): """Places the visual elements onto the page """ self.ec_app_ui.clear_all() self.label_compile_title.grid(row = 0, column = 0) self.entry_compile_filename.delete(0,'end') self.label_compile_filename.grid(row = 0, column = 0,padx = 150,pady = 5,sticky="W") self.entry_compile_filename.grid(row = 0, column = 1,pady = 5) self.button_compile_generate_model.grid(row = 1, column = 1,pady = 5)
[docs] def btn_compile_generate_model(self): """Creates the model with the given name """ filename = self.entry_compile_filename.get() if filename[(len(filename))-3:] == ".py": self.ec_app_ui.new_model.create_model(filename) else: self.ec_app_ui.new_model.create_model(filename+".py") self.button_compile_generate_model.grid_forget()