def rearrange_layout_of_tab(self) -> None: form_rows = [[sg.Text('Enter File Paths:')], [ sg.Text('Path to images used as exercises', size=(15, 1)), sg.InputText(key=self.exercise_dir_key), sg.FolderBrowse(target=self.exercise_dir_key) ], [ sg.Text('Path to images used as solutions', size=(15, 1)), sg.InputText(key=self.solution_dir_key), sg.FolderBrowse(target=self.solution_dir_key) ], [sg.Submit(), sg.Cancel()]] self.rows = form_rows
def create_settings_window(settings): sg.theme(settings['color_theme']) def TextLabel(text): return sg.Text(text+':', justification='r', size=(25,1)) layout = [ [sg.Text('Settings', font=('Work Sans', 12))], [TextLabel('Track Hedge Address(es)'),sg.Input(key='-ADDR-')], [TextLabel('Coordinate System'), sg.Combo(COORD_SYS_CHOICES, key='-COORD_SYS-')], [TextLabel('Units'), sg.Combo(UNITS_CHOICES, key='-UNITS-')], [TextLabel('Precision'), sg.Combo(PREC_CHOICES, key='-PREC-')], [TextLabel('Refresh Rate (ms)'), sg.Input(key='-FREQ-')], [TextLabel('Logfile Folder'),sg.Input(key='-LOGDIR-'), sg.FolderBrowse(target='-LOGDIR-')], [TextLabel('Number of position values to average'),sg.Input(key='-NUMLINES-')], [TextLabel('Time until log considered stale (ms)'), sg.Input(key='-ALLOW_DELTA_T-')], [TextLabel('Color Theme'),sg.Combo(sg.theme_list(), key='-THEME-')], [sg.Button('Save'), sg.Button('Restore Defaults'), sg.Button('Exit')] ] window = sg.Window('Settings', layout, keep_on_top=True, finalize=True) for key in SETTINGS_KEYS_TO_ELEMENT_KEYS: # update window with the values read from settings file try: window[SETTINGS_KEYS_TO_ELEMENT_KEYS[key]].update(value=settings[key]) except Exception as e: print(f'Problem updating PySimpleGUI window from settings. Key = {key}') return window
def getFolderInputWindow(titletext="Inputfolder", initial_folder=home): layout = [[sg.Text("Select a folder:")], [ sg.Input(), sg.FolderBrowse("Select Folder", initial_folder=initial_folder) ], [sg.OK(), sg.Cancel()]] window = sg.Window(titletext, layout) event, values = window.Read() window.Close() return event, values
def create_conf_window(parser): sg.theme(parser.get('gui_settings','theme')) def TextLabel(text): return sg.Text(text+':', justification='r', size=(25,1)) layout = [ [sg.Text('Choose Configuration', font = 'Any 20', justification='c')], [sg.Text('')], [TextLabel('Output Directory'), sg.Input(key='-OUTDIR-'), sg.FolderBrowse(target='-OUTDIR-')], [TextLabel('FASTQ Files Directory'), sg.Input(key='-FASTQ-'), sg.FolderBrowse(target='-FASTQ-')], [TextLabel('Spectra Files Directory'), sg.Input(key='-SPECTRA-'), sg.FolderBrowse(target='-SPECTRA-')], [sg.Text('')], [TextLabel('Trinity'), sg.Input(key='-TRINITY-'), sg.FileBrowse(target='-TRINITY-')], [TextLabel('hg19'), sg.Input(key='-HG19-'), sg.FileBrowse(target='-HG19-')], [TextLabel('SearchGUI'), sg.Input(key='-SEARCHGUI-'), sg.FileBrowse(target='-SEARCHGUI-')], [TextLabel('PeptideShaker'), sg.Input(key='-PEPTIDE-'), sg.FileBrowse(target='-PEPTIDE-')], [TextLabel('ACTG'), sg.Input(key='-ACTG-'), sg.FolderBrowse(target='-ACTG-')], [sg.Text('')], [TextLabel('Transcriptome GTF'), sg.Input(key='-GTF-'), sg.FolderBrowse(target='-GTF-')], [TextLabel('Reference genome'), sg.Input(key='-REF-'), sg.FolderBrowse(target='-REF-')], [TextLabel('Mapping Method'), sg.Combo(['PV','PS','VO','SO'],key='-MAP-')], [TextLabel('Protein Database'), sg.Input(key='-DB-'), sg.FileBrowse(target='-DB-')], [TextLabel('Serialization File'), sg.Input(key='-SER-'), sg.FileBrowse(target='-SER-')], [sg.Text('')], [TextLabel('Bamstats'), sg.Input(key='-BAMSTATS-'), sg.FileBrowse(target='-BAMSTATS-')], [TextLabel('BAM Files'), sg.Input(key='-BAM-'), sg.FolderBrowse(target='-BAM-')], [TextLabel('BED File'), sg.Input(key='-BED-'), sg.FileBrowse(target='-BED-')], [sg.Text('')], [TextLabel('DeNoPro Location'), sg.Input(key='-DENOPRO-'), sg.FolderBrowse(target='-DENOPRO-')], [sg.Text('')], [TextLabel('Theme'), sg.Combo(sg.theme_list(), size=(17, 0.8), key='-THEME-')], [sg.Text('')], [sg.Text('')], [sg.Button('Save'), sg.InputText('', do_not_clear=False, visible=False, key='-filename-',enable_events=True), sg.FileSaveAs('Save As'),sg.Button('Exit')] ] window = sg.Window("Config", keep_on_top=True).Layout([[sg.Column(layout,size = (680,720),scrollable=True)]]).Finalize() for k,v in conf_keys.items(): try: window[conf_keys[k][2]].update(value=parser.get(v[0],k)) except Exception as e: print(f'Problem updating GUI window from config. Key = {k}') return window
def main(): # set program theme theme_name = 'DarkPurple4' sg.theme(theme_name) os.system('color') # define default values for UI default_size_text = (30, 1) default_size_input = (50, 1) default_size_input_with_button = ((30, 1), (15, 1)) # define file handeling modes for song duplicates dupli_mode = { 'radio_move': 'Move when in other list', 'radio_copy': 'Copy when in other list', 'radio_download': 'Download again' } # create progress bars and their labels progresses = [(sg.Text(f'ProgBar {key}: None', key=f'-{key}_text', visible=False), sg.ProgressBar(100, key=f'-{key}_progressbar', visible=False)) for key in range(1, 51)] # make layout layout = [[ sg.Text('Username: '******'', key='username_input', enable_events=True), sg.Button('Check', key='username_button') ], [ sg.Text('Anime Music Dir: '), sg.Input(ml.library_dir, key='dir_input', disabled=True, enable_events=True), sg.FolderBrowse(initial_folder=ml.get_default_dir(), key='dir_browse') ], [ sg.Radio(dupli_mode[key], group_id='dupli', key=key, enable_events=True) for i, key in enumerate(dupli_mode) ], [ sg.Text('Thread count: '), sg.Combo(list(range(1, 51)), default_value=1, key='thread_count_combo', enable_events=True) ], [ sg.Column(progresses, scrollable=True, key='progresses_column', size=(700, 200)) ], [sg.Button('Download', key='download_button')], [sg.Button('', visible=False, key='--PROGRESS_UPDATE--')]] to_disable = [ 'download_button', 'username_input', 'username_button', 'dir_input', 'dir_browse', 'radio_move', 'radio_copy', 'radio_download' ] # make window window = sg.Window("MalMuzic", layout, finalize=True, resizable=False) # for x in range(50): # progresses[x][1].UpdateBar(50) # set default values to UI layout[2][0].update(value=True) # set more variables input_default_color = sg.LOOK_AND_FEEL_TABLE[theme_name]['INPUT'] run_thread_running = False run_thread: Tuple[Event, Thread] = None # type: ignore to_close = False # helper function for main def check_username(): print(f'[I] Looking for mal user "{values["username_input"]}"') exists = mm.user_exists(values["username_input"]) print('[I] Username exists' if exists else '[I] Username doesn\'t exists') if not exists: window['username_input'].update(background_color='#FF7777') else: window['username_input'].update( background_color=input_default_color) return exists def get_dupli_mode(): for i, key in enumerate(dupli_mode): if window[key].get(): return i # UI loop while not to_close: event, values = window.read() # type: ignore if event == sg.WIN_CLOSED or event is None: to_close = True if run_thread is not None: run_thread[0].set() continue # print('[I]', event, values[event] if event in values else '') if event == 'username_button': check_username() if event == 'download_button': if not run_thread_running: print('[I] Checking username') if not check_username(): continue ml.library_dir = values['dir_input'] window['download_button']( text=window['download_button'].ButtonText + ' Disabled') for dis in to_disable: window[dis](disabled=True) run_thread = run(window, values["username_input"], progresses, window['progresses_column'], dir=ml.library_dir, thread_count=values['thread_count_combo']) else: cprint('[E] Download already running', 'red') if event == 'thread_count_combo': print(f'[I] User choose {values[event]} threads to run async') if event in dupli_mode: print(f'[I] User choose: "{dupli_mode[event]}"') if event == '--PROGRESS_UPDATE--': # progresses[values[event][0]][1].UpdateBar(values[event][2]) for i in range(len(st.threads)): if st.threads[i] is not None: if hasattr(st.threads[i][1], 'percent'): progresses[i][1].UpdateBar(st.threads[i][1].percent) progresses[i][0].update( value=st.threads[i][1].request + ': ' + str(st.threads[i][1].total_kb) + 'kB, ' + str(round(st.threads[i][1].rate, 1)) + 'kB/s') if run_thread is not None: print('[I] Download thread still running, joining with it.') run_thread[1].join() window.close() print('[!] Exiting program')
size=(80, 1), font=("Helvetica", 18)) file_num_display_elem = sg.Text('File 1 of {}'.format(len(img_files)), size=(10, 1), font=("Helvetica", 18)) ref_dir_elem = [[ sg.Text('Choose a directory containing the REFERENCE images: ', font=("Helvetica", 18)) ], [ sg.InputText(basePath, key='_REF_DIR_', size=(50, 0.75), font=("Helvetica", 12)), sg.FolderBrowse(initial_folder=basePath, font=("Helvetica", 16)) ]] file_listbox_elem = sg.Listbox(values=img_fileNames, size=(40, 20), font=("Helvetica", 16), key='listbox') # define layout, show and read the imageBrowser # Define the buttons: rightColumn = [[filename_display_elem], [resize_display_elem], [ sg.ReadFormButton('Prev', size=(6, 1), font=("Helvetica", 20)), sg.ReadFormButton('Next',
def main(): sg.theme('Reddit') layout = [[sg.Text('', font=('Times', 12), key='timer')], [ sg.Text('Input Audio', size=(10, 1), font='Times 14'), sg.InputText(key="audioIN", size=(50, 1)), sg.FileBrowse(initial_folder="/home", target="audioIN") ], [ sg.Text('Input Data', size=(10, 1), font='Times 14'), sg.InputText(key="dataIN", size=(50, 1)), sg.FileBrowse(initial_folder="/home", target="dataIN") ], [ sg.Text('Encode To', size=(10, 1), font='Times 14'), sg.InputText(key="audioOUT", size=(50, 1)), sg.FolderBrowse(initial_folder="/home", target="audioOUT") ], [ sg.Submit('Encode', size=(10, 1)), sg.Submit('Datafy', size=(10, 1)), sg.Cancel('Quit', size=(10, 1)) ]] window = sg.Window('mrmp3', layout) ####### Main Event Loop ######## while True: event, values = window.read() if event == sg.WIN_CLOSED or event == "Quit": break ######### When User hits "Encode" button ######### if event == "Encode": ## Get time for timing encoding start_time = int(round(time.time() * 100)) ## Get variables for encodeMP3 call input_audio = values["audioIN"] input_data = values["dataIN"] output_audio = values["audioOUT"] output_data = get_file(input_data) ## Update window to prepare for processing window['timer'].Update('Processing...') window.Refresh() ## Call ffmpeg to encode to mp3 emp3.encodeMP3(input_audio, output_data, output_audio) ## Calculate and report encoding completion time final_time = int(round(time.time() * 100)) - start_time format_time = '{:02d}:{:02d}.{:02d}'.format( (final_time // 100) // 60, (final_time // 100) % 60, final_time % 100) window['timer'].update(f"Encoded in {format_time}.") ######### When User hits "Datafy" button ######### if event == "Datafy": ## Get time for timing encoding start_time = int(round(time.time() * 100)) ## Get variables for dataMP3 call input_audio = values["audioIN"] input_data = values["dataIN"] output_audio = values["audioOUT"] ## Update window to prepare for processing window['timer'].Update('Processing...') window.Refresh() if values["audioIN"] == values["audioOUT"]: window['timer'].update( "WARNING: Output file cannot be same as input.") window.Refresh() else: ## Make ffmpeg-readable data file output_data = get_file(input_data) ## Call ffmpeg to add data to mp3 emp3.dataMP3(input_audio, output_data, output_audio) ## Calculate and report encoding completion time final_time = int(round(time.time() * 100)) - start_time format_time = '{:02d}:{:02d}.{:02d}'.format( (final_time // 100) // 60, (final_time // 100) % 60, final_time % 100) window['timer'].update(f"Data added in {format_time}.") window.close()
justification='left') ], [ sg.Text('Path to input video'), sg.In(i_vid, size=(40, 1), key='input'), sg.FileBrowse() ], [ sg.Text('Optional Path to output video'), sg.In(o_vid, size=(40, 1), key='output'), sg.FileSaveAs() ], [ sg.Text('Yolo base path'), sg.In(y_path, size=(40, 1), key='yolo'), sg.FolderBrowse() ], [ sg.Text('Confidence'), sg.Slider(range=(0, 10), orientation='h', resolution=1, default_value=5, size=(15, 15), key='confidence'), sg.T(' ', key='_CONF_OUT_') ], [ sg.Text('Threshold'), sg.Slider(range=(0, 10), orientation='h',
sg.T(""), sg.T("") ], [ sg.T(' PASSWORD:'******'text_pass'), sg.I(key='pass', size=(10, 0.9), disabled=True), sg.T(""), sg.T(""), sg.T(""), sg.T(""), sg.T("") ], [ sg.T(" FOLDER: "), sg.I(key="pasta", size=(46, 0.9)), sg.FolderBrowse("BROWSE", size=(10, 0.95)) ], [ sg.T(size=(20, 1)), sg.B("RUN", size=(8, 0.9)), sg.B("STOP", disabled=True, size=(8, 0.9)), sg.B("EXIT", size=(8, 0.9)) ], [sg.Output(background_color="Black", text_color="White")]] window = sg.Window('File Sharing System', resizable=False, size=(600, 300)).layout(Layout) def terminate_thread(thread): if not thread.is_alive(): return
import PySimpleGUIQt as sg # The following are the available custom processors. from processors import convert_to_plaintext from processors import encode_to_utf8 from processors import standardize_characters from processors import remove_pdf_metadata # Set the 'print' command to use the GUI. print = sg.Print # Define the GUI. sg.ChangeLookAndFeel('TealMono') layout = [ [sg.Text('Select folder to process:', size=(22, 1)), sg.InputText("", key='source'), sg.FolderBrowse(size=(9, 1))], [sg.Text('Save files to:', size=(25, 1)), sg.InputText("", key='destination'), sg.FolderBrowse(size=(9, 1))], [sg.Text('Choose processor:', size=(20, 1))], [sg.Radio("Convert to plaintext (supports .docx, .html, .pdf, .pptx, .rtf)", "Processors", key='convertToPlaintext', default=True)], [sg.Radio("Encode in UTF-8 (expects .txt files)", "Processors", key='encodeUtf8', default=False)], [sg.Radio("Standardize non-ASCII characters and remove non-English characters (expects UTF-8 encoded input)", "Processors", key='standardizeCharacters', default=False)], [sg.Radio("Remove PDF metadata (i.e., authoring information). Expects .pdf files.", "Processors", key='removeMetadata', default=False)], [sg.Button("Process files", size=(20, 1)), sg.Exit(size=(6, 1))], [sg.ProgressBar(max_value=10, orientation='h', size=(80, 20), key='progress')], [sg.Text('', size=(80, 1), key='result_text')], [sg.Text('', size=(80, 1), key='progress_text')],
import os from http.server import HTTPServer, CGIHTTPRequestHandler import socket import PySimpleGUIQt as sg from concurrent.futures import ThreadPoolExecutor from threading import enumerate import ctypes import webbrowser sg.theme("Reddit") sg.SetOptions(button_color=("000000", "000000"), button_element_size=(8, 0.9), auto_size_buttons=True, auto_size_text=True) Layout = [[sg.T("ONLINE FILE SHARING SYSTEM", font="Arial 12 bold", justification="center")], [sg.T()], [sg.T("FOLDER:", size=(7, 1), justification="center"), sg.I(key="pasta", size=(46, 0.9)), sg.FolderBrowse("BROWSE", size=(10, 0.95))], [sg.T(size=(20,1)), sg.B("RUN", size=(8, 0.9)), sg.B("STOP", disabled=True, size=(8, 0.9)), sg.B("EXIT", size=(8, 0.9))], [sg.Output(background_color="Black", text_color="White")]] window = sg.Window('File Sharing System', resizable=False, size=(600, 300)).layout(Layout) def terminate_thread(thread): if not thread.isAlive(): return exc = ctypes.py_object(SystemExit) res = ctypes.pythonapi.PyThreadState_SetAsyncExc( ctypes.c_long(thread.ident), exc) if res == 0: raise ValueError("nonexistent thread id") elif res > 1: ctypes.pythonapi.PyThreadState_SetAsyncExc(thread.ident, None)
def createnewpkg(projectname, packagename, authname): layout = [ [gui.Text('New Package Creator')], [gui.Text('Package Name: %s' % packagename, justification='center')], [gui.Text('Project Name: %s' % projectname, justification='center')], [gui.Text('Author Name: %s' % authname, justification='center')], [ gui.Text('Maintainer: ', justification='center'), gui.InputText('', size=(30, 1), key='_MAINTAINER_', justification='center') ], [ gui.Text('Description: ', justification='center'), gui.InputText('', size=(30, 1), key='_DESCRIPTION_', justification='center') ], [ gui.Text('Version: ', justification='center'), gui.InputText('1.0.0', size=(10, 1), key='_VERSION_', justification='center') ], [gui.Text('Dependencies: ', justification='center')], [ gui.InputText('mobilesubstrate, libcolorpicker', size=(100, 1), justification='center', key='_DEPENDENCIES_') ], [ gui.Text('Filter: ', justification='center'), gui.InputText('com.apple.SpringBoard', size=(30, 1), key='_FILTER_', justification='center') ], [ gui.Text('Kill Process On Install: ', justification='center'), gui.InputText('SpringBoard', size=(30, 1), key='_KILLPROC_', justification='center') ], [ gui.Text('Folder To Build To', font=('Arial', 13, 'bold'), justification='center') ], [ gui.InputText('', size=(70, 1), justification='left', key='_BUILDPATH_'), gui.FolderBrowse() ], [gui.Button('Cancel'), gui.Button('Create')] ] window = gui.Window('Create Menu', no_titlebar=True, keep_on_top=True, grab_anywhere=True).Layout(layout) count = 0 while True: event, values = window.Read() if event == 'Cancel': break if event == 'Create': if values['_FILTER_'] == '': count = 1 elif values['_FILTER_'] != '': appfilter = values['_FILTER_'] count = 0 if values['_KILLPROC_'] == '': count = 2 elif values['_KILLPROC_'] != '': killproc = values['_KILLPROC_'] if values['_BUILDPATH_'] == '': count = 3 elif values['_BUILDPATH_'] != '': buildpath = values['_BUILDPATH_'] if values[ '_DEPENDENCIES_'] == 'Ex: mobilesubstrate, libcolorpicker': count = 4 elif values[ '_DEPENDENCIES_'] != 'Ex: mobilesubstrate, libcolorpicker': dependencies = values['_DEPENDENCIES_'] description = values['_DESCRIPTION_'] maintainer = values['_MAINTAINER_'] version = values['_MAINTAINER_'] controltemp = """Package: %s Name: %s Depends: %s Version: %s Architecture: iphoneos-arm Description: %s Maintainer: %s Author: %s Section: Tweaks""" % (packagename, projectname, dependencies, version, description, maintainer, authname) plisttemp = """{ Filter = { Bundles = ( "%s" ); }; }""" % appfilter makefiletemp = """ARCHS = arm64 include $(THEOS)/makefiles/common.mk TWEAK_NAME = %s %s_FILES = Tweak.xm include $(THEOS_MAKE_PATH)/tweak.mk after-install:: install.exec "killall -9 %s" """ % (projectname, projectname, killproc) plistname = buildpath + "/%s.plist" % projectname with open(plistname, 'w') as f: f.write(plisttemp) f.close() with open(buildpath + '/control', 'w') as f: f.write(controltemp) f.close() with open(buildpath + '/Makefile', 'w') as f: f.write(makefiletemp) f.close() with open(buildpath + "/Tweak.xm", "w") as f: f.write("Write your code here boi") f.close() if count == 1: gui.Window('Error', no_titlebar=True, keep_on_top=True, auto_close=True, auto_close_duration=1).Layout([[ gui.T('Error: Missing Filter! ', justification='center') ]]).Read() count = 0 elif count == 2: gui.Window('Error', no_titlebar=True, keep_on_top=True, auto_close=True, auto_close_duration=1).Layout([[ gui.T('Error: Missing Kill Process! ', justification='center') ]]).Read() count = 0 elif count == 3: gui.Window('Error', no_titlebar=True, keep_on_top=True, auto_close=True, auto_close_duration=1).Layout([[ gui.T('Error: Missing Build Path! ', justification='center') ]]).Read() count = 0 window.Close()
def theosgui(): nic_layout = [ [ gui.Text('Athena | Theos GUI', font=('Arial', 13, 'bold'), text_color=tcolor, justification='center') ], [ gui.Text('Developed by @maxbridgland', font=('Arial', 10, 'italic'), text_color=tcolor, justification='center') ], [ gui.T('New Tweak Creator', font=('Arial', 13, 'bold'), justification='center') ], [ gui.T('Project Name:', justification='left'), gui.InputText('ExampleTweak', text_color=itcolor, size=(20, 1), key='_PROJNAME_', justification='right') ], [ gui.T('Package Name:', justification='left'), gui.InputText('com.Athena.exampletweak', text_color=itcolor, size=(20, 1), key='_PACKNAME_', justification='right') ], [ gui.T('Author Name:', justification='left'), gui.InputText('AthenaTeam', text_color=itcolor, size=(20, 1), key='_AUTHNAME_', justification='right') ], [gui.Button('Create New Package')], [gui.Text('')], [gui.Text('_' * 100)], [gui.Text('')], [ gui.T('Tweak Compiler', font=('Arial', 13, 'bold'), justification='center') ], [ gui.T('Project Directory:', justification='left'), gui.InputText('C:\\Example\\Tweak\\Path', text_color=itcolor, size=(50, 1), key='_TWEAKPATH_', justification='right'), gui.FolderBrowse() ], [ gui.Checkbox('Install To Device (Required .bashrc setup) ', text_color=itcolor, key='_INSTALL_', default=False), gui.Checkbox('Clean Directory/Theos Cache', text_color=itcolor, key='_CLEAN_', default=True), gui.Checkbox('Final Package Flag', text_color=itcolor, key='_FINAL_', default=True) ], [ gui.T('Theos Device IP (Enter Only If Using Install To Device): ', justification='left'), gui.InputText('', text_color=itcolor, size=(20, 1), justification='center', key='_DEVIP_') ], [gui.Button('Build')], [gui.Button('Exit'), gui.Button('Donate')] ] window = gui.Window('Athena', no_titlebar=True, keep_on_top=True, grab_anywhere=True).Layout(nic_layout) count = 0 while True: event, values = window.Read() if event == 'Exit': window.Close() break elif event == 'Create New Package': if len(values['_PROJNAME_']) == 0: count += 1 if len(values['_PACKNAME_']) == 0: count += 1 if len(values['_AUTHNAME_']) == 0: count += 1 if count >= 1: gui.Window('Error', no_titlebar=True, keep_on_top=True, auto_close=True, auto_close_duration=1).Layout([[ gui.T('Error: Missing Value! ', justification='center') ]]).Read() createnewpkg(values['_PROJNAME_'], values['_PACKNAME_'], values['_AUTHNAME_']) elif event == 'Build': if values['_TWEAKPATH_'] == '': gui.Window('Error', no_titlebar=True, keep_on_top=True, auto_close=True, auto_close_duration=1).Layout([[ gui.T('Error: Missing Tweak Path! ', justification='center') ]]).Read() elif values['_TWEAKPATH_'] != '': path = values['_TWEAKPATH_'] if values['_INSTALL_'] == True: install = 'install' elif values['_INSTALL_'] == False: install = '' if values['_CLEAN_'] == True: clean = 'clean' elif values['_CLEAN_'] == False: clean = '' if values['_FINAL_'] == True: final = 'FINALPACKAGE=1' elif values['_FINAL_'] == False: final = '' query = "make %s package %s -C %s %s" % (clean, install, path, final) buildwindow(path, query) elif event == 'Donate': webbrowser.open_new_tab('https://paypal.me/AuxilumDevelopment')
old usage: yolo_video.py [-h] -i INPUT -o OUTPUT -y YOLO [-c CONFIDENCE] [-t THRESHOLD] """ # import the necessary packages import numpy as np import argparse import time import cv2 import os import PySimpleGUIQt as sg layout = [ [sg.Text('YOLO')], [sg.Text('Path to image'), sg.In(r'C:/Python/PycharmProjects/YoloObjectDetection/images/baggage_claim.jpg',size=(40,1), key='image'), sg.FileBrowse()], [sg.Text('Yolo base path'), sg.In(r'yolo-coco',size=(40,1), key='yolo'), sg.FolderBrowse()], [sg.Text('Confidence'), sg.Slider(range=(0,10),orientation='h', resolution=1, default_value=5, size=(15,15), key='confidence')], [sg.Text('Threshold'), sg.Slider(range=(0,10), orientation='h', resolution=1, default_value=3, size=(15,15), key='threshold')], [sg.OK(), sg.Cancel(), sg.Stretch()] ] win = sg.Window('YOLO', default_element_size=(14,1), text_justification='right', auto_size_text=False).Layout(layout) event, values = win.Read() args = values win.Close() # construct the argument parse and parse the arguments # ap = argparse.ArgumentParser() # ap.add_argument("-i", "--image", required=True,
def rename_dialog(src: str): import PySimpleGUIQt as sg ske = PySimpleGUISpecialKeyEvent() conf_file = real_join_path('~', '.config/rename_dialog.json') root = 'root' fname = 'fname' ext = 'ext' new_root = 'new_root' new_base = 'new_base' ok = 'OK' cancel = 'Cancel' pattern = 'pattern' replace = 'replace' substitute = 'substitute' save_replace = 'save_replace' save_pattern = 'save_pattern' add_root = 'add_root' title = 'Rename - {}'.format(src) h = .7 conf = read_json_file(conf_file, default={pattern: [''], replace: ['']}) tmp_pl = conf[pattern] or [''] tmp_rl = conf[replace] or [''] old_root, old_base = os.path.split(src) old_fn, old_ext = os.path.splitext(old_base) # sg.theme('SystemDefaultForReal') layout = [ [sg.T(src, key='src')], [sg.HorizontalSeparator()], [sg.I(old_root, key=root), sg.B('+', key=add_root, size=(3, h)), sg.FolderBrowse('...', target=root, initial_folder=old_root, size=(6, h))], [sg.I(old_fn, key=fname, focus=True), sg.I(old_ext, key=ext, size=(6, h))], [sg.HorizontalSeparator()], [sg.T('Regular Expression Substitution Pattern & Replacement')], [sg.T(size=(0, h)), sg.Drop(tmp_pl, key=pattern, enable_events=True, text_color='blue'), sg.CB('', default=True, key=save_pattern, enable_events=True, size=(2, h)), sg.Drop(tmp_rl, key=replace, enable_events=True, text_color='blue'), sg.CB('', default=True, key=save_replace, enable_events=True, size=(2, h)), sg.B('Go', key=substitute, size=(3, h))], [sg.HorizontalSeparator()], [sg.I(old_root, key=new_root)], [sg.I(old_fn + old_ext, key=new_base)], [sg.Submit(ok, size=(10, 1)), sg.Stretch(), sg.Cancel(cancel, size=(10, 1))]] ensure_sigint_signal() window = sg.Window(title, return_keyboard_events=True).layout(layout).finalize() window.bring_to_front() loop = True data = {fname: old_fn, ext: old_ext, pattern: tmp_pl[0], replace: tmp_rl[0], root: old_root, new_root: '', new_base: ''} @decorator_factory_exception_retry(Exception, 0, enable_default=True, default=None) def re_sub(): return re.sub(data[pattern], data[replace], data[fname] + data[ext]) while loop: dst_from_data = os.path.join(data[new_root], data[new_base]) try: tmp_fname = re_sub() or data[fname] + data[ext] dst = os.path.realpath(os.path.join(data[root], tmp_fname)) except TypeError: dst = src if dst != dst_from_data: nr, nb = os.path.split(dst) window[new_root].update(nr) window[new_base].update(nb) event, data = window.read() f = window.find_element_with_focus() for k in (root, fname, ext, new_root, new_base): window[k].update(text_color=None) cur_p = data[pattern] cur_r = data[replace] if event == ske.esc: loop = False elif event == add_root: os.makedirs(data[root], exist_ok=True) elif event == substitute: data[fname], data[ext] = os.path.splitext(re_sub() or data[fname] + data[ext]) window[fname].update(data[fname]) window[ext].update(data[ext]) elif event == save_pattern: if data[save_pattern]: conf[pattern].insert(0, cur_p) conf[pattern] = dedup_list(conf[pattern]) else: conf[pattern] = remove_from_list(conf[pattern], [cur_p]) elif event == save_replace: if data[save_replace]: conf[replace].insert(0, cur_r) conf[replace] = dedup_list(conf[replace]) else: conf[replace] = remove_from_list(conf[replace], [cur_r]) elif event == pattern: window[save_pattern].update(value=cur_p in conf[pattern]) elif event == replace: window[save_replace].update(value=cur_r in conf[replace]) elif event == ok: try: shutil.move(src, dst) loop = False except FileNotFoundError: for k in (root, fname, ext): window[k].update(text_color='red') except FileExistsError: for k in (new_root, new_base): window[k].update(text_color='red') except OSError as e: sg.PopupError(str(e)) elif event in (None, cancel): loop = False else: ... else: write_json_file(conf_file, conf, indent=0) window.close()
def get_settings(min_df_val, max_df_val, label_words_val, folder_val, stopwords_path): layout2 = [[sg.Text('Parameter Settings', font=("Ariel", 12))], [ sg.Text('min_df', size=(15, 1), font=("Ariel", 12)), sg.InputText(str(min_df_val), font=("Ariel", 12), key='min_df_val') ], [ sg.Text('max_df', size=(15, 1), font=("Ariel", 12)), sg.InputText(str(max_df_val), font=("Ariel", 12), key='max_df_val') ], [ sg.Text('Number of Label Words', size=(15, 1), font=("Ariel", 12)), sg.InputText(str(label_words_val), font=("Ariel", 12), key='label_words_val') ], [ sg.Txt('Output Folder:', size=(10, 1), font=("Ariel", 12)), sg.InputText(str(folder_val), size=(30, 1), font=("Ariel", 12), key='folder_val'), sg.FolderBrowse(font=("Ariel", 12)) ], [ sg.Txt('Stopwords file:', size=(10, 1), font=("Ariel", 12)), sg.InputText(str(stopwords_path), size=(30, 1), font=("Ariel", 12), key='stopwords_path'), sg.FileBrowse(font=("Ariel", 12)) ], [sg.Submit(font=("Ariel", 12)), sg.Cancel(font=("Ariel", 12))]] settingswdw = sg.Window('Settings', grab_anywhere=False, resizable=False).Layout(layout2) #settingswdw.Refresh() while True: # Event Loop event, values = settingswdw.Read() print(event, values) if event is None or event == 'Cancel': print('None or Exit event') break elif event == 'Submit': if not RepresentsInt(values['min_df_val']) or not RepresentsInt( values['max_df_val']) or not RepresentsInt( values['label_words_val']): sg.PopupError('Values must be integers, please correct.') elif not os.path.exists(folder_val) or not os.path.isdir( folder_val): sg.PopupError('Folder not valid, please correct.') elif not os.path.exists(stopwords_path) or not os.path.isfile( stopwords_path): sg.PopupError('Stopwords file not valid, please correct.') else: min_df_val = values['min_df_val'] max_df_val = values['max_df_val'] label_words_val = values['label_words_val'] folder_val = values['folder_val'] stopwords_path = values['stopwords_path'] #print('min_df_val: ' + min_df_val + ' max_df_val:' + max_df_val + ' label_words_val:' + label_words_val + ' output_folder_val: ' + folder_val) break print('min_df_val: ' + min_df_val + ' max_df_val:' + max_df_val + ' label_words_val:' + label_words_val + ' output_folder_val: ' + folder_val + ' stopwords_path: ' + stopwords_path) settingswdw.Close() return min_df_val, max_df_val, label_words_val, folder_val, stopwords_path
[ "Name::_tools_name_", "AFX::_tools_afx_", "Convert::_tools_convert_", "Export::_tools_export_", ], ], ["&Help", ["About"]], ] ### FORMS ### frm_layout_main = [ [ sg.Text("Directory: "), sg.InputText(key="_selected_dir_", default_text="", disabled=True), sg.FolderBrowse("Browse", key="_selected_dir_browse_", size=(8, 1)), ], [ sg.InputText(key="_backup_location_", visible=False, enable_events=True), sg.FolderBrowse("Backup", key="_main_backup_"), sg.InputText(key="_move_location_", visible=False, enable_events=True), sg.FolderBrowse("Move", key="_main_move_"), sg.InputText(key="_copy_location_", visible=False, enable_events=True), sg.FolderBrowse("Copy", key="_main_copy_"), sg.InputText(key="_zip_location_", visible=False, enable_events=True), sg.FolderBrowse("Zip", key="_main_zip_"), ], ] frm_layout_config = [[
def rename_dialog(src: str): import PySimpleGUIQt as G ske = PySimpleGUISpecialKeyEvent() conf_file = real_join_path('~', '.config/rename_dialog.json') root = 'root' fname = 'fname' ext = 'ext' key_new_root = 'key_new_root' key_new_base = 'key_new_base' ok = 'OK' cancel = 'Cancel' pattern = 'pattern' replace = 'replace' substitute = 'substitute' save_replace = 'save_replace' save_pattern = 'save_pattern' add_root = 'add_root' rename_info_file = 'rename_info_file' bytes_count = 'bytes_count' title = 'Rename - {}'.format(src) h = None conf = read_json_file(conf_file, default={pattern: [''], replace: ['']}) tmp_pl = conf[pattern] or [''] tmp_rl = conf[replace] or [''] old_root, old_base = os.path.split(src) old_fn, old_ext = os.path.splitext(old_base) info_file_base = [ f for f in os.listdir(old_root) if f.endswith('.info') and ( f.startswith(old_fn) or old_fn.startswith(f.rstrip('.info'))) ] has_info = True if info_file_base else False @deco_factory_retry(Exception, 0, enable_default=True, default=None) def re_sub(): return re.sub(data[pattern], data[replace], data[fname] + data[ext]) def count_name_bytes(name: str): d = {} try: c, b = encode_default_locale(name) d[c] = len(b) except UnicodeEncodeError: pass u8 = 'utf-8' if u8 not in d: try: c, b = encode_default_locale(name, u8) d[c] = len(b) except UnicodeEncodeError: pass return f'Basename Length: {len(name)}, {", ".join([f"{k.upper()} {v} bytes" for k, v in d.items()])}' # sg.theme('SystemDefaultForReal') layout = [[G.T(src, key='src')], [G.HorizontalSeparator()], [ G.I(old_fn, key=fname, focus=True), G.I(old_ext, key=ext, size=(42, h)) ], [ G.I(old_root, key=root), G.B('+', key=add_root, size=(20, h)), G.FolderBrowse('...', target=root, initial_folder=old_root, size=(20, h)) ], [G.HorizontalSeparator()], [G.T('Regular Expression Pattern & Replacement')], [ G.T(size=(0, h)), G.Drop(tmp_pl, key=pattern, enable_events=True, text_color='blue'), G.CB('', default=True, key=save_pattern, enable_events=True, size=(15, h)), G.Drop(tmp_rl, key=replace, enable_events=True, text_color='blue'), G.CB('', default=True, key=save_replace, enable_events=True, size=(15, h)), G.B('Go', key=substitute, size=(25, h)) ], [G.HorizontalSeparator()], [G.I(old_root, key=key_new_root)], [G.I(old_base, key=key_new_base)], [ G.Submit(ok, size=(10, 1)), G.Stretch(), G.T(count_name_bytes(old_base), key=bytes_count), G.Stretch(), G.Cancel(cancel, size=(10, 1)) ]] if has_info: info_file_base = info_file_base[0] info_filepath = os.path.join(old_root, info_file_base) with open(info_filepath, encoding='utf8') as f: info = f.read() layout.insert(2, [ G.CB(info_file_base, default=True, key=rename_info_file, enable_events=True) ]) layout.insert(2, [G.ML(info, key='ML')]) layout.insert(4, [G.HorizontalSeparator()]) ensure_sigint_signal() window = G.Window(title, layout, return_keyboard_events=True, finalize=True, font='arial 10', element_padding=(1, 1)) window.bring_to_front() ml = window.find_element('ML', silent_on_error=True) if ml: ml.update(readonly=True) loop = True data = { fname: old_fn, ext: old_ext, pattern: tmp_pl[0], replace: tmp_rl[0], root: old_root, key_new_root: '', key_new_base: '' } while loop: dst_from_data = os.path.join(data[key_new_root], data[key_new_base]) try: tmp_fname = re_sub() or data[fname] + data[ext] dst = os.path.realpath(os.path.join(data[root], tmp_fname)) except TypeError: dst = src if dst != dst_from_data: nr, nb = os.path.split(dst) window[key_new_root].update(nr) window[key_new_base].update(nb) window[bytes_count].update(count_name_bytes(nb)) event, data = window.read() for k in (root, fname, ext, key_new_root, key_new_base): window[k].update(text_color=None) cur_p = data[pattern] cur_r = data[replace] if event == ske.esc: loop = False elif event == add_root: os.makedirs(data[root], exist_ok=True) elif event == substitute: data[fname], data[ext] = os.path.splitext( re_sub() or data[fname] + data[ext]) window[fname].update(data[fname]) window[ext].update(data[ext]) elif event == save_pattern: if data[save_pattern]: conf[pattern].insert(0, cur_p) conf[pattern] = dedup_list(conf[pattern]) else: conf[pattern] = remove_from_list(conf[pattern], [cur_p]) elif event == save_replace: if data[save_replace]: conf[replace].insert(0, cur_r) conf[replace] = dedup_list(conf[replace]) else: conf[replace] = remove_from_list(conf[replace], [cur_r]) elif event == pattern: window[save_pattern].update(value=cur_p in conf[pattern]) elif event == replace: window[save_replace].update(value=cur_r in conf[replace]) elif event == ok: try: shutil.move(src, dst) if has_info: if data[rename_info_file]: shutil.move(info_filepath, os.path.splitext(dst)[0] + '.info') loop = False except FileNotFoundError: for k in (root, fname, ext): window[k].update(text_color='red') except FileExistsError: for k in (key_new_root, key_new_base): window[k].update(text_color='red') except OSError as e: G.PopupError(str(e)) elif event in (None, cancel): loop = False else: ... else: write_json_file(conf_file, conf, indent=0) window.close()
def _show_preferences(self): layout = [[sg.Text("Settings:")], [sg.Text("Speech recognition engine:"), sg.Drop(self._view_model.possible_engines, readonly=True, default_value=self._view_model.get_engine(), key=ENGINE_DROP, enable_events=True)], [sg.Text("Sound device:"), sg.Drop(self._view_model.get_sound_devices(), readonly=True, default_value=self._view_model.get_audio_device(), key=DEVICE_DROP)], [sg.Text("Result path:"), sg.In(disabled=True, key=PATH_INPUT, default_text=self._view_model.get_result_path()), sg.FolderBrowse()], [sg.Text("Engine specific settings:")], [sg.Text("API key:"), sg.In(key=KEY_INPUT, default_text=self._view_model.get_key(), password_char='*')], [sg.Text("Language:"), sg.Drop(self._view_model.possible_languages, key=LANGUAGE_DROP, default_value=self._view_model.get_language())], [sg.Text("Region (optional):"), sg.In(key=REGION_INPUT, default_text=self._view_model.get_region())], [sg.Button(APPLY_BUTTON)]] window = sg.Window("Preferences", layout) while True: event, values = window.read() if event == ENGINE_DROP: window.find_element(LANGUAGE_DROP).update(self._view_model.get_language(values[ENGINE_DROP])) window.find_element(REGION_INPUT).update(self._view_model.get_region(values[ENGINE_DROP])) window.find_element(KEY_INPUT).update(self._view_model.get_key(values[ENGINE_DROP])) elif event == APPLY_BUTTON: self._view_model.update_settings(values) break elif event == sg.WIN_CLOSED: break window.close()
sg.Text('№, №'), sg.InputText('1481', key='-REGNUMS-'), ]] ) ], [sg.Button('Настройки парсинга')], [ sg.Frame('Список банков', [[ sg.Listbox(values=[], select_mode=sg.LISTBOX_SELECT_MODE_MULTIPLE, key='-LISTBOX-') ]] ) ], [sg.Button('Взять данные'), sg.Text(' ' * 79), sg.Button('Удалить')], [ sg.Frame('Cохранение', [[ sg.FolderBrowse('Выберете папку', target='-PATH-'), sg.InputText(f'{dirname(__file__)}', key='-PATH-'), sg.Button('Сохранить') ]] ) ], [sg.ProgressBar(1000, orientation='h', key='progressbar')] ] win1 = sg.Window('101 форма', layout1) win2_active = False banks_data, banks_name = {}, {} dates = [] while True: try: ev1, val1 = win1.read(timeout=100)
sg.ChangeLookAndFeel('SystemDefaultForReal') layout = [ [sg.Stretch(), sg.T("COPIADOR DE ARQUIVOS"), sg.Stretch()], [ sg.T("ARQUIVOS:", tooltip='Local onde as pastas contendo os documentos estão.', size=(10, 1)), sg.I("", do_not_clear=True, size=(92, 1), key='Files', tooltip='Local onde as pastas contendo os documentos estão.'), sg.FolderBrowse("PASTA", size=(8, 1), tooltip='Procurar pasta.'), sg.Stretch() ], [ sg.T("EXTENSÃO:", tooltip='Local onde as pastas contendo os documentos estão.', size=(10, 1)), sg.I("", do_not_clear=True, size=(5, 1), key='Ext', tooltip='Local onde as pastas contendo os documentos estão.'), sg.T("(sem ponto, Ex: pdf)"), sg.Stretch() ], [
caffemodel = resource_path("colorization_release_v2.caffemodel") npyfile = resource_path("pts_in_hull.npy") sg.ChangeLookAndFeel('Reddit') sg.set_options(button_color=("0079d3", "0079d3"), button_element_size=(10, 1), text_justification="center") col1 = [[sg.T("IMAGEM:", size=(44, 1)), sg.I(size=(0, 0), visible=False, key="img", enable_events=True), sg.FileBrowse("SELECIONAR", file_types=(("Imagem", "*.png; *.jpg; *.jpeg"),), target="img")], [sg.Image(filename=resource_path("placeholder.png"), key="img_display")]] col2 = [[sg.T('RESULTADO:', size=(44, 1)), sg.I(size=(0, 0), visible=False, key="savefile", enable_events=True), sg.B("COLORIR", key="processar")], [sg.Image(filename=resource_path("placeholder.png"), key="img_display2", )]] tab1_layout = [[sg.Column(col1), sg.Column(col2)], [sg.Exit(key="EXIT"), sg.FileSaveAs("SALVAR", file_types=(("Imagem", "*.jpg"),), target='savefile', key="savefilebrowse", disabled=True, button_color=("black","grey"))]] tab2_layout = [[sg.T('PASTA:'), sg.I(key="pasta", size=(98,1)), sg.FolderBrowse()], [sg.B("COLORIR")], [sg.Exit(key="Exit")]] layout = [[sg.T("\t\t\t\t\tCOLORIZADOR DE FOTOS EM PRETO E BRANCO", font=("Arial 12 bold"))], [sg.TabGroup([[sg.Tab('COLORIR ARQUIVO ÚNICO', tab1_layout), sg.Tab('COLORIR LOTE', tab2_layout)]])]] window = sg.Window('Monografia do vértice genérica', layout, size=(1000, 700), auto_size_text=True, auto_size_buttons=False, resizable=False) FileIMG = None while True: event, values = window.read() if event is None or event == 'Exit' or event == 'EXIT': if os.path.isdir("./temp/"): shutil.rmtree("./temp/", ignore_errors=False, onerror=handleRemoveReadonly)
def open_file(filepath): if platform.system() == 'Darwin': # macOS subprocess.call(('open', filepath)) elif platform.system() == 'Windows': # Windows os.startfile(filepath) else: # linux variants subprocess.call(('xdg-open', filepath)) layout = [ [sg.Image("0.png", key="screenshot")], [ sg.Input("./data/chap28", key="folderPath", size=(50, 0.5)), sg.FolderBrowse(initial_folder=".", key="browseFolder", target="folderPath"), sg.Button("Analyze", key="analyze"), ], [ sg.Text('Capture frequency (s): '), sg.Input(5, key="delayTime", size=(3, 1), justification='center'), sg.Button("Record", key="recordBtn"), sg.Text('Current capture index:'), sg.Text("0", key="imgIdx"), ], [ sg.Text('Analyze progress', key='progressText'), sg.ProgressBar(100, key="progressbar", size=(5, 1)) ], ]