def strava_client_info_popup(): layout = [[sg.Text("Missing Strava Client info.\r\n" \ "Please get 'client_id' and 'client_secret' from Strava " \ "as described here:\r"\ "https://github.com/russery/pm-trainer#strava-api-access", (60,4))], [sg.T("client_id:", (15,1)), sg.I("", (6,1), key="-CLIENT-ID-", focus=True, tooltip="client_id")], [sg.T("client_secret:", (15,1)), sg.I("", (41,1), key="-CLIENT-SECRET-", tooltip="client_secret")], [sg.B("Save", key="-SAVE-", bind_return_key=True), sg.B("Cancel", key="-CANCEL-")]] window = sg.Window("Enter Strava Client Info", layout, use_ttk_buttons=True, modal=True, keep_on_top=True, finalize=True, element_padding=(5, 5)) while True: e, _ = window.read() if e in [sg.WIN_CLOSED, "-CANCEL-"]: window.close() return None, None elif e == "-SAVE-": client_id = window["-CLIENT-ID-"].get() client_secret = window["-CLIENT-SECRET-"].get() window.close() return client_id, client_secret
def save_previous_filename_demo(): """ Saving the previously selected filename.... A demo of one of the likely most popular use of user settings * Use previous input as default for Input * When a new filename is chosen, write the filename to user settings """ # Notice that the Input element has a default value given (first parameter) that is read from the user settings layout = [[sg.Text('Enter a filename:')], [ sg.Input(settings.get('-filename-', ''), key='-IN-'), sg.FileBrowse() ], [sg.B('Save'), sg.B('Exit Without Saving', key='Exit')]] window = sg.Window('Filename Example', layout) while True: event, values = window.read() if event in (sg.WINDOW_CLOSED, 'Exit'): break elif event == 'Save': settings['-filename-'] = values['-IN-'] window.close()
def about_window() -> sg.Window: """About window.""" items = ["coffee", "meal", "book"] selector = sg.Combo(items, "coffee", key="cmb.item") desc = ("Royale Tools is a clan management python application." "If you have any problem, open a new issue in GitHub!") info = [ [sg.T("Name: Royale Tools")], [sg.T("Author: Iago GR")], [sg.T(f"Version: {VERSION}")], ] layout = [ [ cw.F("Description", [[sg.T(desc, size=(30, 3), justification="c")]]) ], [cw.F("Project information", info), sg.B("GitHub")], [ cw.F("Donations", [[sg.T("Buy me a..."), selector, sg.B("PayPal")]]) ], [sg.B("\u2190")], ] return sg.Window(TITLE, layout)
def make_window(): """ Creates the main window :return: The main window object :rtype: (Window) """ theme = get_theme() if not theme: theme = sg.OFFICIAL_PYSIMPLEGUI_THEME sg.theme(theme) # First the window layout...2 columns find_tooltip = "Find in file\nEnter a string in box to search for string inside of the files.\nFile list will update with list of files string found inside." filter_tooltip = "Filter files\nEnter a string in box to narrow down the list of files.\nFile list will update with list of files with string in filename." find_re_tooltip = "Find in file using Regular Expression\nEnter a string in box to search for string inside of the files.\nSearch is performed after clicking the FindRE button." left_col = sg.Col([ [sg.Listbox(values=get_file_list(), select_mode=sg.SELECT_MODE_EXTENDED, size=(50, 20), key='-DEMO LIST-')], [sg.Text('Filter:', tooltip=filter_tooltip), sg.Input(size=(25, 1), enable_events=True, key='-FILTER-', tooltip=filter_tooltip), sg.T(size=(15,1), k='-FILTER NUMBER-')], [sg.Button('Run'), sg.B('Edit'), sg.B('Clear'), sg.B('Open Folder')], [sg.Text('Find:', tooltip=find_tooltip), sg.Input(size=(25, 1), enable_events=True, key='-FIND-', tooltip=find_tooltip), sg.T(size=(15,1), k='-FIND NUMBER-')], ], element_justification='l') lef_col_find_re = sg.pin(sg.Col([ [sg.Text('Find:', tooltip=find_re_tooltip), sg.Input(size=(25, 1),key='-FIND RE-', tooltip=find_re_tooltip),sg.B('Find RE')]], k='-RE COL-')) right_col = [ [sg.Multiline(size=(70, 21), write_only=True, key=ML_KEY, reroute_stdout=True, echo_stdout_stderr=True)], [sg.Button('Edit Me (this program)'), sg.B('Settings'), sg.Button('Exit')], [sg.T('PySimpleGUI ver ' + sg.version.split(' ')[0] + ' tkinter ver ' + sg.tclversion_detailed, font='Default 8', pad=(0,0))], ] options_at_bottom = sg.pin(sg.Column([[sg.CB('Verbose', enable_events=True, k='-VERBOSE-'), sg.CB('Show only first match in file', default=True, enable_events=True, k='-FIRST MATCH ONLY-'), sg.CB('Find ignore case', default=True, enable_events=True, k='-IGNORE CASE-')]], pad=(0,0), k='-OPTIONS BOTTOM-')) choose_folder_at_top = sg.pin(sg.Column([[sg.T('Click settings to set top of your tree or choose a previously chosen folder'), sg.Combo(sorted(sg.user_settings_get_entry('-folder names-', [])), default_value=sg.user_settings_get_entry('-demos folder-', ''), size=(50, 1), key='-FOLDERNAME-', enable_events=True, readonly=True)]], pad=(0,0), k='-FOLDER CHOOSE-')) # ----- Full layout ----- layout = [[sg.Text('PySimpleGUI Demo Program & Project Browser', font='Any 20')], [choose_folder_at_top], sg.vtop([sg.Column([[left_col],[ lef_col_find_re]], element_justification='l'), sg.Col(right_col, element_justification='c') ]), [options_at_bottom] ] # --------------------------------- Create Window --------------------------------- window = sg.Window('PSG Demo & Project Browser', layout, finalize=True, icon=icon) if not advanced_mode(): window['-FOLDER CHOOSE-'].update(visible=False) window['-RE COL-'].update(visible=False) window['-OPTIONS BOTTOM-'].update(visible=False) sg.cprint_set_output_destination(window, ML_KEY) return window
def decryptWindow(N=None, e=None, d=None): sg.theme('Dark Blue 3') layout = [[sg.T("Decrypt a Message")], [sg.Multiline(key="-MessIn-")], [sg.B("Decrypt Message")], [sg.T("Decrypt a File")], [sg.In(key="-FileName-"), sg.FileBrowse()], [sg.B("Decrypt File")]] window = sg.Window('RSA Encryptor', layout) rsaDecrypt = rsa.RSAObj(N=N, e=e, d=d) while True: event, values = window.read() if event == sg.WIN_CLOSED or event == 'Exit': rsaDecrypt.clearDictionaries() window.close() break if event == "Decrypt Message": rsaDecrypt.getMessage(values["-MessIn-"]) decryptedMess = rsaDecrypt.decrypteMess() layoutMess = [[sg.Multiline(default_text=decryptedMess)]] sg.Window('RSA Encryptor', layoutMess).read(close=True) elif event == "Decrypt File": pathIn = values["-FileName-"] fileName, isText, pathOut, dummy = getFileName(pathIn) rsaDecrypt.setPathIn(pathIn) rsaDecrypt.setPathOut(pathOut) if not isText: rsaDecrypt.setBinaryOn() rsaDecrypt.decryptFile(fileName) layoutMess = [[sg.Text("Decryption Successful!!!")]] sg.Window('RSA Encryptor', layoutMess).read(close=True)
def _upload_activity(config, logfile, workout): layout = [[sg.T("Upload activity to Strava?")], [sg.B("Strava Connect", key="-STRAVA-BTTN-"), sg.T("Auth status", (30,1), key="-STRAVA-AUTH-STATUS-")], [sg.Frame("Summary", layout=[ [sg.T("Distance", (24,1), key="-DIST-"), sg.T("Time", (24,1), key="-TIME-")], [sg.T("Activity Name:", (15,1)), sg.I(workout.name, text_color="gray", size=(40,1), key="-NAME-", metadata="default")], [sg.T("Description:", (15,1)), sg.I(workout.description, text_color="gray", size=(40,1), key="-DESC-", metadata="default")]])], [sg.B("Upload", key="-UPLOAD-", bind_return_key=True, disabled=True), sg.B("Discard", key="-DISCARD-")]] window = sg.Window("Upload Activity", layout=layout) window.finalize() # Update Strava status: strava_api = StravaApi(config) set_strava_status(window, strava_api) if strava_api.is_authed(): window["-UPLOAD-"].update(disabled=False) # Update workout info: time_s, distance_m = logfile.get_lap_stats() window["-DIST-"].update("Distance: {:4.1f}miles".format(float(distance_m)/1609.34)) window["-TIME-"].update("Time: {:4.0f} minutes".format(float(time_s)/60)) window.refresh() # Bind focus events on input boxes, to delete default value automatically for user window["-NAME-"].bind("<FocusIn>", "") window["-DESC-"].bind("<FocusIn>", "") while True: e, _ = window.read() if e in [sg.WIN_CLOSED, "-DISCARD-"]: if sg.PopupYesNo("Really discard this activity?") == "Yes": break elif e == "-STRAVA-BTTN-": handle_strava_auth_button(strava_api, config) config.write_settings(config.get("settingsfile")) set_strava_status(window, strava_api) if strava_api.is_authed(): window["-UPLOAD-"].update(disabled=False) elif e in ["-NAME-", "-DESC-"]: if window[e].metadata == "default": window[e].update(value="",text_color="White") window[e].metadata = "" elif e == "-UPLOAD-": try: StravaData(strava_api).upload_activity(activity_file=logfile.file_name, name=window["-NAME-"].get(), description=window["-DESC-"].get(), trainer=True, commute=False, activity_type="VirtualRide", gear_id="PM Trainer") sg.Popup("Uploaded successfully!") except StravaApi.AuthError as e: sg.Popup("Upload failed: \r\n{}".format(e.message)) break window.close()
def create_dump_data_window(settings, cfg_folder): """ dump data from CWP to XLS screen :param settings: (dict) :param cfg_folder: (string) """ 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) ] layout = [[ sg.T( 'Select checkbox and enter file names of output files to generate', size=(50, 1)) ], [ sg.Checkbox('Display listing to screen', default=True, key=tsl_func.DISPLAY_KEY) ], CheckboxFileSaveAs('TS Dump file', 'ts_dump', 'ts_dump.xlsx', cfg_folder), [sg.B('Ok'), sg.B('Exit')]] return sg.Window('e-Share Trusted Share Listing', layout)
def run(self): layout = [[sg.T("")], [sg.T("")], [ sg.T("Bienvenido a la Calculadora y Graficadora", font=self.font) ], [sg.T("")], [sg.T("")], [sg.B('Calculadora', font=self.font, focus=True)], [sg.B('Graficadora', font=self.font)], [sg.T("")], [sg.T("")], [sg.T("")], [sg.T("")], [sg.T("")], [sg.T("Por Bruno Martínez", font=self.font)], [sg.B("Salir", font=self.font)]] w, h = sg.Window.get_screen_size() window = sg.Window("Bienvenido", layout, size=(int(w / 2), int(h / 2)), element_justification='c') while True: event, values = window.read() if event in (sg.WIN_CLOSED, None, 'Salir'): # always, always give a way out! window.close() break if event == "Calculadora": window.close() self.run_calc() break if event == "Graficadora": window.close() self.run_graf() break window.close()
def create_window(): """ Defines the window's layout and creates the window object. This function is used so that the window's theme can be changed and the window "re-started". :return: The Window object :rtype: sg.Window """ left_col = [[sg.T('Figures to Draw')], [ sg.Listbox(list(dictionary_of_figures), default_values=[list(dictionary_of_figures)[0]], size=(15, 5), key='-LB-') ], [sg.T('Matplotlib Styles')], [sg.Combo(plt.style.available, size=(15, 10), key='-STYLE-')], [sg.T('PySimpleGUI Themes')], [ sg.Combo(sg.theme_list(), default_value=sg.theme(), size=(15, 10), key='-THEME-') ]] layout = [[sg.T('Matplotlib Example', font='Any 20')], [sg.Col(left_col), sg.Image(key='-IMAGE-')], [sg.B('Draw'), sg.B('Exit')]] window = sg.Window('Matplotlib Embedded Template', layout, finalize=True) return window
def main(): dictionary_of_figures = { 'Axis Grid': create_axis_grid, 'Subplot 3D': create_subplot_3d, 'Scales': create_pyplot_scales, 'Basic Figure': create_figure } layout = [[sg.T('Matplotlib Example', font='Any 20')], [ sg.Listbox(list(dictionary_of_figures.keys()), size=(15, 5), key='-LB-'), sg.Image(key='-IMAGE-') ], [sg.B('Draw'), sg.B('Exit')]] window = sg.Window('Title', layout) image_element = window['-IMAGE-'] # type: sg.Image while True: event, values = window.read() print(event, values) if event == 'Exit' or event == sg.WIN_CLOSED: break if event == 'Draw': func = dictionary_of_figures[values['-LB-'][0]] draw_figure(image_element, func()) window.close()
def main(): udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) layout = [[ sg.Multiline("", size=(90, 20), k="content", disabled=True, autoscroll=True), sg.Multiline("", size=(10, 10), k="tip", disabled=True) ], [sg.Multiline("", size=(45, 5), k="-in-")], [sg.B("发送"), sg.B("退出"), sg.B("skip")]] window = sg.Window('client', layout, return_keyboard_events=True) t1 = threading.Thread(target=recv, args=(udp_socket, window)) t1.start() global content content = "" while True: event, value = window.read() if event == '发送' or event == '\r': udp_socket.sendto( value["-in-"].replace('\n', '').replace('\r', '').encode(CODE), (CLIENT_HOST, PORT)) window['tip'].update("已发送,等待回复") content += "【发送】" + value['-in-'].replace('\n', '').replace( '\r', '') + "\n" window['content'].update(content) window['-in-'].update("") print("【发送】:" + value["-in-"].replace('\n', '').replace('\r', '')) if event == '退出' or event == sg.WINDOW_CLOSED: udp_socket.sendto("exit".encode(CODE), (SERVER_HOST, PORT)) exit()
def app(): sg.theme('DarkAmber') blocks = [[sg.B('example1', key='ex1')], [sg.B('example2', key='ex2')], [sg.B('example3', key='ex3')], [sg.B('many random points', key='ex4')], [sg.Canvas(key='controls_cv')], [sg.Column(layout=[[sg.Canvas(key='fig_cv', size=(500 * 2, 700))]], pad=(0, 0))]] window = sg.Window('Fedchenko labOG', blocks) while True: event, values = window.read() if event == sg.WIN_CLOSED: break elif event == 'ex1': points = [[0, 0], [1, 3], [4, 1], [3, 2], [4, 3]] poly = [[1, 2], [3, 3], [4, 4], [5, 2], [3, 1], [1, 2]] inside_points = [] for p in points: if algo.ray_tracing_method(p[0], p[1], poly): inside_points.append(p) fig, ax = draw_plot(poly, points, inside_points) xs, ys = get_bottom_point(points) ax.text(xs - 1, ys - 0.5, ("Points inside the poly:", inside_points), fontsize=10) draw_polynom(window['fig_cv'].TKCanvas, fig, window['controls_cv'].TKCanvas) elif event == 'ex2': points = [[0, 0], [1, 3], [4, 0.5], [3, 2], [4, 3]] poly = [[1, 2], [5, 4], [7, 4], [10, 4], [9, 3], [8, 2], [6, 1], [2, 1], [1, 2]] inside_points = [] for p in points: if algo.ray_tracing_method(p[0], p[1], poly): inside_points.append(p) fig, ax = draw_plot(poly, points, inside_points) xs, ys = get_bottom_point(points) ax.text(xs - 1, ys - 0.5, ("Points inside the poly:", inside_points), fontsize=10) draw_polynom(window['fig_cv'].TKCanvas, fig, window['controls_cv'].TKCanvas) elif event == 'ex3': points = [[0, 0], [1, 3], [4, 0.5], [2, 2], [4, 3], [-1, 2]] poly = [[-1, -1], [-2, 2], [1, 4], [3, 0], [1, -1], [-1, -1]] inside_points = [] for p in points: if algo.ray_tracing_method(p[0], p[1], poly): inside_points.append(p) fig, ax = draw_plot(poly, points, inside_points) xs, ys = get_bottom_point(points) ax.text(xs - 2, ys - 2, ("Points inside the poly:", inside_points), fontsize=10) draw_polynom(window['fig_cv'].TKCanvas, fig, window['controls_cv'].TKCanvas) elif event == 'ex4': random_points = [] for i in range(2000): random_points.append([random.uniform(-1.0, 12.0), random.uniform(-1.0, 6.0)]) poly = [[1, 2], [5, 4], [7, 4], [10, 4], [9, 3], [8, 2], [6, 1], [2, 1], [1, 2]] inside_points = [] for p in random_points: if algo.ray_tracing_method(p[0], p[1], poly): inside_points.append(p) fig, ax = draw_plot(poly, random_points, inside_points) xs, ys = get_bottom_point(random_points) ax.text(xs - 2, ys - 2, ("Points inside the poly:", inside_points), fontsize=10) draw_polynom(window['fig_cv'].TKCanvas, fig, window['controls_cv'].TKCanvas) window.close()
def main(): # --------- Define layout and create Window ------- layout = [ [sg.Text('User Exec API Demo', font='_ 18')], [sg.T(sg.main_get_debug_data(True))], [sg.T('Python Version', text_color='yellow'), sg.T(f'{sg.sys.version_info.major}.{sg.sys.version_info.minor}.{sg.sys.version_info.micro}', text_color = 'yellow')], [sg.B('Global Settings'), sg.B('Relaunch'), sg.B('Main'), sg.B('Refresh'), sg.Exit()], ] window = sg.Window('Execute Py File Demo', layout, keep_on_top=True, font='_ 14') # --------- Event Loop ------- while True: event, values = window.read() if event in (sg.WIN_CLOSED, 'Exit'): break if event.startswith('Global'): sg.main_global_pysimplegui_settings() elif event == 'Relaunch': sg.execute_py_file(__file__) # Run using Global Settings to determine which python version to use elif event == 'Main': sg.main() # --------- After event loop --------- window.close()
def merge_window(): """window for merging experiments. will deal with either root growth or germination data, but not both at the same time.""" # the table of experiments explist = [[ sg.Table(headings=[ 'Experiments', ], display_row_numbers=False, auto_size_columns=False, values=list([]), def_col_width=65, num_rows=8, key='-EXPERIMENTS-', select_mode=sg.TABLE_SELECT_MODE_BROWSE) ], [sg.B('Remove experiment', key='Remove')]] # rest of ui addexp = [[ sg.T('Folder:'), sg.I(key='exp', size=(45, 1)), sg.FolderBrowse(), sg.B('Add') ]] layout = [[sg.Frame('Merge experiments', layout=explist)], [sg.Frame('Add experiment', layout=addexp)], [sg.B('Perform Merge', key='Merge'), sg.B('Exit')]] return sg.Window('Merge', layout=layout, grab_anywhere=False, icon=icon)
def main(): """ Every time "Start A Thread" is clicked a new thread is started When the event is received from the thread, a popup is shown in its behalf """ layout = [ [sg.Output(size=(60,10))], [sg.T('How often a thread will show a popup in seconds'), sg.Spin((2, 5, 10, 20), initial_value=5, k='-SPIN-')], [sg.B('Start A Thread'), sg.B('Dummy'), sg.Button('Exit')] ] window = sg.Window('Window Title', layout, finalize=True, font='_ 15') while True: # Event Loop event, values = window.read() print(event, values) if event == sg.WIN_CLOSED or event == 'Exit': break if event == '-POPUP-': sg.popup_non_blocking('This is a popup that the thread wants to show', *values['-POPUP-']) elif event == 'Start A Thread': print(f'Starting thread. You will see a new popup every {values["-SPIN-"]} seconds') threading.Thread(target=the_thread, args=(window, values['-SPIN-']), daemon=True).start() window.close()
def logintWindow(): event, values = sg.Window('Login Window', [[sg.T(text='Email:', size=(8, 1)), sg.In(key='Email'), ], [sg.T(text="Passwort:", size=(8, 1)), sg.In(key="psd", password_char="*")], [sg.Checkbox(text=" Zugangsdaten speichern", key="speichern")], [sg.B('OK'), sg.B('Cancel')]]).read(close=True) print(values)
def next_screen(username): window = sg.Window( 'Next Window', [[sg.T(username)], [sg.B('OK'), sg.B('Skip'), sg.Exit()]], size=WINDOW_SIZE) return window
def choose_locations(locations, chosen_locations): locations = list(locations) if not chosen_locations: defaults = DEFAULT_LOCATIONS else: defaults = chosen_locations max_col = 7 row = [] cb_layout = [] for i, location in enumerate(sorted(locations)): row.append(sg.CB(location, size=(15,1), pad=(1,1), font='Any 9', key=location, default=True if location in defaults else False)) if (i+1) % max_col == 0: cb_layout += [row] row = [] cb_layout += [row] layout = [[sg.T('Choose Locations (max 8)')]] layout += cb_layout layout += [[sg.B('Ok', border_width=0, bind_return_key=True), sg.B('Cancel', border_width=0)]] window = sg.Window('Choose Locations', layout, keep_on_top=True, border_depth=0) event, values = window.read() window.close() if event == 'Ok': locations_selected = [] for key in values.keys(): if values[key]: locations_selected.append(key) else: locations_selected = chosen_locations return locations_selected
def settings_window(): """ Show the settings window. This is where the folder paths and program paths are set. Returns True if settings were changed :return: True if settings were changed :rtype: (bool) """ layout = [[sg.T('Program Settings', font='DEFAIULT 18')], [sg.T('Path to Demos', size=(20,1)), sg.In(sg.user_settings_get_entry('-demos folder-', '.'), k='-DEMOS-'), sg.FolderBrowse()], [sg.T('Editor Program', size=(20,1)), sg.In(sg.user_settings_get_entry('-Editor Program-', ''),k='-EDITOR PROGRAM-'), sg.FileBrowse()], [sg.T(r"For PyCharm, Add this to your PyCharm main program's folder \bin\pycharm.bat")], [sg.Combo(sg.theme_list(), sg.user_settings_get_entry('-theme-', None), k='-THEME-')], [sg.B('Ok', bind_return_key=True), sg.B('Cancel')], ] window = sg.Window('Settings', layout) event, values = window.read(close=True) if event == 'Ok': sg.user_settings_set_entry('-demos folder-', values['-DEMOS-']) sg.user_settings_set_entry('-Editor Program-', values['-EDITOR PROGRAM-']) sg.user_settings_set_entry('-theme-', values['-THEME-']) return True return False
def postqc_window(uid_groups, avail_groups): """main interface. uid_groups is a list of [UID, Group] combinations. avail_groups is a list of the available groups. returns the main window object.""" table_height = min(25, len(uid_groups)) mgmt_layout = [[sg.B('Add New Group', key='Add')], [ sg.B('Assign Seedling to Group', key='Change'), sg.B('Exclude Seedling from Analysis', key='Exclude') ]] layout = [[ sg.Table(values=uid_groups, headings=['UID', 'Group'], display_row_numbers=False, auto_size_columns=True, num_rows=table_height, key="-COMBOS-"), sg.Table(values=avail_groups, headings=[ 'Available groups', ], display_row_numbers=False, auto_size_columns=True, num_rows=table_height, key="-GROUPS-", select_mode=sg.TABLE_SELECT_MODE_BROWSE) ], [sg.Frame('Seedling and Group Management', layout=mgmt_layout)], [ sg.Sizer(h_pixels=120), sg.B('Write PostQC File', key='Write'), sg.B('Exit') ]] return sg.Window('SPIRO Assay Customizer', layout, grab_anywhere=False, icon=icon)
def create_login(conn): """ Creates a login screen :param conn: Connection object to SQLite DB :return: event (string for what happened on the screen), values (dictionary with GUI element values at time of event) """ column1 = [[sg.T('Username:'******'-ID-')], [sg.T('Password:'******'-Password-', password_char='*')], [sg.B('Login'), sg.B('Exit')], [ sg.T('Incorrect username or password', key='-Error-', text_color='Red', visible=False) ]] columns = [ sg.Column(column1, vertical_alignment='center', justification='center', element_justification='center', k='-COLUMN1-') ] layout, window = create_window(columns, 'LOGIN') while True: event, values = window.read() if event == 'Login': # Successful login if attempt_login(values['-ID-'], values['-Password-'], conn) == 1: # Load our data load_fetal_data(conn) load_model() # Update current_user, and log event to User Log set_current_user(values['-ID-']) dirname = Path(__file__).parent.absolute() user_filepath = Path(dirname, 'user_log').with_suffix('.txt') f = open(user_filepath, 'a') f.write('{} logged in at {}\n'.format(values['-ID-'], datetime.datetime.now())) f.close() values['-Password-'] = None window.close() return event, values # Unsuccessful login else: window['-Error-'].update(visible=True) elif event == "Exit" or event == sg.WIN_CLOSED: window.close() return event, values
def create_main_window(settings): layout = [[sg.T('Yolo automation training')], [sg.T('Change settings or start this app')], [sg.B('Exit'), sg.B('Change Settings'), sg.B('Start')]] return sg.Window('Main Application', layout)
def prolongar(): layout = [[sg.T("Dias"), sg.Input()], [sg.B("Confirmar"), sg.B("Cancelar")]] window = sg.Window('Prolongar', layout) data = window.read(close=True) if not data or data[0] == 'Cancelar': return value = data[1][0] return int(value)
def create_main_window(settings): sg.theme(settings['theme']) layout = [[sg.T('This is my main application')], [sg.T('Add your primary window stuff in here')], [sg.B('Ok'), sg.B('Exit'), sg.B('Change Settings')]] return sg.Window('Main Application', layout)
def InVar(key1): row1 = [ sg.T(' '), sg.I(key=key1, size=(WIDTH_VARIABLES, 1)), sg.T('', key=key1 + 'CHANGED_', size=(WIDTH_RESULTS, 1)), sg.B('Detail', key=key1 + 'DETAIL_'), sg.B('Obj', key=key1 + 'OBJ_'), ] return row1
def main(): MLINE_KEY = '-MLINE-' + sg.WRITE_ONLY_KEY layout = [[ sg.Text( 'Demonstration of Multiline Element\'s ability to show multiple colors ' ) ], [ sg.Multiline(size=(60, 20), disabled=True, autoscroll=False, key=MLINE_KEY) ], [ sg.B('Plain'), sg.Button('Text Blue Line'), sg.Button('Text Green Line') ], [ sg.Button('Background Blue Line'), sg.Button('Background Green Line'), sg.B('White on Green') ]] window = sg.Window('Demonstration of Multicolored Multline Text', layout) # Make all prints output to the multline in Red text print = lambda *args, **kwargs: window[MLINE_KEY].print( *args, **kwargs, text_color='red') while True: event, values = window.read() # type: (str, dict) if event in (None, 'Exit'): break print(event, values) if 'Text Blue' in event: window[MLINE_KEY].print('This is blue text', text_color='blue', end='') if 'Text Green' in event: window[MLINE_KEY].print('This is green text', text_color='green') if 'Background Blue' in event: window[MLINE_KEY].print('This is Blue Background', background_color='blue') if 'Background Green' in event: window[MLINE_KEY].print('This is Green Background', background_color='green') if 'White on Green' in event: window[MLINE_KEY].print('This is white text on a green background', text_color='white', background_color='green') if event == 'Plain': window[MLINE_KEY].print( 'This is plain text with no extra coloring') window.close()
def main_GUI(): layout = [[sg.T('Choose an action:')], [sg.B("Crop Background")], [sg.B("Sort By Direction")]] window = sg.Window('BgCrop V1.3', layout) event, values = window.read() window.close() return event, values
def create_main_window(settings): sg.theme(settings['theme']) layout = [ [sg.Menu([['File', ['Open']], ['Edit', ['Settings'], ],['Help', 'About...'],])], [sg.T('This is my main application')], [sg.T('Add your primary window stuff in here')], [sg.B('Ok'), sg.B('Exit'), sg.B('Change Settings')]] return sg.Window('Main Application', layout)
def menu(opts, voltar='Voltar'): layout = [ [sg.B(element)] for index, element in enumerate(opts) ] + [[sg.B(voltar)]] window = sg.Window("Painel Geral", layout) data = window.read(close=True)[0] if data is None or data == voltar: return None else: return opts.index(data)
def b_one_shot(my_theme=DEFAULT_THEME): simpleGUI.theme(my_theme) event, values = simpleGUI.Window( 'Login Win', [[simpleGUI.T('Enter your login ID'), simpleGUI.In(key='-ID-')], [simpleGUI.B('OK'), simpleGUI.B('Cancel')]]).read(close=True) login_id = values['-ID-'] print(login_id)