def startup(): layout = [[sg.Text('Please enter the name of your server:')], [sg.InputText()], [sg.Submit(), sg.Cancel()]] window = sg.Window('Project0', layout) event, values = window.Read() window.Close() ServerName = values[0] return ServerName
def main(): global g_exit, g_response_time layout = [[sg.T('Enter width, height of graph')], [sg.In(size=(6, 1)), sg.In(size=(6, 1))], [sg.Ok(), sg.Cancel()]] window = sg.Window('Enter graph size').Layout(layout) b,v = window.Read() if b is None or b == 'Cancel': sys.exit(69) w, h = int(v[0]), int(v[1]) CANVAS_SIZE = (w,h) # start ping measurement thread sg.ChangeLookAndFeel('Black') sg.SetOptions(element_padding=(0,0)) layout = [ [sg.Quit( button_color=('white','black'))], [sg.Graph(CANVAS_SIZE, (0,0), (SAMPLES,SAMPLE_MAX),background_color='black', key='graph')],] window = sg.Window('Canvas test', grab_anywhere=True, background_color='black', no_titlebar=False, use_default_focus=False).Layout(layout).Finalize() graph = window.FindElement('graph') prev_response_time = None i=0 prev_x, prev_y = 0, 0 graph_value = 250 while True: # time.sleep(.2) button, values = window.ReadNonBlocking() if button == 'Quit' or values is None: break graph_offset = random.randint(-10, 10) graph_value = graph_value + graph_offset if graph_value > SAMPLE_MAX: graph_value = SAMPLE_MAX if graph_value < 0: graph_value = 0 new_x, new_y = i, graph_value prev_value = graph_value if i >= SAMPLES: graph.Move(-STEP_SIZE,0) prev_x = prev_x - STEP_SIZE graph.DrawLine((prev_x, prev_y), (new_x, new_y), color='white') # window.FindElement('graph').DrawPoint((new_x, new_y), color='red') prev_x, prev_y = new_x, new_y i += STEP_SIZE if i < SAMPLES else 0
def addClient(): layout = [ [sg.Text('Please enter the IP address and email')], [sg.Text('IP Address:', size=(15, 1)), sg.InputText('', key='_IP_')], [sg.Text('Email:', size=(15, 1)), sg.InputText('', key='_EMAIL_')], [sg.Submit(), sg.Cancel()] ] window = sg.Window('Add Account', layout) event, values = window.Read() window.Close() if (sg.PopupYesNo("Are you sure?") == "Yes"): return values else: pass
def GetFilesToCompare(): form_rows = [[sg.Text('Enter 2 files to comare')], [ sg.Text('File 1', size=(15, 1)), sg.InputText(key='file1'), sg.FileBrowse() ], [ sg.Text('File 2', size=(15, 1)), sg.InputText(key='file2'), sg.FileBrowse(target='file2') ], [sg.Submit(), sg.Cancel()]] window = sg.Window('File Compare') button, values = window.Layout(form_rows).Read() return button, values
def addAccount(): #add email account to the "Available" section layout = [[sg.Text('Please enter the email address and password')], [ sg.Text('Email Address:', size=(15, 1)), sg.InputText('', key='_EMAIL_') ], [ sg.Text('Password:'******'', key='_PASSWORD_') ], [sg.Submit(), sg.Cancel()]] window = sg.Window('Add Account', layout) event, values = window.Read() window.Close() if (sg.PopupYesNo("Are you sure?") == "Yes"): return values else: pass
def PlayerChooseSongGUI(self): # ---------------------- DEFINION OF CHOOSE WHAT TO PLAY GUI ---------------------------- layout = [[ sg.Text('MIDI File Player', font=("Helvetica", 15), size=(20, 1), text_color='green') ], [sg.Text('File Selection', font=("Helvetica", 15), size=(20, 1))], [ sg.Text('Single File Playback', justification='right'), sg.InputText(size=(65, 1), key='midifile'), sg.FileBrowse(size=(10, 1), file_types=(("MIDI files", "*.mid"), )) ], [ sg.Text('Or Batch Play From This Folder', auto_size_text=False, justification='right'), sg.InputText(size=(65, 1), key='folder'), sg.FolderBrowse(size=(10, 1)) ], [sg.Text('_' * 250, auto_size_text=False, size=(100, 1))], [ sg.Text('Choose MIDI Output Device', size=(22, 1)), sg.Listbox(values=self.PortList, size=(30, len(self.PortList) + 1), key='device') ], [sg.Text('_' * 250, auto_size_text=False, size=(100, 1))], [ sg.SimpleButton('PLAY', size=(12, 2), button_color=('red', 'white'), font=("Helvetica", 15), bind_return_key=True), sg.Text(' ' * 2, size=(4, 1)), sg.Cancel(size=(8, 2), font=("Helvetica", 15)) ]] window = sg.Window('MIDI File Player', auto_size_text=False, default_element_size=(30, 1), font=("Helvetica", 12)).Layout(layout) self.Window = window return window.Read()
def CustomMeter(): # layout the form layout = [[sg.Text('A custom progress meter')], [ sg.ProgressBar(10000, orientation='h', size=(20, 20), key='progress') ], [sg.Cancel()]] # create the form` window = sg.Window('Custom Progress Meter').Layout(layout) progress_bar = window.FindElement('progress') # loop that would normally do something useful for i in range(10000): # check to see if the cancel button was clicked and exit loop if clicked button, values = window.ReadNonBlocking() if button == 'Cancel' or values == None: break # update bar with loop value +1 so that bar eventually reaches the maximum progress_bar.UpdateBar(i + 1) # done with loop... need to destroy the window as it's still open window.CloseNonBlocking()
sg.InputCombo(('none', 'minmax', 'l1 norm', 'l2 norm', 'z score'), size=(20, 3)) ], [ sg.Text('Select Filter', size=(22, 1)), sg.InputCombo(('none', 'remove hotels', 'remove users', 'remove both'), size=(20, 3)) ], [ sg.Text('Select Feature', size=(22, 1)), sg.InputCombo( ('ratings', 'all features', 'no ratings', 'rating+date+total', 'rating+date+word', 'rating+total+word', 'rating+date', 'rating+total', 'rating+word', 'all normal'), size=(20, 3)) ], [sg.Submit('Search'), sg.Cancel()] ] window = sg.Window('Hotel Finder').Layout(layout) # keep the window persistent while True: button, values = window.Read() if button == 'Cancel': window.Close() elif button == 'Search': id_input = int(values[0]) country_input = values[1] travel_input = values[2] stay_input = values[3] room_input = values[4]
[sg.Text('Strength of Similarity P:', size=(25, 1)), sg.InputText()], # 6 [sg.Text('Similarity of Chunks:', size=(25, 1)), sg.InputText()], # 7 [sg.Text('Advanced parameters for the Production Module:')], # [sg.Text('Production Utility Noise e:', size=(25, 1)), sg.InputText()], # 8 [sg.Text('Production Utility Success:', size=(25, 1)), sg.InputText()], # 9 [sg.Text('Production Utility Fail:', size=(25, 1)), sg.InputText()], # 10 [sg.Text('Physical help factor:', size=(25, 1)), sg.InputText()], # 11 [sg.Text('Verbal help factor:', size=(25, 1)), sg.InputText()], # 12 [sg.Submit(button_text='Run'), sg.Cancel()] # ] my_font = ("Arial", 13) window = sg.Window('Simulation of daily activities', layout, element_justification='c', size=(700, 550), font=my_font) event, values = window.read() window.close() print(event) if values[0] == 'Tea Preparation Activity': activity = 1 if values[0] == 'Washing Hands Activity': activity = 2 if values[0] == 'Dressing Activity': activity = 3
#!/usr/bin/env python import sys if sys.version_info[0] < 3: import PySimpleGUI27 as sg else: import PySimpleGUI as sg """ Simple Form showing how to use keys on your input fields """ layout = [[sg.Text('Please enter your Name, Address, Phone')], [sg.Text('Name', size=(15, 1)), sg.InputText('1', key='name')], [sg.Text('Address', size=(15, 1)), sg.InputText('2', key='address')], [sg.Text('Phone', size=(15, 1)), sg.InputText('3', key='phone')], [sg.Submit(), sg.Cancel()]] window = sg.Window('Simple Data Entry Window').Layout(layout) button, values = window.Read() sg.Popup(button, values, values['name'], values['address'], values['phone'])
[ sg.Text("Dep. cache control:", size=(15, 1)), sg.Checkbox("Ignore", text_color="#FF0000", default=False, key="ignore-cache"), sg.Checkbox("Recurse", text_color="#FF0000", default=False, key="int-depend"), sg.Checkbox( "Rebuild", text_color="#FF0000", default=False, key="rebuild-cache" ), ], [sg.Text("No recurse into:", text_color="#FF0000", size=(13, 1)), frm_no_follow], [sg.Text("Recurse into:", size=(13, 1)), frm_follow], [sg.Text("Include packages:", size=(13, 1)), frm_packages], [sg.Text("Include modules:", size=(13, 1)), frm_modules], [sg.Text("Include plugin-dir:", size=(13, 1)), frm_plugins], [sg.Text("More Nuitka args:", size=(13, 1)), frm_more], [message], [sg.Submit(), sg.Cancel()], ] form.Layout(layout) while True: frm_input.Update(pscript) frm_output.Update(compile_to) frm_icon.Update(icon_file) btn, val = form.Read() if btn in (None, "Cancel"): break pscript = os.path.abspath(val["py-file"]) if not os.path.exists(pscript): message.Update("Python script '%s' does not exist!" % pscript) pscript = ""
#master=tk.Tk() #tk.Label(master, text=" finestra 1").grid(row=0) #tk.Label(master, text=" finestra 2").grid(row=1) #e1=tk.Entry(master) #e2=tk.Entry(master) #e1.grid(row=0, column=1) #e2.grid(row=1, column=1) #master.mainloop() # continue from https://www.python-course.eu/tkinter_entry_widgets.php #_______________________________________ # GUI layout = [[sg.Text('Insert Company Name, name of the job, link')], [sg.Text('Company Name', size=(15, 1)), sg.InputText('name')], [sg.Text('Name of the job', size=(15, 1)), sg.InputText('address')], [sg.Text('link', size=(15, 1)), sg.InputText('phone')], [sg.Submit(), sg.Cancel()]] window = sg.Window('Job Apllications').Layout(layout) button, values = window.Read() print(button, values[0], values[1], values[2]) #__________________________ #workbook = xlwt.Workbook() #sheet = workbook.add_sheet("Sheet Name")
def MachineLearningGUI(): sg.SetOptions(text_justification='right') flags = [ [ sg.Checkbox('Normalize', size=(12, 1), default=True), sg.Checkbox('Verbose', size=(20, 1)) ], [ sg.Checkbox('Cluster', size=(12, 1)), sg.Checkbox('Flush Output', size=(20, 1), default=True) ], [ sg.Checkbox('Write Results', size=(12, 1)), sg.Checkbox('Keep Intermediate Data', size=(20, 1)) ], [ sg.Checkbox('Normalize', size=(12, 1), default=True), sg.Checkbox('Verbose', size=(20, 1)) ], [ sg.Checkbox('Cluster', size=(12, 1)), sg.Checkbox('Flush Output', size=(20, 1), default=True) ], [ sg.Checkbox('Write Results', size=(12, 1)), sg.Checkbox('Keep Intermediate Data', size=(20, 1)) ], ] loss_functions = [ [ sg.Radio('Cross-Entropy', 'loss', size=(12, 1)), sg.Radio('Logistic', 'loss', default=True, size=(12, 1)) ], [ sg.Radio('Hinge', 'loss', size=(12, 1)), sg.Radio('Huber', 'loss', size=(12, 1)) ], [ sg.Radio('Kullerback', 'loss', size=(12, 1)), sg.Radio('MAE(L1)', 'loss', size=(12, 1)) ], [ sg.Radio('MSE(L2)', 'loss', size=(12, 1)), sg.Radio('MB(L0)', 'loss', size=(12, 1)) ], ] command_line_parms = [ [ sg.Text('Passes', size=(8, 1)), sg.Spin(values=[i for i in range(1, 1000)], initial_value=20, size=(6, 1)), sg.Text('Steps', size=(8, 1), pad=((7, 3))), sg.Spin(values=[i for i in range(1, 1000)], initial_value=20, size=(6, 1)) ], [ sg.Text('ooa', size=(8, 1)), sg.In(default_text='6', size=(8, 1)), sg.Text('nn', size=(8, 1)), sg.In(default_text='10', size=(10, 1)) ], [ sg.Text('q', size=(8, 1)), sg.In(default_text='ff', size=(8, 1)), sg.Text('ngram', size=(8, 1)), sg.In(default_text='5', size=(10, 1)) ], [ sg.Text('l', size=(8, 1)), sg.In(default_text='0.4', size=(8, 1)), sg.Text('Layers', size=(8, 1)), sg.Drop(values=('BatchNorm', 'other'), auto_size_text=True) ], ] layout = [[ sg.Frame('Command Line Parameteres', command_line_parms, title_color='green', font='Any 12') ], [sg.Frame('Flags', flags, font='Any 12', title_color='blue')], [ sg.Frame('Loss Functions', loss_functions, font='Any 12', title_color='red') ], [sg.Submit(), sg.Cancel()]] window = sg.Window('Machine Learning Front End', font=("Helvetica", 12)).Layout(layout) button, values = window.Read() sg.SetOptions(text_justification='left') print(button, values)
#!/usr/bin/env python import sys if sys.version_info[0] < 3: import PySimpleGUI27 as sg else: import PySimpleGUI as sg layout = [[sg.Text('Filename', )], [sg.Input(), sg.FileBrowse()], [sg.OK(), sg.Cancel()]] button, (number,) = sg.Window('Get filename example').LayoutAndRead(layout) import PySimpleGUI as sg button, (filename,) = sg.Window('Get filename example').LayoutAndRead( [[sg.Text('Filename')], [sg.Input(), sg.FileBrowse()], [sg.OK(), sg.Cancel()]])
[ sg.Text('Spain', size=(15, 1), font=("Calibri", 11)), sg.InputCombo(['yes', 'no', 'undefined']) ], [ sg.Text('Narrow Geolocation', size=(15, 1), font=("Calibri", 11)), sg.InputCombo(['yes', 'no']) ], [ sg.Text('Tweet ' + index + ' of ' + total, font=("Calibri", 11)) ], [sg.Text('Start from tweet number: ', font=("Calibri", 11))], [sg.Input()], [sg.Submit(), sg.Cancel()]] window = sg.Window('Processing tweets') button, values = window.LayoutAndRead(layout) if button != 'Submit': if button == 'Copy Original Tweet': pyperclip.copy(text) if button == 'Copy Russian translation': pyperclip.copy(russian_trans) if button == 'Copy English translation': pyperclip.copy(english_trans) if button == 'Cancel': break
#!/usr/bin/env python import sys if sys.version_info[0] < 3: import PySimpleGUI27 as sg else: import PySimpleGUI as sg import sys ''' Quickly add a GUI to your script! This simple script shows a 1-line-GUI addition to a typical Python command line script. Previously this script accepted 1 parameter on the command line. When executed, that parameter is read into the variable fname. The 1-line-GUI shows a form that allows the user to browse to find the filename. The GUI stores the result in the variable fname, just like the command line parsing did. ''' if len(sys.argv) == 1: button, (fname, ) = sg.Window('My Script').LayoutAndRead( [[sg.T('Document to open')], [sg.In(), sg.FileBrowse()], [sg.Open(), sg.Cancel()]]) else: fname = sys.argv[1] if not fname: sg.Popup("Cancel", "No filename supplied") raise SystemExit("Cancelling: no filename supplied")