def process_window(window: sg.Window): """ Processes events, button clicks, for a detailed window :param window: The PySimpleGUI Window to work with :return: event: The button clicked or None if exited """ event, values = window.Read( timeout=0) # Read without waiting for button clicks if event in (None, 'Close'): window.Close() return None elif event == 'Action 1': window.Element('_ACTION_RESULT_').Update('Action 1 result = ' + str(randint(0, 1000))) elif event == 'Action 2': window.Element('_ACTION_RESULT_').Update('Action 2 result = ' + str(randint(-1000, 0))) # show dummy stats so can see window is live and operational window.Element('_INPUT_BYTES_').Update(randint(0, 40000)) window.Element('_OUTPUT_BYTES_').Update(randint(0, 40000)) return event # return the button clicked
def run(self, window: Window, fields: list) -> map: """ This method control the logic of load records selection window Args: window: the window contains the table fields: the fields that need to be get Returns: a map that contains selected record data """ "" info = window.Element('_OR_TABLE_').get()[self.values["_OR_TABLE_"][0]] window.close() i = 0 for each in fields: self.record[each] = info[i] i += 1 return self.record
], [ Slider(range=(37, 32767), orientation='h', default_value=10000, key="Beep", tooltip="Current frequency") ], [ Button("-", key="Lower", tooltip="Lower frequency", size=(1, 1)), Button("+", key="Raise", tooltip="Raise frequency", size=(1, 1)) ]] layout = [[Column(col1)]] window = Window("Beep!").Layout(layout).Finalize() window.Size = (310, 140) while True: event, values = window.Read(timeout=10) if not event or event == "Quit": break elif event == "Raise": window.Element("Beep").Update(values["Beep"] + int(values["Step"])) elif event == "Lower": window.Element("Beep").Update(values["Beep"] - int(values["Step"])) elif event == "Beep!": print(values) Beep(int(values["Beep"]), int(values["Time"]))
Tab('Model selection', tab3_layout, tooltip= 'Here you can decide which ML model to use for the prediction') ]]) ]] # Create the Window window = Window('MoralStrength GUI', layout) # Event Loop to process "events" while True: event, values = window.Read() if event in (None, 'Cancel'): break if event == 'Analyze text': # getModel(values) if "inputtext" in values and not values["inputtext"].isspace(): analyzeText(values["inputtext"]) else: window.Element('inputtext').Update( "Write or paste some text first!") if event == "Analyze file(s)": getModel(values) #ugh... why is the target= of the open file not working? I don't know if 'text' in window.Element('files').TKText.keys( ) and not window.Element('files').TKText['text'].isspace(): processFiles(window.Element('files').TKText['text']) else: window.Element('files').Update("Select one (or more) files first!") window.Close()