def save_graph(): ''' ''' requestdata = request.get_json() # print(requestdata) print('handling POST on save!') global data # graphdata = requestdata[0] # app.bg = bg = lcg.viz.from_visjs(graphdata) w = sg.Window('Save graph').Layout([[sg.Text('Filename')], [sg.Input(), sg.FileSaveAs()], [sg.OK(), sg.Cancel()]]) event, values = w.Read() w.Close() if event == 'OK': dest = Path(values[0]) bgmat = to_matrix_str(app.bg) with dest.open('w') as f: f.write(bgmat) if len(app.mcg) <= 128: mcgmat = to_matrix_str(app.mcg) f.write(mcgmat) response = app.response_class(status=200, mimetype='application/json', response=json.dumps({'status': 'OK'})) return response return None
def make_win1(): layout = [[ sg.Text("Datei: "), sg.Input(key="-INPUTFILE-", enable_events=True, change_submits=True), sg.FileBrowse(key="-IN-", target="-INPUTFILE-", file_types=(("Etherpad Files", "*.etherpad"), ), initial_folder='') ], [sg.Text('Verlauf:', visible=False, key="-txt-")], [sg.Multiline(key='-out-', size=(80, 20), visible=False)], [ place( sg.InputText(key='-save-', do_not_clear=False, enable_events=True, visible=False)), place( sg.FileSaveAs(target="-save-", initial_folder='', file_types=(('Text', '.txt'), ('CSV', '.csv')))), place(sg.Button("Exit")) ]] return sg.Window('Etherpadparser', layout, location=(100, 100), finalize=True)
def ask_for_filename(default_filename='', initial_folder=None, size=None): if initial_folder is None: initial_folder = os.getcwd() save_layout = [[ sg.InputText(key='-FILETOSAVE-', default_text=default_filename, enable_events=True, justification='l'), sg.InputText(key='-SAVEAS-', do_not_clear=False, enable_events=True, visible=False, ), sg.FileSaveAs('Select', initial_folder=initial_folder, file_types=(("PNG", "*.png"),))], [sg.Button('OK', bind_return_key=True), sg.Button('Cancel')] ] save_window = sg.Window('Save image', save_layout, keep_on_top=True, modal=True) while True: event, values = save_window.Read() if event is None or event == 'Cancel': save_window.close() return None elif event == '-SAVEAS-': filename = values['-SAVEAS-'] if filename: save_window['-FILETOSAVE-'].update(value=filename) elif event == "OK": save_window.close() return values['-FILETOSAVE-']
def save_model(model): # Button to save the trained model sg.set_options(auto_size_buttons=True) layout = [[ sg.InputText(key='-FILE_TO_SAVE-', default_text='**.pkl', enable_events=True), sg.InputText(key="-SAVE_AS-", do_not_clear=False, enable_events=True, visible=False), sg.FileSaveAs(initial_folder='/tmp') ]] window_save = sg.Window("Save", layout) while True: event, values = window_save.Read() print("event: ", event, "values: ", values) if event in (sg.WIN_CLOSED, "Exit"): break elif event == "-SAVE_AS-": fname = values["-SAVE_AS-"] if fname: window_save["-FILE_TO_SAVE-"].update(value=fname) pd.to_pickle(model, fname) window_save.close()
def Merge(): return [ [sg.Image('img/merge.jpg', size=(500,200 ))], [sg.Text('Select PDFs')], [sg .Input(key="input"), sg.FilesBrowse()], [sg.Text('Save')], [sg .Input(key="output"), sg.FileSaveAs(file_types=(("Pdf", "*.pdf"),))], [sg.Ok()] ]
def Word2PDF(): return [ [sg.Image('img/word-to-pdf.png', size=(500,200 ))], [sg.Text('Select Folder')], [sg.Input(key="from"), sg.FilesBrowse(file_types=(("Word", "*.docx"),))], [sg.Text('Save')], [sg.Input(key="to"), sg.FileSaveAs(file_types=(("Pdf", "*.pdf"),))], [sg.Ok()] ]
def CheckboxFileSaveAs(text, key, default_text, default_folder): keychkbox = f"-{key.upper()}_CHKBOX-" key = f"-{key.upper()}-" text = text + ':' return [ sg.Checkbox(text, default=False, key=keychkbox), sg.Input(key=key, default_text=default_text), sg.FileSaveAs(initial_folder=default_folder, target=key) ]
def Image2PDF(): return [ [sg.Image('img/image-to-pdf.jpg', size=(500,200))], [sg.Text('Select images')], [sg .Input(key="input"), sg.FilesBrowse(file_types=(("JPEG", "*.jpg"),))], [sg.Text('Save')], [sg .Input(key="output"), sg.FileSaveAs(file_types=(("Pdf", "*.pdf"),))], [sg.Ok()] ]
def getInputOutputWindow(titletext="Select File"): layout = [[sg.Text('Input File')], [sg.Input(), sg.FileBrowse(initial_folder=home)], [sg.Text('Output File')], [sg.Input(), sg.FileSaveAs(initial_folder=home)], [sg.OK(), sg.Cancel()]] window = sg.Window(titletext, layout) event, values = window.Read() return event, values
def getOutputWindow(titletext: str = "Output File", prefill: str = ""): layout = [[sg.Text("Where should it be saved?")], [ sg.Text("Save under:"), sg.Input(), sg.FileSaveAs(initial_folder=prefill) ], [sg.OK(), sg.Cancel()]] window = sg.Window(titletext, layout) event, values = window.Read() window.Close() return event, values
def create_row(label, key, file_types, save=False): if save: return [ sg.Text(label), sg.Input(size=(25, 1), key=key), sg.FileSaveAs(file_types=file_types) ] return [ sg.Text(label), sg.Input(size=(25, 1), key=key), sg.FileBrowse(file_types=file_types), ]
def analysis(data): ''' Run quick analysis on the system. ''' data.update() layout = [ [sg.Multiline("Top 10 Processes\n"+data.get_top_processes(10), \ size=(200, 12), key="_top_processes")], [sg.Multiline("Top 10 Paths\n"+data.get_top_paths(10), \ size=(200, 12), key="_top_paths")], [sg.Multiline("Top 10 Extensions\n"+data.get_top_extensions(10), \ size=(200, 12), key="_top_extensions")], [sg.Multiline("Top 10 Folders\n"+data.get_top_folders(10), \ size=(200, 12), key="_top_folders")], [sg.Multiline("Top 10 Exclusions Hit\n"+data.get_top_exclusions(10), \ size=(200, 12), key="_top_exclusions")], [ sg.FileSaveAs("Save As", button_color=('black', '#F0F0F0'), \ file_types=(("Log File", "*.log"),)), sg.Button("Cancel", button_color=('black', '#F0F0F0')), ] ] window = sg.Window("Analysis", layout, location=(1, 1)) to_save = "" while True: event, values = window.Read(timeout=3000) if event in (None, "Cancel"): break data.update() window.Element("_top_processes").Update("Top 10 Processes\n" + data.get_top_processes(10)) window.Element("_top_paths").Update("Top 10 Paths\n" + data.get_top_paths(10)) window.Element("_top_extensions").Update("Top 10 Extensions\n" + data.get_top_extensions(10)) window.Element("_top_folders").Update("Top 10 Folders\n" + data.get_top_folders(10)) window.Element("_top_exclusions").Update("Top 10 Exclusions Hit\n" + data.get_top_exclusions(10)) window.Refresh() if values.get("Save As") != to_save: to_save = "Top 10 Processes\n{}\n\n".format( data.get_top_processes(10)) to_save += "Top 10 Paths\n{}\n\n".format(data.get_top_paths(10)) to_save += "Top 10 Extensions\n{}\n\n".format( data.get_top_extensions(10)) to_save += "Top 10 Folders\n{}".format(data.get_top_folders(10)) to_save += "Top 10 Exclusions Hit\n{}".format( data.get_top_exclusions(10)) with open(values.get("Save As"), "w") as f: f.write(to_save) window.close()
def exportModal(self, rec): defaultType = 'txt' types = { 'txt': ('Text Files', '*.txt'), 'pdf': ('PDF Files', '*.pdf'), 'json': ('JSON Files', '*.json'), 'yaml': ('YAML Files', '*.yaml') } recTitle = rec.title.replace(' ', '-') defaultSave = self.model.get( 'prefs', 'recipeFolder') + recTitle + f'.{defaultType}' layout = [[sg.Text('Export Details')], [ sg.T('Destination'), sg.In(default_text=defaultSave, key='-EXPORT-FOLDER-'), sg.FileSaveAs('Browse', initial_folder=self.model.get( 'prefs', 'recipeFolder')) ], [ sg.T('Format'), sg.Combo(default_value=defaultType, values=['txt', 'pdf', 'yaml', 'json'], size=(20, 12), key='-FORMAT-LIST-', enable_events=True) ], [sg.Button('Export'), sg.Button('Cancel')]] window = sg.Window('Export Details', layout) while True: event, values = window.read() # logger.debug(f'prefEditor event is {event}') if event in (sg.WIN_CLOSED, 'Cancel'): break elif event == '-FORMAT-LIST-': new_type = values['-FORMAT-LIST-'] new_fname = values['-EXPORT-FOLDER-'].split('.') new_fname[-1] = new_type new_fname = '.'.join(new_fname) window['-EXPORT-FOLDER-'].update(value=new_fname) elif event == 'Export': # logger.debug(f'list value is {values["-LIST-"]}') self.exportFile(rec, type=values['-FORMAT-LIST-'], location=values['-EXPORT-FOLDER-']) break elif event == 'Cancel': break window.close()
def __init__(self): self.df = pd.DataFrame() self.path_symbols = "" self.path_eplan = "" self.path_merged = "" self.path_merged = "" self.listEplan = [] #Optionshandling self.Option = True self.Reserve = True self.AddMissing = True #GUI Layout self.layout = [ [sg.Text("Enter Path for the EPlan Export File below:")], [ sg.Input(key='eplan'), sg.FileBrowse(file_types=(('EPlan Export', '*.xls'), )) ], [sg.T(background_color='white')], # spacer [sg.Text("Enter Path for the PLC Symbol Export below:")], [ sg.Input(key='plc'), sg.FileBrowse(file_types=(('System Data Format', '*.sdf'), )) ], [sg.Text("!! Only SDF supported so far !!", font='Default 8')], [sg.T(background_color='white')], # spacer [sg.Text("Save merged File to:")], [ sg.Input(key='save'), sg.FileSaveAs(file_types=(('System Data Format', '*.sdf'), )) ], [sg.T(background_color='white')], #spacer [ sg.Checkbox("Inactive EAs get Suffix '_Option'", default=True, key='Option') ], [ sg.Checkbox( "if Comment = 'Reserve' -> Symbols = 'Reserve_Kürzel_Byte_Bitadresse'", default=True, key='Reserve') ], [ sg.Checkbox("Add missing Values to File", default=True, key='Add') ], [sg.T(background_color='white')], # spacer [sg.OK(), sg.Cancel()] ]
def create_layout() -> list: return [[psg.Text('Save As - File Dialogue')], [ psg.Combo(psg.user_settings_get_entry('-filenames-', []), default_value=psg.user_settings_get_entry( '-last filename-', ''), size=(50, 1), key='-FILENAME-'), psg.FileSaveAs('File') ], [ psg.Button('Accept'), psg.Button('Clear'), psg.Button('Exit') ]]
def box_window_question_file_save(question): layout = [[sg.Text(question)], [sg.Input(key="input")], [sg.FileSaveAs(key="FileBrowse", enable_events=True)], [sg.Submit()]] window = sg.Window('3D Resumer', layout, size=(700, 300)) while True: event, values = window.read() if event == sg.WIN_CLOSED: sys.exit() elif event == "Submit": window.close() return values["input"] elif event == "FileBrowse": window["input"].update(values["FileBrowse"])
def just_process(data, settings_manager): """ Look at process data only. """ layout = [[ sg.Multiline(data.get_top_processes(), size=(100, 30), key="_data") ], [ sg.Button("Pause", button_color=('black', '#F0F0F0')), sg.Button("Resume", button_color=('black', '#F0F0F0')), sg.FileSaveAs("Save As", button_color=('black', '#F0F0F0'), file_types=(("Log File", "*.log"), )), sg.Button("Reset Data", button_color=('black', '#F0F0F0')), sg.Button("Cancel", button_color=('black', '#F0F0F0')), sg.Text("Status: RUNNING", key="_running"), ]] window = sg.Window("Live Top Processes", layout, location=(1, 1)) running = True to_save = "" while True: event, values = window.Read(timeout=1000) data.update(settings_manager) if event in (None, "Cancel"): break elif event == "Pause": running = False window.Element("_running").Update("Status: PAUSED") elif event == "Resume": running = True window.Element("_running").Update("Status: RUNNING") elif event == "Reset Data": data.reset_data(settings_manager) window.Refresh() if values.get("Save As") != to_save: to_save = values.get("Save As") with open(values.get("Save As"), "w") as f: f.write(data.get_top_processes()) if running: top = data.get_top_processes() window.Element("_data").Update(value=top) window.close()
def saveMenu(self): sg.theme("DarkBlue") layout = [ [sg.Text("Save Untitled as")], [sg.FileSaveAs(), sg.InputText(key="saveLocation")], [sg.Button("Save"), sg.Button("Cancel")], ] window = sg.Window("Save file as", layout=layout) while True: event, values = window.read() if event == sg.WINDOW_CLOSED or event == "Cancel": window.close() return None if event == "Save": window.close() return values['saveLocation']
def main(): ''' Main function for live debugger. ''' lppc = LivePathAndProcess("_output1") # template="$process_\n") layout = [[lppc.layout], [sg.Text("AMP CPU Usage: "), sg.Text("{:.1f}", key='_cpu')], [ sg.Button("Pause"), sg.Button("Resume"), sg.FileSaveAs("Save As", file_types=(("Log File", "*.log"), )), sg.Button("Cancel"), sg.Text("Status: RUNNING", key="_running"), ]] window = sg.Window("Live File/Process Monitoring", layout) running = True to_save = "" while True: event, values = window.Read(timeout=2000) if event in (None, "Cancel"): break elif event == "Pause": running = False window.Element("_running").Update("Status: PAUSED") elif event == "Resume": running = True window.Element("_running").Update("Status: RUNNING") if values.get("Save As") != to_save: to_save = values.get("Save As") with open(values.get("Save As"), "w") as file: file.write(values.get(lppc.key)) if running: lppc.update(window) window.close()
def get_layout(cls): return [ sg.Button('save & overwrite', key='save', font=cls.FONT_10, pad=cls.PAD_BUTTON_CONTROLS), sg.FileSaveAs('save as', key='save_as', font=cls.FONT_10, pad=cls.PAD_BUTTON_CONTROLS, target='save_cfg_path', file_types=(cls.JSON_FILETYPE, ), initial_folder=cls.INITIAL_CONFIG_FOLDER), sg.FileBrowse('load', key='load', font=cls.FONT_10, pad=cls.PAD_BUTTON_CONTROLS, target='load_cfg_path', file_types=(cls.JSON_FILETYPE, ), initial_folder=cls.INITIAL_CONFIG_FOLDER), sg.InputText(key='save_cfg_path', enable_events=True, visible=False, disabled=True), sg.InputText(key='load_cfg_path', enable_events=True, visible=False, disabled=True), sg.InputText(cls.DEF_PATH, key='cfg_path', visible=False, disabled=True), sg.Text('loaded config:', pad=((5, 0), 0)), sg.Text(os.path.basename(cls.DEF_PATH), key='cfg_filename', font=('Courier New', 10), size=(30, 1)), ]
class interface: sg.theme('Light Blue 2') # Definição dos botões __play_button = sg.Button('Tocar música', font = 'Helvetica', disabled = False, key = 'play_button') __stop_button = sg.Button('Parar música', font = 'Helvetica', disabled = True, key = 'stop_button') __select_button = sg.FileBrowse('Abrir arquivo ', font = 'Helvetica', key = 'select_button', file_types = (("Text Files", "*.txt"), )) __save_button = sg.FileSaveAs('Exportar MIDI', font = 'Helvetica', key = 'save_button',default_extension = ".MIDI", file_types = (("MIDI Files", "*.midi"), )) __text_box = sg.Multiline(default_text = '', size = (75, 25), font = 'Helvetica', key = 'text_box') __octave_select = sg.Spin([i for i in range(1,10)], initial_value=5, font = 'Helvetica', key='octave_select', size=(2,1)) __bpm_select = sg.Spin([i for i in range(1,180)], initial_value=80, font = 'Helvetica', key='bpm_select', size=(3,1)) __volume_slider = sg.Slider(range=(0,100), default_value=50, size=(16,15), orientation='horizontal', font=('Helvetica', 12), key='volume_slider') # Definição do layout da interface layout = [ [sg.Text(" ", size = (10, 1))], [ sg.Text(" ", size = (14, 1)), sg.Text("TEXT-TO-BEEP", justification = 'center', size = (20, 1), font = ['Helvetica', 30]) ], [__text_box], [sg.Text(" ", size = (10, 1))], [ sg.Text("Oitava inicial:", size = (10, 1), font=('Helvetica', 12)), __octave_select, sg.Text("BPM inicial:", size = (9, 1), font=('Helvetica', 12)), __bpm_select, sg.Text(" ", size = (6, 1), pad='20'), __play_button, sg.Text(" ", size = (10, 2)), __stop_button ], [ sg.Text("Volume inicial:", size = (11, 1), font=('Helvetica', 12)), __volume_slider, sg.Text(" ", size = (5, 2)), sg.Input(key = 'file_saved', visible = False, enable_events = True, default_text = " "), __save_button, sg.Text(" ", size = (10, 2)), sg.Input(key = 'file_selected', visible = False, enable_events = True), __select_button ], [sg.Text(" ", size = (10, 1))] ] window = sg.Window('Text-to-Beep', layout) event = 0 values = 0 def __init__(self): pass # Altera os estados dos botões def play(self): self.window['play_button'].update(disabled = True) self.window['volume_slider'].update(disabled = True) self.window['octave_select'].update(disabled = True) self.window['select_button'].update(disabled = True) self.window['save_button'].update(disabled = True) self.window['bpm_select'].update(disabled = True) self.window['stop_button'].update(disabled = False) # Altera os estados dos botões def stop(self): self.window['play_button'].update(disabled = False) self.window['volume_slider'].update(disabled = False) self.window['octave_select'].update(disabled = False) self.window['select_button'].update(disabled = False) self.window['save_button'].update(disabled = False) self.window['bpm_select'].update(disabled = False) self.window['stop_button'].update(disabled = True) # Carrega um arquivo texto para a caixa de texto de entrada def writeFileToTextBox(self): textFile = None if self.values['file_selected'] != '': textFile = open(self.values['file_selected'], "r") if textFile != None: self.__text_box.print(textFile.read()) textFile.close() else: pass # Metodo que retorna o texto que está na caixa de texto def returnText(self): return self.__text_box.get() def getDefaultVolumeSelect(self): return int(self.values['volume_slider']) def getDefaultOctaveSelect(self): return int(self.values['octave_select']) def getDefaultBPMSelect(self): return int(self.values['bpm_select']) # update_window(self) checa para interações com a interface e armazena em EVENT e VALUES. Em seguida é feita a alteração visual necessária na interface. def update_window(self): self.event, self.values = self.window.read() if (self.event == "play_button"): interface.play(self) elif (self.event == "stop_button"): interface.stop(self) else: pass
def start_scorer_windows(): scorer_layout = [[ Sg.Text("Current Question:"), Sg.Text("N/A", key="current_question"), Sg.Text("Question Value:"), Sg.Text("0000", key="question_value") ], [Sg.Text(" + - Other")]] for i in range(len(players)): scorer_layout.append([ Sg.Text(players[i] + ":"), Sg.Radio("", group_id="player_{}".format(i + 1), key="player_{}_add".format(i + 1)), Sg.Radio("", group_id="player_{}".format(i + 1), key="player_{}_subtract".format(i + 1)), Sg.Radio("", default=True, group_id="player_{}".format(i + 1), key="player_{}_other".format(i + 1)), Sg.Input(key="player_{}_input".format(i + 1), size=(6, 1)) ]) scorer_layout.extend([[ Sg.Text("Save to File:"), Sg.Input(key="filename", size=(18, 1)), Sg.FileSaveAs(file_types=(("Text Document", "*.txt"), ("all files", "*.*"))) ], [Sg.Check("Keep client window on top", key="keep_on_top")], [ Sg.Button("Update", key="update", bind_return_key=True), Sg.Button("Start Client", key="client_start"), Sg.Button("Save To File", key="save_to_file") ]]) scorer_window = Sg.Window("Jeopardy Score Host", scorer_layout, resizable=True, finalize=True) client_window, client_event, client_values = None, None, None scores = { "players": players, "scores": ["0" for _ in range(len(players))], "previous_scores": ["0" for _ in range(len(players))] } question_value = 0 board = json.loads(open("board.json").read()) while True: scorer_event, scorer_values = scorer_window.read(100) if scorer_event is None: return elif scorer_event == "client_start" and not client_window: scorer_window["client_start"].update(disabled=True) scorer_window["keep_on_top"].update(disabled=True) client_window = make_client_window(scores, scorer_values["keep_on_top"]) elif scorer_event == "update": scores["previous_scores"] = scores["scores"][:] for i in range(len(scores["scores"])): if scorer_values["player_" + str(i + 1) + "_add"]: scores["scores"][i] = str( int(scores["scores"][i]) + question_value) elif scorer_values["player_" + str(i + 1) + "_subtract"]: scores["scores"][i] = str( int(scores["scores"][i]) - question_value) else: add_to_score = scorer_values["player_" + str(i + 1) + "_input"] if add_to_score.isnumeric() or ( len(add_to_score) > 1 and add_to_score[0] == "-" and add_to_score[1:].isnumeric()): scores["scores"][i] = str( int(scores["scores"][i]) + int(add_to_score)) scorer_window["player_" + str(i + 1) + "_add"](False) scorer_window["player_" + str(i + 1) + "_subtract"](False) scorer_window["player_" + str(i + 1) + "_other"](True) scorer_window["player_" + str(i + 1) + "_input"]("") if client_window is not None: table_data = [] for i in range(len(players)): row = [ players[i], scores["scores"][i], scores["previous_scores"][i] ] table_data.append(row) client_window["score_table"].update(values=table_data) elif scorer_event == "save_to_file": if scorer_values["filename"] != "": open(scorer_values["filename"], "w").write(str(scores)) current_question = open("SlideNotes.txt").read().strip("\n") scorer_window["current_question"](current_question) question_value = board[current_question] scorer_window["question_value"](str(question_value)) if current_question == "DD": for i in range(len(scores["players"])): scorer_window["player_" + str(i + 1) + "_add"].update(disabled=True) scorer_window["player_" + str(i + 1) + "_subtract"].update(disabled=True) else: for i in range(len(scores["players"])): scorer_window["player_" + str(i + 1) + "_add"].update(disabled=False) scorer_window["player_" + str(i + 1) + "_subtract"].update(disabled=False)
[ sg.Radio(text="Chip erase", group_id="-GRP-OPS-", key="-OP-CHIP-ERASE-", tooltip="Perform a chip erase operation") ], [ sg.Radio(text="Blank check", group_id="-GRP-OPS-", key="-OP-BLANK-CHECK-", tooltip="Verify if the cartridge is blank") ], [ sg.Button("Run", key='-RUN-') ], ] layout_buffer = [ [ sg.Text("Contents: "), sg.Text("", key="-BUFFER-NAME-") ], [ sg.Text("Size: "), sg.Text("", key="-BUFFER-SIZE-") ], [ sg.Text("MD5: "), sg.Input("", key="-MD5-", disabled=True) ], [ sg.Text("TMR header: "), sg.Text("-", key="-TMR-") ], [ sg.Text("SDSC header: "), sg.Text("-", key="-SDSC-") ], [ sg.Multiline(autoscroll = False, expand_y = True, expand_x = True, size=(80,25), font=('monospace', 8), key="-BUFFER-", write_only = True, disabled = True ) ], [ sg.FileBrowse("Load file...", enable_events=True, key="-LOAD-", target="-LOAD-", file_types=g_rom_filetypes), sg.FileSaveAs("Save file...", enable_events=True, key="-SAVE-", target="-SAVE-"), ], ] layout_programmer = [ [ sg.Text("Port: "), sg.Button("(rescan)", key="-RESCAN-") ], [ sg.Listbox(key="-SELECTED-PORT-", values=g_portnames, enable_events=True, expand_x = True, expand_y = True, size=(10,5)) ], [ sg.Text("Version: "), sg.Text("", key="-TXT-VERSION-") ], [ sg.FileBrowse("Update...", enable_events=True, key="-UPDATEFW-", file_types=[("HEX Files","*.hex")]) ], ] column_leftSide = [ [ sg.Frame("Operations", layout_operations, expand_x = True) ], [ sg.Frame("Programmer", layout_programmer) ], ]
def the_GUI(): program_theme = 'DarkGrey5' is_authenticated = False gui_queue = queue.Queue() auth_window_active, about_window_active, console_window_active = False, False, False sg.theme(program_theme) menu_def = [ ['File', ['About', 'API Authentication']], ] main_layout = [ [sg.Menu(menu_def)], [sg.Text('FLICKR GeoSearch')], # Search [sg.Radio('BBOX', "Search_Type", default=True, key='-bbox_boolean-')], [ sg.Text(size=(5, 1)), sg.Text('Min Lat:', size=(7, 1), tooltip='-90 - 90'), sg.InputText(size=(5, 1), key='-min_lat-'), sg.Text(size=(1, 1)), sg.Text('Max Lat:', size=(7, 1), tooltip='-90 - 90'), sg.InputText(size=(5, 1), key='-max_lat-') ], [ sg.Text(size=(5, 1)), sg.Text('Min Long:', size=(7, 1), tooltip='-180 - 180'), sg.InputText(size=(5, 1), key='-min_long-'), sg.Text(size=(1, 1)), sg.Text('Max Long:', size=(7, 1), tooltip='-180 - 180'), sg.InputText(size=(5, 1), key='-max_long-') ], [ sg.Radio('Radial', "Search_Type", default=False, key='-radial_boolean-') ], [ sg.Text(size=(5, 1)), sg.Text('Lat: ', size=(7, 1), tooltip='-90 - 90'), sg.InputText(size=(5, 1), key='-radial_lat-'), sg.Text(size=(1, 1)), sg.Text('Long:', size=(7, 1), tooltip='-180 - 180'), sg.InputText(size=(5, 1), key='-radial_long-') ], [ sg.Text(size=(5, 1)), sg.Text('Radius:', size=(7, 1), tooltip='max 20mi / 32km'), sg.InputText(size=(5, 1), key='-radial_radius-'), sg.Text(size=(1, 1)), sg.Text('Units', size=(7, 1)), sg.Drop(values=('mi', 'km'), size=(4, 1), auto_size_text=True, key='-radial_units-') ], # Accuracy [ sg.Checkbox('Accuracy: ', default=False, size=(7, 1), key='-accuracy_boolean-'), sg.InputText(size=(4, 1), key='-accuracy-'), sg.Text(size=(13, 1), key='-accuracy_description-') ], [ sg.Text(size=(3, 1)), sg.Slider((1, 16), key='-slider_accuracy-', orientation='h', enable_events=True, disable_number_display=True) ], # Min Date Taken Upload [ sg.Checkbox('Minimum Date Taken: ', default=False, size=(17, 1), key='-min_date_boolean-') ], [ sg.Text(size=(3, 1)), sg.Drop(values=('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), size=(3, 1), auto_size_text=True, key='-min_month-', tooltip='month, 3 letter abbreviation'), sg.Text('-', size=(1, 1)), sg.Drop(values=('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'), size=(2, 1), tooltip='day, max 2 digit', key='-min_date-'), sg.Text('-', size=(1, 1)), sg.InputText(size=(4, 1), tooltip='Year, 4 number', key='-min_year-') ], # Max Date Taken Upload [ sg.Checkbox('Maximum Date Taken: ', default=False, size=(17, 1), key='-max_date_boolean-') ], [ sg.Text(size=(3, 1)), sg.Drop(values=('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), size=(3, 1), auto_size_text=True, key='-max_month-', tooltip='month, 3 letter abbreviation'), sg.Text('-', size=(1, 1)), sg.Drop(values=('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'), size=(2, 1), tooltip='day, max 2 digit', key='-max_date-'), sg.Text('-', size=(1, 1)), sg.InputText(size=(4, 1), tooltip='Year, 4 number', key='-max_year-') ], # Search Tags [ sg.Checkbox('Search tags: ', default=False, size=(9, 1), key='-search_tags_boolean-', tooltip='comma delimited'), sg.InputText(size=(23, 0), key='-search_tags-') ], # User wants results uploaded to gallery [ sg.Checkbox('Upload to Gallery', default=False, size=(17, 1), key='-upload_to_gallery_boolean-', tooltip='time intensive, 3 minutes per 500 results') ], # User wants results on Owner Info [ sg.Checkbox('Get Owner Info', default=False, size=(17, 1), key='-user_info_boolean-', tooltip='Slow, Name and Hometown') ], [sg.Text('' * 30)], # Download Gallery [ sg.Radio('Download From Gallery', "Search_Type", default=False, key='-gallery_download_boolean-', tooltip='TODO, see V1.0 for function') ], [ sg.Text(size=(1, 1)), sg.Frame(layout=[ [ sg.Text('Gallery ID: ', size=(9, 1)), sg.InputText(size=(20, 1), key='-gallery_id-') ], ], title='', title_color='red', relief=sg.RELIEF_SUNKEN) ], # File name and location [sg.InputText('Output File'), sg.FileSaveAs(key='-file_save_as-')], # Search [sg.Button('Search')] ] window = sg.Window("FLICKR GeoSearch", main_layout) thread = None # ---------EVENT LOOP-----------# while True: event, values = window.read() if event is None or event == 'Exit': break # Authorization Window if event == 'API Authentication' and not auth_window_active: sg.theme(program_theme) auth_layout = [ [sg.Text('API Key')], [sg.InputText(key='-api_key-')], [sg.Text('Secret Key')], [sg.InputText(key='-secret_key-', password_char='*')], [ sg.Button('Validate'), sg.Text(size=(15, 1), key='-Valid_Status-') ], [sg.Text('Token')], [ sg.InputText(key='-token-'), sg.Text(size=(15, 1), key='-Authentication_Status-') ], [sg.Button('Authenticate')], [sg.Ok(), sg.Cancel()], ] auth_window = sg.Window('Authentication', auth_layout, no_titlebar=True, grab_anywhere=True) auth_window_active = True # Authorization Interactions while auth_window_active: event2, values2 = auth_window.read() if event2 == 'Cancel' or event2 == 'Ok': auth_window.close() auth_window_active = False if event2 == 'Validate' and not is_authenticated: flickr = flickrapi.FlickrAPI(values2['-api_key-'], values2['-secret_key-']) auth_window['-Valid_Status-'].update('Validating..') if flickr.token_valid(perms='write'): is_authenticated = True auth_window['-Valid_Status-'].update('Validated') auth_window['-Authentication_Status-'].update( 'Authenticated') if not flickr.token_valid(perms='write'): flickr.get_request_token(oauth_callback='oob') # authorization_url = flickr.auth_url(perms='write') webbrowser.open_new(flickr.auth_url(perms='write')) if event2 == 'Authenticate' and not is_authenticated: auth_window['-Authentication_Status-'].update( 'Authenticating...') verifier = values2['-token-'] flickr.get_access_token(verifier) if flickr.token_valid(perms='write'): is_authenticated = True auth_window['-Authentication_Status-'].update( 'Authenticated') # About Window if event == 'About' and not about_window_active: sg.theme(program_theme) about_layout = [ [ sg.Multiline( default_text= "FLICKR GeoSearch V3.0\nCreated by: Matthew Tralka, 2020\nSource available on " "Github: " "mtralka\nLicensed under: GNU General Public License v3.0\n\n\n\nUses the Flickr API " "to " "execute geospatial photo searches. Results are auto formatted into an excel file and " "can be " "uploaded to Flickr photo galleries for review. Also supports the download of photos " "from " "Flickr photo galleries. " "", enter_submits=False, disabled=True, autoscroll=False, enable_events=False, do_not_clear=True, size=(50, 30)) ], [sg.Ok()], ] about_window = sg.Window('About', about_layout, no_titlebar=True, grab_anywhere=True) about_window_active = True # About Interactions while about_window_active: event3, values3 = about_window.read() if event3 == 'Ok': about_window.close() about_window_active = False # Accuracy Slider window['-accuracy-'].update(values['-slider_accuracy-']) if values['-accuracy_boolean-']: if int(values['-slider_accuracy-']) == 1: window['-accuracy_description-'].update('World') if int(values['-slider_accuracy-']) == 2: window['-accuracy_description-'].update('World+') if int(values['-slider_accuracy-']) == 3: window['-accuracy_description-'].update('Country') if int(values['-slider_accuracy-']) == 4: window['-accuracy_description-'].update('Country+') if int(values['-slider_accuracy-']) == 5: window['-accuracy_description-'].update('Country++') if int(values['-slider_accuracy-']) == 6: window['-accuracy_description-'].update('Region') if int(values['-slider_accuracy-']) == 7: window['-accuracy_description-'].update('Region+') if int(values['-slider_accuracy-']) == 8: window['-accuracy_description-'].update('Region++') if int(values['-slider_accuracy-']) == 9: window['-accuracy_description-'].update('Region+++') if int(values['-slider_accuracy-']) == 10: window['-accuracy_description-'].update('Region++++') if int(values['-slider_accuracy-']) == 11: window['-accuracy_description-'].update('City') if int(values['-slider_accuracy-']) == 12: window['-accuracy_description-'].update('City+') if int(values['-slider_accuracy-']) == 13: window['-accuracy_description-'].update('City++') if int(values['-slider_accuracy-']) == 14: window['-accuracy_description-'].update('City+++') if int(values['-slider_accuracy-']) == 15: window['-accuracy_description-'].update('City++++') if int(values['-slider_accuracy-']) == 16: window['-accuracy_description-'].update('Street') # Search Command if event == 'Search' and not is_authenticated: sg.popup("Authentication Needed", title="Error", background_color='red', no_titlebar=True) if event == 'Search' and is_authenticated and not thread: search = flickrSearchParameters(values) thread = threading.Thread(target=long_operation_thread, daemon=True, kwargs={ 'flickr': flickr, 'search': search }) thread.start() # Threading if thread: sg.popup_animated(sg.DEFAULT_BASE64_LOADING_GIF, background_color='white', transparent_color='white', time_between_frames=1) thread.join(timeout=0) if not thread.is_alive(): sg.popup_animated(None) thread = None
def __init__(self, robots_names, sm_path): # Set environment variable required for the Interface execution # os.environ["DISPLAY"]=":0" # Events trace self.trace = pd.DataFrame(columns = ['robot', 'event', 'event_type', 'param', 'enabled_events', 'time']) # Variable that maitaints the allowed events self.robots_events = {} for r in robots_names: self.robots_events[r] = [] ################################################################################# #### -- Auxiliary variables -- ################################################## # Control of the tracer self.events_counter = 0 self.new_trace = False self.update_allowed_events = False self.update_model = False # Get name of the Machines self.sm_path = sm_path self.models = None # Get all events call in the module self.__events = {} for x in inspect.getmembers(events_module,inspect.isclass): self.__events[x[0]] = x[1] # Get controllable events self.__cont_e = [e for e in self.__events if self.__events[e].is_controllable()] # Get uncontrollable events self.__not_cont_e = [e for e in self.__events if not self.__events[e].is_controllable()] # Get translation table self.translation_table = pd.read_csv("OP/translation_table.csv") self.robots = ['all'] self.robots[1:] = robots_names ################################################################################# #### -- Layout of the Window -- ################################################# self.main = [ # TRACE: [sg.Frame('TRACE:',[ [sg.InputCombo(values = self.robots, default_value= self.robots[0], key='trace_option', enable_events=True, size= (25,10))], [sg.Text("Id"), sg.Text("Robot"), sg.Text("Event"), sg.Text("Parameters"), sg.Text("Time")], [sg.Multiline(size=(45,35), key='tracer', disabled=True, autoscroll=True, )], [sg.Input(visible=False, enable_events=True, key='save'), sg.FileSaveAs("SAVE", file_types = (("ALL Files", "*.*"),("CSV text",".csv")), target='save', enable_events=True), sg.Button("REFRESH", key='refresh')] ]), # TRIGGER sg.Column([ [sg.Frame('TRRIGER EVENT:',[ [sg.Text("Robot: "), sg.InputCombo(values = self.robots[1:], default_value= self.robots[1], size=(20,10), key='selected_robot', enable_events=True)], [sg.Text("Event: "),sg.InputCombo(values = [], default_value= '', size=(20,10), key='selected_event')], [sg.HorizontalSeparator()], [sg.Text('Parameters:')], [sg.Input(key='new_param',enable_events=True, size=(25,5)), sg.Button("+", key='add_param', size=(1,1), button_color=('white','green'))], [sg.Listbox('', key='param_list', size=(30, 4))], [sg.Button("-", key='remove_param', size=(28,1), button_color=('white','red'))], [sg.Button('TRIGGER', key='trigger', size=(28,1))] ])], [sg.Button('Vizualize Models', key='models', size=(28,1))] ])] ] # start the Window # self.window = sg.Window("EVENTS TRIGGER INTERFACE", size=(650,500)).layout(self.main) self.window = sg.Window("EVENTS TRIGGER INTERFACE", size=(650,500),layout = self.main, resizable = True) self.models_window = None
return rows except IOError as i: return rows window_layout = [[pSg.Text('Please select the csv file')], [ pSg.Text('Choose CSV File :'), pSg.InputText('Outlook CSV File.csv'), pSg.FileBrowse(file_types=(("CSV", "*.csv"), )) ], [pSg.Text('')], [pSg.Text('Please select VCard destination')], [ pSg.Text('Save VCF File as :'), pSg.InputText('Apple VCF Card.vcf'), pSg.FileSaveAs(file_types=(("VCARD", ".vcf"), )) ], [pSg.Text('')], [pSg.Button("Convert"), pSg.Exit()]] default_input = "Outlook CSV File.csv" default_output = "Apple VCF Card.vcf" main_window = pSg.Window('CSV to VCF Converter').Layout(window_layout) while True: btn, value = main_window.Read() if btn in (None, 'Exit'): break if default_input == value[0] or default_output == value[1]: pSg.Popup("Please select input source / output destination ", title="Error") continue
def manual_sfc(data): """ Pop-up for manual analysis of an SFC log. """ column1 = [] layout = [ [sg.Text("Current SFC Log: {}".format(data.sfc_path), size=(150, 1), \ key="_path_display"),], [sg.Button("Change SFC File", button_color=('black', '#F0F0F0')), sg.Button("Analyze", \ button_color=('black', '#F0F0F0')), sg.Button("Reset SFC File", \ button_color=('black', '#F0F0F0'))], [ sg.Text("Cloud Lookup Count: ", tooltip="Count of the cloud lookups since starting \ the AMP Health Checker." ), sg.Text("", size=(20, 1), key="_cloud_lookup_count") ], [ sg.Text("Excluded Count: ", tooltip="Count of the scanned files that matched an \ exclusion." ), sg.Text("", size=(20, 1), key="_excluded_count")], [ sg.Text("Cache Count: ", tooltip="Count of the files that matches a locally cached \ hash. These don't require a cloud lookup." ), sg.Text("", size=(20, 1), key="_cache_hit_count") ], [ sg.Text("TETRA Scan Count: ", tooltip="Count of the files that the TETRA engine \ scanned." ), sg.Text("", size=(20, 1), key="_tetra_scan_count") ], [ sg.Text("SPERO Scan Count: ", tooltip="Count of the files that the SPERO engine \ scanned." ), sg.Text("", size=(20, 1), key="_spero_count") ], [ sg.Text("ETHOS Scan Count: ", tooltip="Count of the files that the ETHOS engine \ scanned." ), sg.Text("", size=(20, 1), key="_ethos_count") ], [ sg.Text("Malicious Count: ", tooltip="Count of the files scanned that returned a \ malicious disposition." ), sg.Text("", size=(20, 1), key="_malicious_hit_count") ], [ sg.Text("Quarantine Count: ", tooltip="Count of the files that were successfully \ quarantined." ), sg.Text("", size=(20, 1), key="_quarantine_count") ], [ sg.Text("Inner File Scan Count: ", tooltip="Count of inner file scans. ClamAV could \ slow the system if scan count is high over a short period." ), sg.Text("", size=(20, 1), key="_inner_file_scan") ], [sg.Multiline("Top 10 Processes\n"+data.get_top_processes(10), size=(100, 12), \ key="_top_processes"), sg.Multiline("Top 10 Paths\n"+data.get_top_paths(10), size=(100, 12), \ key="_top_paths")], [sg.Multiline("Top 10 Extensions\n"+data.get_top_extensions(10), size=(100, 12), \ key="_top_extensions"), sg.Multiline("Top 10 Folders\n"+data.get_top_folders(10), size=(100, 12), \ key="_top_folders")], [sg.Multiline("Top 10 Exclusions Hit\n"+data.get_top_exclusions(10), size=(100, 12), \ key="_top_exclusions")], [ sg.FileSaveAs("Save As", button_color=('black', '#F0F0F0'), \ file_types=(("Log File", "*.log"),)), sg.Button("Cancel", button_color=('black', '#F0F0F0')), ] ] window = sg.Window("Manual SFC Analysis", layout) while True: event, values = window.Read() logging.debug('Event - %s : Values - %s', event, values) if event in (None, 'OK', 'Cancel'): break elif event == "Change SFC File": new_sfc_file = sg.PopupGetFile(title="SFC Log", message="Choose New SFC.log", default_path=data.sfc_path, initial_folder="{}/{}".format( data.root_path, data.version)) data.sfc_path = new_sfc_file window.Element("_path_display").Update( "Current SFC Log: {}".format(data.sfc_path)) window.Refresh() elif event == "Analyze": with open(data.sfc_path) as file: data.last_log_line = file.readlines()[0] data.update() window.FindElement('_quarantine_count').Update( data.quarantine_count) window.FindElement('_spero_count').Update(data.spero_count) window.FindElement('_ethos_count').Update(data.ethos_count) window.FindElement('_cloud_lookup_count').Update( data.cloud_lookup_count) window.FindElement('_tetra_scan_count').Update( data.tetra_scan_count) window.FindElement('_excluded_count').Update(data.excluded_count) window.FindElement('_cache_hit_count').Update(data.cache_hit_count) window.FindElement('_malicious_hit_count').Update( data.malicious_hit_count) window.FindElement('_inner_file_scan').Update( data.inner_file_count) window.FindElement('_top_processes').Update("Top 10 Processes\n"+ \ data.get_top_processes(10)) window.FindElement('_top_paths').Update("Top 10 Paths\n" + data.get_top_paths(10)) window.FindElement('_top_extensions').Update("Top 10 Extensions\n"+ \ data.get_top_extensions(10)) window.FindElement('_top_folders').Update("Top 10 Folders\n" + data.get_top_folders(10)) window.FindElement('_top_exclusions').Update( "Top 10 Exclusions Hit\n" + data.get_top_exclusions(10)) elif event == "Reset SFC File": data.sfc_path = "{}/{}/sfc.exe.log".format(data.root_path, data.version) window.Element("_path_display").Update( "Current SFC Log: {}".format(data.sfc_path)) window.Refresh() window.close()
"Aspergillus genomes?", size=(TEXT_WIDTH, 6)) ], [ TextLabel("Session file"), sg.InputText(size=(34, 1), key="extract_session"), sg.FileBrowse(key="extract_session") ], [ sg.Text("A session file (.json) generated by a cblaster search.", size=(TEXT_WIDTH, 1)) ], [ TextLabel("Output file"), sg.InputText(key="extract_output", size=(34, 1)), sg.FileSaveAs(key="extract_output") ], [ sg.Text( "File path to save the extracted sequences to." " If not provided, they will be printed to the terminal.", size=(TEXT_WIDTH, 2)) ], [TextLabel("Query sequences"), sg.InputText(key="queries")], [ sg.Text( "The names of query sequences which extracted sequences match." " You can provide multiple names here.", size=(TEXT_WIDTH, 2)) ],
def detect_on_dataset_ui(model): sg.theme(cfg.UI.THEME) layout = [ [sg.Text('Dataset Folder Path:')], [ sg.Input(key='-INPUT-PATH-', enable_events=True), sg.FolderBrowse(initial_folder='./') ], [sg.Text('Prediction Output Path:')], [sg.Input(key='-OUTPUT-PATH-'), sg.FolderBrowse(initial_folder='./')], [sg.Text('Annotation Output Path')], [sg.Input(key='-ANNO-PATH-'), sg.FileSaveAs(initial_folder='./')], [sg.Text('Input File Type:')], [ sg.Combo(('.jpg', '.png', '.bmp', '.tif', '.tiff', '.gif'), readonly=True, default_value='.jpg', size=(15, 1), key='-FILE-TYPE-') ], [ sg.Text('Confidence Threshold'), sg.Slider((0, 1), 0.4, 0.05, orientation='h', key='-CONF-SLIDER-'), sg.Text('NMS IOU Threshold'), sg.Slider((0, 1), 0.45, 0.05, orientation='h', key='-NMS-SLIDER-') ], [sg.B('Detect'), sg.B('Exit')] ] window = Window('Detect Dataset', layout, font=(cfg.UI.FONT, 12)) while True: event, value = window.read() if event in ['Exit', None]: break # Update output path and annotation file path according to input path if event in ['-INPUT-PATH-']: window['-OUTPUT-PATH-'].update( os.path.join(value['-INPUT-PATH-'], 'Prediction')) window['-ANNO-PATH-'].update( os.path.join(value['-INPUT-PATH-'], 'annotation.txt')) # Start detection if event in ['Detect']: input_path = value['-INPUT-PATH-'] output_path = value['-OUTPUT-PATH-'] anno_path = value['-ANNO-PATH-'] file_type = value['-FILE-TYPE-'] nms_iou = value['-NMS-SLIDER-'] conf_thresh = value['-CONF-SLIDER-'] anno_file = None try: anno_file = open(anno_path, 'w') images = os.listdir(input_path) if not os.path.exists(output_path): os.mkdir(output_path) # Count file conform the given file type max_process = [x.endswith(file_type) for x in images].count(True) cur_process = 1 window.disable() for image in images: if image.endswith(file_type): # If user push cancel button on the progress popup if not sg.one_line_progress_meter( 'Generating Prediction', cur_process, max_process, key='-PROGRESS-'): break img_RGB = io.imread(os.path.join(input_path, image)) img = cv2.cvtColor(img_RGB, cv2.COLOR_RGB2BGR) # Predict bboxes, _ = predict(img_RGB, model, nms_iou, conf_thresh) pred_img = util.draw_bbox(img.copy(), bboxes) cv2.imwrite(os.path.join(output_path, image), pred_img) anno_line = util.encode_annotation(bboxes, image) anno_file.write(anno_line.strip() + '\n') cur_process += 1 except IOError as e: sg.PopupError("Invalid input file,\n{}".format(e)) sg.one_line_progress_meter('Generating Prediction', 1, 1, key='-PROGRESS-') finally: if anno_file is not None: anno_file.close() window.enable() sg.popup_ok("Detection finished", title="Finish") window.close() del window del layout
def lpap(data): """ This is the live path and process (lpap) pop-up. Needs to be fed the data. """ layout = [ [sg.Text("CPU: {}".format(data.current_cpu), key="_cpu", size=(10, 1))], [ sg.Text("Cloud Lookup Count: ", tooltip="Count of the cloud lookups since \ starting the AMP Health Checker." ), sg.Text("", size=(20, 1), key="_cloud_lookup_count") ], [ sg.Text("Excluded Count: ", tooltip="Count of the scanned files that matched \ an exclusion." ), sg.Text("", size=(20, 1), key="_excluded_count")], [ sg.Text("Cache Count: ", tooltip="Count of the files that matches a locally \ cached hash. These don't require a cloud lookup." ), sg.Text("", size=(20, 1), key="_cache_hit_count") ], [ sg.Text("TETRA Scan Count: ", tooltip="Count of the files that the TETRA \ engine scanned." ), sg.Text("", size=(20, 1), key="_tetra_scan_count") ], [ sg.Text("SPERO Scan Count: ", tooltip="Count of the files that the SPERO \ engine scanned." ), sg.Text("", size=(20, 1), key="_spero_count") ], [ sg.Text("ETHOS Scan Count: ", tooltip="Count of the files that the ETHOS \ engine scanned." ), sg.Text("", size=(20, 1), key="_ethos_count") ], [ sg.Text("Malicious Count: ", tooltip="Count of the files scanned that returned \ a malicious disposition." ), sg.Text("", size=(20, 1), key="_malicious_hit_count") ], [ sg.Text("Quarantine Count: ", tooltip="Count of the files that were successfully \ quarantined." ), sg.Text("", size=(20, 1), key="_quarantine_count") ], [ sg.Text("Inner File Scan Count: ", tooltip="Count of inner file scans \ (i.e. zipped files)." ), sg.Text("", size=(20, 1), key="_inner_file_scan") ], [sg.Text("", key="_data", size=(100, 30))], [ sg.Button("Start/Resume", button_color=('black', '#F0F0F0'), key="_start_resume"), sg.Button("Pause", button_color=('black', '#F0F0F0')), sg.FileSaveAs("Save As", button_color=('black', '#F0F0F0'), \ file_types=(("Log File", "*.log"),)), sg.Button("Reset Data", button_color=('black', '#F0F0F0')), sg.Button("Cancel", button_color=('black', '#F0F0F0')), sg.Text("Status: READY", key="_running", size=(30, 1)), ] ] window = sg.Window("Live Path and Process", layout, location=(1, 1)) running = False to_save = "" is_first = True while True: event, values = window.Read(timeout=1000) data.update() if event in (None, "Cancel"): break elif event == "_start_resume": running = True if is_first: data = lpap_data_reset(data) is_first = False window.Element("_running").Update("Status: RUNNING") window.Element("_start_resume").Update(disabled=True) elif event == "Pause": running = False window.Element("_running").Update("Status: PAUSED") window.Element("_start_resume").Update(disabled=False) elif event == "Reset Data": data = lpap_data_reset(data) window.Element("_data").Update("") window.Element("_cpu").Update("CPU: {}".format(data.current_cpu)) window.FindElement('_quarantine_count').Update( data.quarantine_count) window.FindElement('_spero_count').Update(data.spero_count) window.FindElement('_ethos_count').Update(data.ethos_count) window.FindElement('_cloud_lookup_count').Update( data.cloud_lookup_count) window.FindElement('_tetra_scan_count').Update( data.tetra_scan_count) window.FindElement('_excluded_count').Update(data.excluded_count) window.FindElement('_cache_hit_count').Update(data.cache_hit_count) window.FindElement('_malicious_hit_count').Update( data.malicious_hit_count) window.FindElement('_inner_file_scan').Update( data.inner_file_count) window.Element("_running").Update("Status: READY") window.Refresh() if values.get("Save As") != to_save: to_save = values.get("Save As") with open(values.get("Save As"), "w") as file: file.write(data.convert_to_layout()) if running: window.Element("_data").Update(data.convert_to_layout()) window.Element("_cpu").Update("CPU: {}".format(data.current_cpu)) window.FindElement('_quarantine_count').Update( data.quarantine_count) window.FindElement('_spero_count').Update(data.spero_count) window.FindElement('_ethos_count').Update(data.ethos_count) window.FindElement('_cloud_lookup_count').Update( data.cloud_lookup_count) window.FindElement('_tetra_scan_count').Update( data.tetra_scan_count) window.FindElement('_excluded_count').Update(data.excluded_count) window.FindElement('_cache_hit_count').Update(data.cache_hit_count) window.FindElement('_malicious_hit_count').Update( data.malicious_hit_count) window.FindElement('_inner_file_scan').Update( data.inner_file_count) window.close()