def validateInputBase(inp: Gui.Input) -> bool: val = str(inp.get()) result = __testInputForInt(val) if result: val = int(val) result = 0 < val <= MAX_BASE __markInputAs(inp, result) return result
def Signup(self): signup_active = True layout = [ [T("Signup for Xpnsit", **heading_format), ], [T("First Name:"), Input(size=(15, 1), key="f_name"), T( " "), T("Last Name:"), Input(size=(15, 1), key="l_name")], [T("Username:"******"user")], [T("Password:"******"pass", password_char="*")], [], [T(' '*40), Submit()] ] signup_win = Window("Xpnsit - Signup", layout=layout) while signup_active: # <------------ Event Loop -----------------> # event, values = signup_win.Read() if event in (None, 'Exit'): signup_active = False login_active = True if event == 'Submit': self.vals = [values["user"], values["pass"], values["mail"], values["f_name"], values["l_name"]] if not username_used(self.vals[0]): create_account(*self.vals) # <------------------- Confirmation of Insertion ------------------> # success = check_login_info(values["user"], values["pass"]) if success == True: print("Signup Successful.") Popup( "Signup Successful!", "Exit this popup to return to the login page" ) signup_win.close() signup_active = False login_active = True else: PopupError("ERROR: Username already in usage", title="Username already taken")
def Login(self): login_active = True layout = [ [T("Xpnsit", **heading_format)], [T("Username:"******"user")], [T("Password:"******"pass", password_char='*')], [Button("Login", bind_return_key=True), Button("Signup")] ] win = Window("Xpnsit", layout=layout) while login_active: # <------------ Event Loop -----------------> # event, values = win.Read() if event is None: print("Exiting event loop") login_active = False self.app_state = False win.close() del win break if event == "Login": success = check_login_info(values["user"], values["pass"]) if success == True: print("Login Successful.") self.user_details = get_user_details(values["user"]) self.user = NewUser(*self.user_details) win.close() self.Interface() login_active = False else: PopupError( "ERROR: Username or password incorrect.\nPlease try again.") if event == "Signup": self.Signup()
def Analytics(self): fig, w, h = get_graph_values() analysis_layout = [ [T("Analytics", font=("Helvetica", 18))], [T("Here you can find and generate graphs for your desired timeframe\nand observe trends in your balance.")], [T("Generate for records from "), Input(f"{year}-{month}-1", key="a_start_date", size=(10, 1)), CalendarButton("Start date", target="a_start_date", default_date_m_d_y=( month, 1, year), button_color=("white", "green"), format="%Y-%m-%d"), T("to"), Input(f"{year}-{month}-{day}", key="a_end_date", size=(10, 1)), CalendarButton("End date", target="a_end_date", default_date_m_d_y=( month, day, year), button_color=("white", "red"), format="%Y-%m-%d") ], [T("Type:"), Combo(["All", "Credit", "Debit"], default_value="All", key="a_type", readonly=True)], [Button("Generate", button_color=("white", "orange"))], [Canvas(size=(w, h), key="canvas")] ] return analysis_layout
def History(self): history_values, table, no_of_records = get_transactions( self.user.uname) self.slider = sg.Slider( range=(0, no_of_records), default_value=no_of_records, orientation='h', enable_events=True, key='slider' ) layout = [ [T("Transaction History", font=("Helvetica", 18))], [T("All your transactions, in one place. Right click any one to delete or edit it.")], [T('Number of records to be shown:'), self.slider], [T("Show records from "), Input(f"{year}-{month}-1", key="start_date", size=(10, 1)), CalendarButton("Start date", target="start_date", default_date_m_d_y=( month, 1, year), button_color=("white", "green"), format="%Y-%m-%d"), T("to"), Input(f"{year}-{month}-{day}", key="end_date", size=(10, 1)), CalendarButton("End date", target="end_date", default_date_m_d_y=( month, day, year), button_color=("white", "red"), format="%Y-%m-%d") ], [T("Type:"), Combo(["All", "Credit", "Debit"], default_value="All", key="used_type", readonly=True)], [T("Sort by:"), Combo(["Name", "Amount", "Date of Transaction"], default_value="Name", key="sort_by", readonly=True), Combo(["Ascending", "Descending"], default_value="Ascending", key="asc_or_desc", readonly=True)], [table, Button("Refresh", button_color=( "white", "orange"), bind_return_key=True, key="refresh")], ] self.history_active = True return layout
def setLayout(): layout = [[ sg.Text(' Atividades para a semana', size=(25, 1), justification='center', font=("Verdana", "10", "bold")) ], [ sg.Text('Atividade:', size=(10, 1), justification='right'), sg.I(key='-ATIVIDADE-', do_not_clear=False) ], [ sg.T('Tempo:', size=(10, 1), justification='right'), sg.I(key='-TEMPO-', do_not_clear=False) ], [ sg.T('Prioridade:', size=(10, 1), justification='right'), sg.I(key='-PRIORIDADE-', do_not_clear=False) ], [ sg.T(' ' * 5), sg.Button('Inserir'), sg.Button('Pomodoro'), sg.Button('Agendar') ], [ sg.T(key='-MESSAGE-', size=(30, 1), font=("Verdana", "9", "italic")) ]] layout += [[Text('Progresso', justification='Left', font="Verdana 10")]] # a title line t try: layout += [[Text(f'{i+1}. '), CBox(''), sg.I(data['Task'][i])] for i in range(len(data['Task'])) ] # the checkboxes and descriptions except: layout += [[Text(f'{i}. '), CBox(''), Input()] for i in range(1, 6)] # the checkboxes and descriptions window = sg.Window('Cardeal Assist', layout, font='Calibri 10', default_element_size=(25, 1)) return window
# PyBeep, the GUI program nobody asked for! Made by George Brellas. # Frequency range: 37hz - 32767hz (This is a limitation set by the winsound module) from PySimpleGUI import Button, Column, Slider, Input, Text, Window from winsound import Beep col1 = [[ Button("Beep!", tooltip="Beeps! :)"), Text("Step:", tooltip="Frequency to lower/raise by"), Input(default_text="50", do_not_clear=True, key="Step", tooltip="Frequency to lower/raise by", size=(5, 5)), Text("MS:", tooltip="Milliseconds to beep for"), Input(default_text="1000", do_not_clear=True, key="Time", tooltip="Milliseconds to beep for", size=(5, 5)) ], [ Slider(range=(37, 32767), orientation='h', default_value=10000, key="Beep", tooltip="Current frequency") ], [ Button("-", key="Lower", tooltip="Lower frequency", size=(1, 1)), Button("+", key="Raise", tooltip="Raise frequency", size=(1, 1)) ]]
def __init__(self): self.window = Window('Autenticação de Usuário').layout( [[Text('Informe sua matrícula: ')], [Input(key='matricula')], [Button('Ok!')]])
# -*- coding: utf-8 -*- """ Created on Mon Mar 12 10:01:01 2019 @author: Girvan Tse I have regrets tbh """ import re from PySimpleGUI import Text, FileBrowse, FolderBrowse, Input, OK, Cancel, Window, Popup, Button, Column from CompySame import compareAll from pandas import ExcelWriter, DataFrame, read_excel, concat from xlrd import XLRDError layout1 = [[Text('How many files would you like to compare?')], [Input('#', key='numFiles')], [Button('Next', key='toLayout2'), Button('Cancel', key='exit')]] layout2 = [] layout3 = [[Text('Where would you like the export to be put')], [Input('Path'), FolderBrowse(key='exportPath')], [Button('Finish', key='export'), Button('Cancel', key='exit')]] def validate(file): try: testParam = read_excel(file[0], sheet_name=file[1]) testParam[file[2]] except FileNotFoundError:
), Radio("Software", "radio1", key="-SOFTWARE-", size=(10, 1)), ]], ) ], # Information frame [ Frame( "Information:", [[ Text(), Column( [ [Text("Account:")], [Input(key="-ACCOUNT-IN-", size=(19, 1))], [Text("User Id:")], [ Input(key="-USERID-IN-", size=(19, 1)), Button("Copy", key="-USERID-"), ], [Text("Password:"******"-PW-IN-", size=(19, 1)), Button("Copy", key="-PASS-"), ], [Text("Location:")], [ Input(key="-LOC-IN-", size=(19, 1)), Button("Copy", key="-LOC"), ],
"*.xlsx"), ("ALL Files", "*.*"))) openManyFilesButton = FilesBrowse('Select multiple files', target="files", file_types=(("Text Files", "*.txt"), ("Excel Files", "*.xlsx"), ("ALL Files", "*.*"))) #The first tab is for direct text entry. It has a big text box, a button, and a 2*6 grid for results + labels output_values = [[ Text('Moral Trait', size=(20, 1)), Text('Trait present', size=(36, 1)), Text('Trait avg.', size=(35, 1)) ], [ Text('Care/Harm', size=(20, 1)), Input('0', key='care_result', size=(35, 1)), Input('0', key='care_avg', size=(35, 1)) ], [ Text('Fairness/Cheating', size=(20, 1)), Input('0', key='fairness_result', size=(35, 1)), Input('0', key='fairness_avg', size=(35, 1)) ], [ Text('Loyalty/Betrayal', size=(20, 1)), Input('0', key='loyalty_result', size=(35, 1)), Input('0', key='loyalty_avg', size=(35, 1)) ], [ Text('Authority/Subversion', size=(20, 1)), Input('0', key='authority_result', size=(35, 1)),
def __build_import_ui(self): return Frame(title='Import', layout=[[Text('Filename')], [Input(), FilesBrowse()], [OK(key=self.IMPORT)]])
def __markInputAs(inp: Gui.Input, valid: bool): if valid: layout.resetInputColor(inp) else: inp.update(background_color="#f2506b")
def start(): Gui._info_text = Text(background_color='#101010', font=(None, 18, 'italic'), justification='c', key='info_text', border_width=8, size=(24, 1), text='Enter sensor address') Gui._address_input = Input(default_text='192.168.0.', key='address_input', size=(16, 1)) Gui._load_button = Button(bind_return_key=True, button_text='Load', key='load_button', size=(6, 1)) Gui._file_list = Listbox(values=(), background_color='#e0e4f0', enable_events=True, highlight_background_color='#a0c0e0', highlight_text_color='#000000', key='file_list', select_mode=PySimpleGUI.SELECT_MODE_MULTIPLE, size=(28, 12), text_color='#202020') Gui._selection_text = Text(background_color='#101010', font=(None, 14, 'italic'), justification='c', key='selection_text', size=(24, 1), text_color='#808080') Gui._select_all_button = Button(button_text='Select All', disabled=True, key='select_all_button', size=(12, 1)) Gui._deselect_all_button = Button(button_text='Deselect All', disabled=True, key='deselect_all_button', size=(12, 1)) Gui._retrieve_button = PySimpleGUI.FolderBrowse(button_text='Retrieve', disabled=True, key='retrieve_button', size=(12, 1), target='retrieve_button_handle') # FolderBrowser is buggy at reporting events Gui._retrieve_button_handle = Button(enable_events=True, key='retrieve_button_handle', visible=False) Gui._delete_button = Button(button_text='Delete', disabled=True, key='delete_button', size=(12, 1)) Gui._is_element_disabled = { x: False for x in (Gui._address_input, Gui._load_button, Gui._file_list, Gui._select_all_button, Gui._deselect_all_button, Gui._retrieve_button, Gui._delete_button) } Gui._window = Window(background_color='#101010', element_justification='c', element_padding=(9, 9), font=(None, 16), layout=( (Gui._info_text,), (Gui._address_input, Gui._load_button), (Gui._file_list,), (Gui._selection_text,), (Gui._select_all_button, Gui._deselect_all_button), (Gui._retrieve_button, Gui._delete_button), (Gui._retrieve_button_handle,), ), margins=(48, 48), title='Retrieve Data From Sensor') Gui._window.finalize() Gui._address_input.update(select=True) Gui._address_input.set_focus(True) while True: event, values = Gui._window.read() if event == PySimpleGUI.WIN_CLOSED: break Gui._address_input_value = values['address_input'] Gui._file_list_selection = values['file_list'] Gui._retrieve_button_selection = values['retrieve_button'] if event == 'load_button': Gui._handle_load_button_clicked() elif event == 'file_list': Gui._handle_file_list_selected() elif event == 'select_all_button': Gui._handle_select_all_button_clicked() elif event == 'deselect_all_button': Gui._handle_deselect_all_button_clicked() elif event == 'retrieve_button_handle': Gui._handle_retrieve_button_selected() elif event == 'delete_button': Gui._handle_delete_button_clicked() else: print('Unhandled:', event, values)
def __init__(self): self.window = Window('Avaliação de filme').layout( [[Text('Nota'), Input(key='nota')], [Text('Comentário'), Input(key='comentario')], [Button('Voltar'), Button('Avaliar')]])
def __init__(self): self.window = Window('Edição de lista').layout( [[Text('Novo titulo: '), Input(key='title')], [Button('Atualizar'), Button('Voltar')]])
def __init__(self): self.window = Window('Criação de lista').layout( [[Text('Titulo: '), Input(key='title')], [Text('Descrição: '), Input(key='description')], [Button('Voltar'), Button('Cadastrar')]])
""" Created on Mon Mar 12 10:01:01 2019 @author: Girvan Tse """ import re from PySimpleGUI import Text, FileBrowse, Input, Window, Popup, Submit, Cancel, Checkbox, Button, Column import numpy as np from tkinter import TclError from pandas import ExcelWriter, DataFrame, read_excel from xlrd import XLRDError layout = [[Text('File to Query')], [ Input('[Path to Excel Workbook]', key='path'), FileBrowse(file_types=(("Excel Workbook", "*.xlsx"), ("All Files", "*.*"))), ], [Input('[Sheet Name]', key='sheet', size=(54, 0))], [ Input('[Column Label]', key='colName', size=(32, 0)), Input('[Column Sum]', key='colSum', size=(20, 0)) ], [Input('[# of Sum Elements]', key='numsums', size=(20, 0))], [Submit(key='next'), Cancel(key='exit')]] layout2 = [[Text('Filter which elements?')]] window = Window('RowRemoveTool').Layout(layout) def validate(file):
def show_main(): METER_REASON_CANCELLED = "cancelled" # METER_REASON_CLOSED = "closed" # METER_REASON_REACHED_MAX = "finished" METER_OK = True # METER_STOPPED = False menu_def = [ # ["File", ["Save", "Load", "Exit"]], ["File", ["Exit"]], [ "Commands", [ "Extract", "Load", "Merge", "Catalog", ["Get", "List", "Purge", "Upload"], "Transform", ], ], ["Help", ["About", "Help"]], ] col1 = Column( [ # Logon frame [ Frame( "Logon information", [[ Text(), Column([ [ Text("ION File:", size=(14, 1)), Input(key="-ION-FILE-"), FileBrowse(), ], [ Text("M3 Company/Div:"), Input(key="-M3-COMPANY-", size=(5, 1)), Input(key="-M3-DIV-", size=(7, 1)), ], ]), ]], ) ], # Information frame [ Frame( "Input Data", [[ Text(), Column([ [ Text("URL:", size=(14, 1)), Input(key="-ION-URL-"), ], [ Text("Program:", size=(14, 1)), sg.Input( size=(10, 1), enable_events=True, key="-ION-FILTER-", ), ], [ Text(justification="r", size=(14, 1)), sg.Listbox( programs, size=(10, 5), enable_events=False, key="-ION-Program-", select_mode="single", ), ], [ Text("Method:", size=(14, 1)), Input(key="-ION-METHOD-"), ], [ Text("Input File:", size=(14, 1)), Input(key="-INPUT-FILE-"), FileBrowse(), ], [ Text("Output File:", size=(14, 1)), Input(key="-OUTPUT-FILE-"), FileBrowse(), ], [ Text("Begin on line:", size=(14, 1)), Input(key="-ION-BEGIN-", enable_events=True), ], [ Text("End on line:", size=(14, 1)), Input(key="-ION-END-", enable_events=True), ], ], ), ]], ) ], ], ) layout = [ [sg.Menu(menu_def, tearoff=True, pad=(200, 1))], [col1], [Button("Execute"), Button("Cancel")], ] window = sg.Window("QuickdataLoad - Main", layout=layout, icon=icon_image, margins=(10, 10)) settings = load_settings(SETTINGS_FILE, DEFAULT_SETTINGS) window_extract_active = False # Event Loop while True: event, values = window.read(10) if not notifications.empty(): e, m = notifications.get() sg.popup(m, icon=icon_image) if event in (None, sg.WIN_CLOSED, "Cancel"): break if event in ("-ION-BEGIN-", "-ION-END-"): if values[event] and values[event][-1] not in ("0123456789"): sg.popup_quick_message( "Please enter a valid row number", keep_on_top=True, text_color="red", no_titlebar=True, ) if values["-ION-FILTER-"] != "": search = values["-ION-FILTER-"] filtered_programs = [x for x in programs if search in x] window["-ION-Program-"].update(filtered_programs) else: window["-ION-Program-"].update(programs) if event == "Execute": url = values["-ION-URL-"] ionfile = values["-ION-FILE-"] programs_list = values["-ION-Program-"] method = values["-ION-METHOD-"] inputfile = values["-INPUT-FILE-"] outputfile = values["-OUTPUT-FILE-"] if values["-ION-BEGIN-"]: start = int(values["-ION-BEGIN-"]) else: start = 0 if values["-ION-END-"]: end = int(values["-ION-END-"]) else: end = None if validators.url(url) != True: sg.popup_quick_message( "You have to provide a valid URL", keep_on_top=True, text_color="red", no_titlebar=True, ) METER_OK = False elif infor.filehandling.checkfile_exists(ionfile) != True: sg.popup_quick_message( "You have to provide a valid ionfile", keep_on_top=True, text_color="red", no_titlebar=True, ) METER_OK = False elif not programs_list: sg.popup_quick_message( "You have to provide a program", keep_on_top=True, text_color="red", no_titlebar=True, ) METER_OK = False elif not method: sg.popup_quick_message( "You have to provide atleast one method", keep_on_top=True, text_color="red", no_titlebar=True, ) METER_OK = False elif not outputfile: sg.popup_quick_message( "You have to provide output file path", keep_on_top=True, text_color="red", no_titlebar=True, ) METER_OK = False elif not infor.filehandling.checkfile_exists(inputfile): sg.popup_quick_message( "Input File not found", keep_on_top=True, text_color="red", no_titlebar=True, ) METER_OK = False elif end is not None and end < start: sg.popup_quick_message( "Begin value must be greater then End value", keep_on_top=True, text_color="red", no_titlebar=True, ) METER_OK = False else: METER_OK = True dataframe = pd.read_excel(inputfile, dtype=str) program = programs_list[0] if METER_OK: infor.main_load( url, ionfile, program, method, dataframe, outputfile, start, end, on_progress, ) if event == "Save": save_settings(True, SETTINGS_FILE, settings, values) if event == "Load": settings = load_settings(SETTINGS_FILE, DEFAULT_SETTINGS) fill_form_with_settings(window, settings) if event == "About": open_about() if event == "Help": open_help() if event in (sg.WIN_CLOSED, "Exit"): break # Command Windows if event == "Extract" and not window_extract_active: window_extract_active = True window.Hide() def TextLabel(text): return sg.Text(text + ":", justification="r", size=(12, 1)) column = Column([ [ Frame( "Input Data", [[ Text(), Column([ [ TextLabel("Program"), sg.Input( size=(10, 1), enable_events=True, key="-FILTER-", ), ], [ Text(justification="r", size=(12, 1)), sg.Listbox( programs, size=(10, 5), enable_events=False, key="-PROGRAM-", select_mode="multiple", ), ], [ TextLabel("Output Folder"), sg.Input(key="-OUTPUT-FOLDER-"), sg.FolderBrowse(target="-OUTPUT-FOLDER-"), ], ], ), ]], ) ], ], ) layout_extract = [[column], [Button("Execute"), Button("Cancel")]] window_extract = sg.Window( "QuickdataLoad - Extract", layout=layout_extract, icon=icon_image, margins=(10, 10), ) while True: event, values = window_extract.read() if event == sg.WIN_CLOSED or event == "Cancel": window_extract.Close() window_extract_active = False break if values["-FILTER-"] != "": search = values["-FILTER-"] filtered_programs = [x for x in programs if search in x] window_extract["-PROGRAM-"].update(filtered_programs) else: window_extract["-PROGRAM-"].update(programs) if event == "Execute": try: programs_list = values["-PROGRAM-"] output_folder = values["-OUTPUT-FOLDER-"] if validators.length(programs_list, 1) and validators.length( output_folder, 1): for program in programs_list: output_path = output_folder + os.sep + program excelexport.generate_api_template_file( program, output_path) sg.popup("Template(s) generated!", icon=icon_image) else: sg.popup_ok("Please, check the form values!", icon=icon_image) except Exception as e: infor.logger.exception(e) sg.popup_ok( "Something went wrong! Please check the error logs!", icon=icon_image, ) if event == "Transform" and not window_extract_active: window_transform_active = True window.Hide() def TextLabel(text): return sg.Text(text + ":", justification="r", size=(15, 1)) column = Column([ [ Frame( "Input Data", [[ Text(), Column([ [ TextLabel("Mapping File"), Input(key="-MAPPING-FILE-"), FileBrowse(), ], [ TextLabel("Main Sheet"), Input(key="-MAIN-SHEET-"), ], [ TextLabel("Input File"), Input(key="-INPUT-FILE-"), FileBrowse(), ], [ TextLabel("Output Folder"), sg.Input(key="-OUTPUT-FOLDER-"), sg.FolderBrowse(target="-OUTPUT-FOLDER-"), ], ], ), ]], ) ], ], ) layout_transform = [[column], [Button("Execute"), Button("Cancel")]] window_transform = sg.Window( "QuickdataLoad - Transform", icon=icon_image, layout=layout_transform, margins=(10, 10), ) while True: event, values = window_transform.read(10) if not notifications.empty(): e, m = notifications.get() sg.popup(m, icon=icon_image) if event == sg.WIN_CLOSED or event == "Cancel": window_transform.Close() window_transform_active = False break if event == "Execute": try: mapping_file = values["-MAPPING-FILE-"] main_sheet = values["-MAIN-SHEET-"] input_file = values["-INPUT-FILE-"] output_folder = values["-OUTPUT-FOLDER-"] if (validators.length(mapping_file, 1) and validators.length(main_sheet, 1) and validators.length(input_file, 1) and validators.length(output_folder, 1)): output_file_name = "output_" + path_leaf( input_file) output_file = output_folder + os.sep + output_file_name threading.Thread( target=transform, args=( mapping_file, main_sheet, input_file, output_file, notifications, ), ).start() sg.popup( "Transformation file result will generated at: \n" + output_file, icon=icon_image, ) else: sg.popup_ok("Please, check the form values!", icon=icon_image) except Exception as e: infor.logger.exception(e) sg.popup_ok( "Something went wrong! Please check the error logs!", icon=icon_image, ) window.UnHide() window.close()
def __init__(self): self.window = Window('Autenticação de Usuário').layout( [[Text('Usuário: '), Input(key='username')], [Text('Senha: '), Input(key='password')], [Button('Registrar'), Button('Login')]])
def __init__(self): self.window = Window('Pesquisa de filme').layout( [[Text('Pesquise aqui um filme/série:')], [Input(key='title')], [Button('Pesquisar')]])
def validateInputValue(inp: Gui.Input) -> bool: val = str(inp.get()) result = __testInputForInt(val) __markInputAs(inp, result) return result
[[ Radio('Websites', 'radio1', default=True, key='-WEBSITES-', size=(10, 1)), Radio('Software', 'radio1', key='-SOFTWARE-', size=(10, 1)) ]], ) ], # Information frame [ Frame('Information:', [[ Column([ [Text('Account:')], [Input(key='-ACCOUNT-IN-', size=(19, 1))], [Text('User Id:')], [ Input(key='-USERID-IN-', size=(19, 1)), Button('Copy', key='-USERID-') ], [Text('Password:'******'-PW-IN-', size=(19, 1)), Button('Copy', key='-PASS-') ], [Text('Location:')], [ Input(key='-LOC-IN-', size=(19, 1)), Button('Copy', key='-LOC') ],
from PySimpleGUI import Text, CBox, Input, Button, Window layout = [[Text(f'{i}. '), Input()] for i in range(1, 6)] layout += [[Button('Save'), Button('Exit')]] window = Window('To Do List Example', layout) event, values = window.read() print(values)