def windowInit(): sg.theme('LightBrown1') # sg.theme('HotDogStand') # funny theme # Use Tkinter Agg use_agg('TkAgg') # Layout Definition # cube_layout = # allCubeRows = [[sg.Slider((1,10), key=f"slider_x{i}") for i in range(1,6)]] # first column of a layout function_definition_column = [ [ # FUNCTION sg.Frame( layout=[ [ sg. T("Podaj wzór funkcji wykorzystując następujące zmienne w podanej kolejności:\nx1, x2, x3, x4, x5." ) ], [ sg.Text(f"f({CHAR_XVEC})="), sg.In(size=(30, 1), key="-FUNCTION-"), sg.Checkbox('Zatwierdź funkcję', size=(15, 1), key='-CONFIRM_FUNCTION-', default=False, enable_events=True), sg.B("Test function", key="-TEST_FUNCTION-"), ], ], title='Funkcja', key='function_frame', relief=sg.RELIEF_GROOVE, # GROOVE is normal, nice looking ) ], [ ### CUBE & RESTRICTIONS sg.Frame( layout=[ [ sg.Checkbox('Zatwierdź kostkę', size=(15, 1), key='-CONFIRM_CUBE-', default=False, enable_events=True), ], *[ [ sg.T(f'x{i}: ', key=f'tXNo{i}', font=('Arial', 10, 'bold')), sg.Input( key=f'iMin{i}', size=(5, 1), default_text="-10", tooltip=f'Minimalna wartość zmiennej x{i}'), sg.T(f'{CHAR_LOE} x{i} {CHAR_LOE}', key=f'cubeTextRange_{i}'), sg.Input( key=f'iMax{i}', size=(5, 1), default_text="10", tooltip=f'Maksymalna wartość zmiennej x{i}'), # sg.VSeperator(key=f'vSep_x{i}'), sg. T(f'rozdzielczość x{i}:', key=f'tCubeRng{i}', tooltip= f'Suwakiem ustal generowaną liczbę punktów dla zmiennej x{i}' ), sg.Slider( range=(10, 200), default_value=70, size=(18, 8), orientation='horizontal', font=('Helvetica', 10), tooltip= f'Suwakiem ustal generowaną liczbę punktów dla zmiennej x{i}', key=f'sRes{i}') # sg.CB(f'Zatwierdź ograniczenie x{i}') ] for i in range(1, 6) ], ], title='Kostka', # tooltip = 'Użyj tego pola do ograniczenia zmiennych xi', # relief = sg.RELIEF_SUNKEN ), sg.Frame(layout=[ [ sg.Checkbox('Zatwierdź ograniczenia', size=(20, 1), key='-CONFIRM_RESTRICTIONS-', default=False, enable_events=True), ], *[[ sg.T(f'g{i}({CHAR_XVEC}): '), sg.In(size=(25, 1), key=f"-REST{i}-"), sg.T(f'{CHAR_LOE} 0'), sg.Checkbox('Zatwierdź', key=f'-CONFIRM_REST{i}-', enable_events=True) ] for i in range(1, 6)], ], title='Ograniczenia', tooltip='Użyj tego pola do wprowadzenia ograniczeń', relief=sg.RELIEF_GROOVE), # sg.Frame( # layout=[ # [ # sg.Checkbox('Zatwierdź ograniczenia', size=( # 20, 1), key='-CONFIRM_RESTRICTIONS-', default=False, enable_events=True), # ], # [sg.Listbox(key='lbRest',values=[]),sg.T(f'{CHAR_LOE} 0')], # [sg.In(key='-REST-', size=(30,40)),sg.T(f'{CHAR_LOE} 0')], # [sg.B("Dodaj",key="-addRest-"), sg.B("Usuń",key="-rmRest-")] # ], # title='Ograniczenia', # tooltip='Użyj tego pola do wprowadzenia ograniczeń', # relief=sg.RELIEF_GROOVE # ), ], [sg.Button("Rysuj funkcję", key="-GENERATE-")], [sg.Button("GenerujMockData", key="-GENERATE_MOCK-")], [sg.Output(size=(120, 15), key=keyOfLoggerWindow)], [ # SIMULATION sg.Frame( layout=[ [ sg.In(size=(8, 1), key="mu", default_text="20"), sg.T('<- mu', tooltip='liczba rodziców'), ], [ sg.In(size=(8, 1), key="lambda", default_text="40"), sg.T('<- lambda', tooltip='liczba potomstwa'), ], [ sg.In(size=(8, 1), key="sigma", default_text="0.15"), sg.T('<- sigma', tooltip='parametr mutowalności'), ], [ sg.In(size=(8, 1), key="noEpoch", default_text="5"), sg.T('<- N', tooltip='liczba epok'), ], [ sg.B("Rozpocznij symulację", key="-RUN_SIMULATION-"), ], ], title='Symulacja', key='simulation_frame', relief=sg.RELIEF_GROOVE, # GROOVE is normal, nice looking ) ], ] # second column of layout graph_viewer_column = [ [ sg.T(f"f({CHAR_XVEC})="), sg.I("<Wykres funkcji zostanie umieszczony tutaj>", disabled=True, size=(80, 1), key="function_title") ], [sg.T('Controls1:')], [sg.Canvas(key='-FIGURE_CONTROLS1-')], [sg.T('Figure1:')], [ sg.Column( layout=[[ sg.Canvas( key='-FIGURE1-', # it's important that you set this size size=(600, 300)) ]], background_color='#DAE0E6', pad=(0, 0)) ], [sg.T('Controls2:')], [sg.Canvas(key='-FIGURE_CONTROLS2-')], [sg.T('Figure2:')], [ sg.Column( layout=[[ sg.Canvas( key='-FIGURE2-', # it's important that you set this size size=(600, 300)) ]], background_color='#FFFFFF', pad=(0, 0)) ], ] # Full layout layout = [[ sg.Column(function_definition_column), sg.VSeperator(), sg.Column(graph_viewer_column), ]] # Window definition window = sg.Window( 'Wizualizacja strategii ewolucyjnych', layout, # default_element_size=(30, 2), # font=('Helvetica', ' 10'), # default_button_element_size=(8, 2), finalize=True, # no_titlebar=True, location=(0, 0), # size=(1024, 1080), size=(1920, 1080), resizable=True, # keep_on_top=True, ) # Hide some elements @ start # disable confirming Cube, Restrictions & Generate widgetsToDeactivateAtStart = [ '-CONFIRM_CUBE-', '-CONFIRM_RESTRICTIONS-', '-GENERATE-' ] for widget_label in widgetsToDeactivateAtStart: window.FindElement(widget_label).Update(disabled=True) # disable rows of Cube for i in range(1, 6): # 1, 2, 3, 4, 5 disableCubeRow(i, window) return window
import time import PySimpleGUI as sg import matplotlib.pyplot as plt from matplotlib import use as use_agg from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg import numpy as np import ctypes from ctypes import * from numpy.ctypeslib import ndpointer # Use Tkinter Agg use_agg("TkAgg") functions = { "64x^2 + 126xy + 64y^2 - 10x + 30y + 13": { "func": lambda x, y: 64 * x * x + 126 * x * y + 64 * y**2 - 10 * x + 30 * y + 13, "c_func_num": 1, }, "x^2 + y^2 - 2x + 5y": { "func": lambda x, y: x * x + y * y - 2 * x + 5 * y, "c_func_num": 2, }, "25x^2 - 6xy + y^2 - 20x + 300y + 1": { "func":
import PySimpleGUI as sg import pandas as pd import numpy as np from matplotlib import use as use_agg import matplotlib.pyplot as plt from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg import time from stareg import Stareg FONT = "Helvetica 14" CONSTR = ('inc', 'dec', 'peak', 'valley', 'conc', 'conv', 'none') # Use Tkinter Agg use_agg('TkAgg') def load_data(): # Button to browse for the data file sg.set_options(auto_size_buttons=True) layout = [[ sg.Text('Dataset (a CSV file)', size=(16, 1)), sg.InputText(), sg.FileBrowse(file_types=(("CSV Files", "*.csv"), ("Text Files", "*.txt"))) ], [sg.Submit(), sg.Cancel()]] window1 = sg.Window('Input file', layout) try: event, values = window1.read() except Exception: