import tkinter as tk import tkinter.ttk as ttk from tkinter import StringVar, simpledialog, messagebox from gui.widgets.glFrame import AppOgl from typing import List from functools import partial from gui.framsutils.FramsInterface import TreeNode, InterfaceType from gui.widgets.mainTreeView import TreeView from gui.widgets.listGenePoolWindow import ListGenePoolWindow from gui.widgets.listPopulationsWindow import ListPopulationsWindow from gui.widgets.dialogBox import DirectoryDialgoBox, FileOpenDialogBox, FileSaveDialogBox from gui.widgets.ConsoleWindow import ConsoleWindow from gui.widgets.importWindow import ImportWindow from gui.widgets.propertyWindow import PropertyWindow from gui.libInterface import LibInterface from gui.socketInterface import SocketInterface from gui.utils import debounce from gui.utils import windowHideAndMaximize, windowShowAndSetGeometry from gui.widgets.ToolTip import CreateToolTip from time import perf_counter class MainPage(tk.Tk): OPENGL_WIDTH = 720 OPENGL_HEIGHT = 480 SIDEBAR_WIDTH = 400 CONTROL_HEIGHT = 50 OPTIONS_WIDTH = 100 STATUSBAR_HEIGHT = 20 OFFSET_HEIGHT = 60 OPENGL_ANIMATE_DELAY = 1 MENU_CONNECT_TO_SERVER = "Connect to server" MENU_CONNECT_TO_LIB = "Connect to library" WORKAROUND_TKINTER_FREEZE_BUG = True # There is a bug in tkinter that freezes whole app when dialogs are called too fast, hint: https://stackoverflow.com/questions/40666956/tkinter-hangs-on-rapidly-repeated-dialog refresh_rate_dict = {"0.1s": 100, "0.2s": 200, "0.5s": 500, "1s": 1000, "2s": 2000, "5s": 5000, "10s": 10000} #paths which can reload world and tree reload_path = ["/Experiment", "/Advanced scripting", "/World", "/User scripts"] def __init__(self, parent, networkAddress: str = None, libPath: str = None): super().__init__(parent) self.parent = parent self.protocol("WM_DELETE_WINDOW", self._dismiss) self.title("Framsticks GUI for library/server") self.option_add('*tearOff', tk.FALSE) self.listRefreshRate = 1000 self.frams = None self.canStep = False #disable step while drawing #OPENGL FRAME self.frame_opengl = AppOgl(self, width=self.OPENGL_WIDTH, height=self.OPENGL_HEIGHT) self.frame_opengl.animate = self.OPENGL_ANIMATE_DELAY self.frame_opengl.bind("", self.frame_opengl.onResize) self.frame_opengl.bind("", self.frame_opengl.onMouseMotion) self.frame_opengl.bind("", self.frame_opengl.onScroll) self.frame_opengl.bind("