def HowDoI(): ''' Make and show a window (PySimpleGUI form) that takes user input and sends to the HowDoI web oracle Excellent example of 2 GUI concepts 1. Output Element that will show text in a scrolled window 2. Non-Window-Closing Buttons - These buttons will cause the form to return with the form's values, but doesn't close the form :return: never returns ''' # ------- Make a new Window ------- # sg.ChangeLookAndFeel('GreenTan') # give our form a spiffy set of colors layout = [ [sg.Text('Ask and your answer will appear here....')], [sg.Output(size=(900, 500), font=('Courier', 10))], [ sg.Spin(values=(1, 4), initial_value=1, size=(50, 25), key='Num Answers', font=('Helvetica', 15)), sg.Text('Num Answers',font=('Helvetica', 15), size=(170,22)), sg.Checkbox('Display Full Text', key='full text', font=('Helvetica', 15), size=(200,22)), sg.T('Command History', font=('Helvetica', 15)), sg.T('', size=(100,25), text_color=sg.BLUES[0], key='history'), sg.Stretch()], [sg.Multiline(size=(600, 100), enter_submits=True, focus=True, key='query', do_not_clear=False), sg.Stretch(), sg.ReadButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0]), bind_return_key=True), sg.Button('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0])), sg.Stretch()] ] window = sg.Window('How Do I ??', default_element_size=(100, 25), # element_padding=(10,10), icon=DEFAULT_ICON, font=('Helvetica',14), default_button_element_size=(70,50), return_keyboard_events=True, no_titlebar=False, grab_anywhere=True,) window.Layout(layout) # ---===--- Loop taking in user input and using it to query HowDoI --- # command_history = [] history_offset = 0 while True: event, values = window.Read() if event in ['SEND', 'query']: # window.FindElement('+OUTPUT+').Update('test of output') # manually clear input because keyboard events blocks clear query = values['query'].rstrip() # print(query) QueryHowDoI(query, values['Num Answers'], values['full text']) # send the string to HowDoI command_history.append(query) history_offset = len(command_history)-1 window.FindElement('query').Update('') # manually clear input because keyboard events blocks clear window.FindElement('history').Update('\n'.join(command_history[-3:])) elif event is None or event == 'EXIT': # if exit button or closed using X break elif 'Up' in event and len(command_history): # scroll back in history command = command_history[history_offset] history_offset -= 1 * (history_offset > 0) # decrement is not zero window.FindElement('query').Update(command) elif 'Down' in event and len(command_history): # scroll forward in history history_offset += 1 * (history_offset < len(command_history)-1) # increment up to end of list command = command_history[history_offset] window.FindElement('query').Update(command) elif 'Escape' in event: # clear currently line window.FindElement('query').Update('')
def janelareceita( NOME, RECEITA_IMAGEM, RECEITA_INGREDIENTES, RECEITA_CATEGORIAS, RECEITA_MODOPREPARO ): window.Disable() LAYOUT2 = [ [sg.Stretch(), sg.Text(NOME, font=("SegoeUI bold", 24)), sg.Stretch()], [sg.HorizontalSeparator()], [ sg.Column( [ [sg.Stretch(), sg.Image(data=RECEITA_IMAGEM), sg.Stretch()], [sg.Text("Ingredientes:")], [sg.Listbox(RECEITA_INGREDIENTES)], [sg.Text("Categorias:")], [sg.Listbox(RECEITA_CATEGORIAS)], ] ), sg.VerticalSeparator(), sg.Column( [[sg.Text("MODO DE PREPARO:")], [sg.Multiline(RECEITA_MODOPREPARO)]] ), ], ] window2 = sg.Window( "Livro de Receitas", layout=LAYOUT2, size=(1200, 600), keep_on_top=True, ) while 1: event2, values2 = window2.read() if event2 == sg.WINDOW_CLOSED: break window2.close() window.Enable()
def main(): # Define theme for the GUI sg.theme('Light Grey 1') # Create a list of all of the accounts in the userdata file. account_names = userdata.get_names() # Define the icon in base64 format - this is the FontAwesome arrows-alt icon. # Create a column for the account list and the post GUI. acct_col = [[sg.Text('Select accounts to post to:')], [sg.Listbox(values=account_names, size=(20, 12))]] post_col = [[sg.Text('Subject/Content Warning (leave blank for none)')], [sg.Input(size=(50, 1))], [sg.Text("What's on your mind?")], [sg.Multiline(size=(50, 15))], [ sg.Text(justification='right', key='-CHARS-', margins=(10, 10, 10, 10)), sg.Button("Post!", size=(10, 1)) ]] # Combine both columns in one layout, and define the layout in the main window. layout = [[sg.Column(acct_col), sg.Column(post_col)]] window = sg.Window('Cross - A Mastodon/Hubzilla cross-poster', layout, icon=common.fa_arrows) # Start an loop that watches for window events and post length. while True: # This will update the post length counter every 20 milliseconds if I'm understanding correctly. # And, of course, will also do the event listening and monitor the values of the different items. event, values = window.read(timeout=20) if event in (None, 'Post!'): if event == 'Post!': # If we get here, the user pressed the post button. # Let's do a few sanity checks - first, let's make sure an account was selected to post to. if not values[0]: # If we're here, no accounts were selected. sg.popup_ok( "You didn't select any accounts!\n" "Try selecting an account before posting.\n", title="Error making post", icon=common.fa_arrows) # Next, let's make sure they actually wrote a post. elif values[2] == "": # They didn't actually write a post. Error out and let them know why. sg.popup_ok( "You didn't actually write a post, silly!\n" "Try writing one first.", title="Error making post", icon=common.fa_arrows) # We /should/ be good to continue at this point. else: userdata.post_sel_accts(values[0], values[1], values[2]) # And once we get here, we're done! Print a thank-you message in the console, break, and exit. print() print("Done! Thank you for using Cross.") # We've either finished posting or the user closed the window. Either way, let's break. break # If we get here, we're not breaking or posting, so update the post length counter with # the combined length of the subject/content warning and the post. window['-CHARS-'].update(str(len(values[1]) + len(values[2]))) window.close()
def create_note(name, config): g.SetOptions(background_color=config.background_color, text_color=config.text_color, input_elements_background_color=config.background_color, input_text_color=config.text_color, button_color=(config.text_color, config.background_color), border_width=config.border_width, font=('Arial', int(config.font_size))) layout = [ [g.T('Create Note', font=('Arial', int(config.title_size)), justification='center')], [g.Multiline('', size=(50, 5), key='content')], [g.B('Close'), g.B('Save')] ] window = g.Window('Create', no_titlebar=NTB, keep_on_top=True, grab_anywhere=True, layout=layout, alpha_channel=float(config.alpha)) while True: event, value = window.Read() if event == 'Close': window.Close() break elif event == 'Save': with open(NOTES_PATH, 'r+') as notes: note_obj = json.load(notes) note_obj.update({ name: value['content'] }) notes.seek(0) notes.truncate() json.dump(note_obj, notes, indent=4) window.Close() break
def _build(self): self.width = 576 self.layout = [ [sg.Text("Starting...", **self._bd_status_kw(1, 24))], [sg.Multiline("", disabled=True, **self._bd_status_kw(2, 128))], [sg.Text("", **self._bd_status_kw(3, 24))], [sg.Multiline( "D&D *.msg file(s) here", key="_INPUT_", enable_events=True, size=(self.width, 256), font=self.def_font, text_color="#666666")], ] self.header = "MSG=>EML Converter" self.window = sg.Window(self.header).Layout(self.layout).Finalize() self._on_running = True self._values = [] self._exec_count = 0 self._skip_next_event = False self._event_handlers = { "_INPUT_": self._on_dnd_event, "_TIMEOUT_": self._on_timeout_event, }
def main(): window = sg.FlexForm('Log window', default_element_size=(30, 2), font=('Helvetica', ' 10'), default_button_element_size=(8, 2), return_keyboard_events=True) layout = \ [ [sg.Multiline(size=(50, 15), key='Log')], [sg.Button('Start', bind_return_key=True, key='_START_'), sg.Button('Exit')] ] window.Layout(layout).Read(timeout=0) appStarted = False # Setup logging and start app logging.basicConfig(level=logging.DEBUG) log_queue = queue.Queue() queue_handler = QueueHandler(log_queue) logger.addHandler(queue_handler) threadedApp = ThreadedApp() # Loop taking in user input and querying queue while True: # Wake every 100ms and look for work event, values = window.Read(timeout=100) if event == '_START_': if not appStarted: threadedApp.start() logger.debug('App started') window.FindElement('_START_').Update(disabled=True) appStarted = True elif event in (None, 'Exit'): break # Poll queue try: record = log_queue.get(block=False) except queue.Empty: pass else: msg = queue_handler.format(record) window.FindElement('Log').Update(msg + '\n', append=True) window.Close() exit()
def setup(self): window_layout = [[ sg.Text(f'GitHub Notifications: {notif_num}', key='notifications_num'), sg.Button('info', size=(5, 1)) ], [sg.T('') ], [sg.Multiline(notifications, size=(500, 200), key='output')], [sg.Text('')], [ sg.Ok(size=(10, 1)), sg.Button('To GitHub', size=(10, 1), key='open_url'), sg.Button('Mark all as read', size=(20, 1), key='read_all'), ]] self.window = sg.Window(f'GitHub Notifier ver.{version}', window_layout, icon=icon1) self.window.Finalize()
def __init__(self, ConsoleWinName="Default Name"): psg.theme("BtrConsole") print( f"Better Console by ultraflame42 [Version-{v}]\nGithub:{github}\n\n" ) layout = [[ psg.Text("Filters:", size=(17, 0.7)), psg.Button("Normal", size=(17, 0.7)), psg.Button("Debug", size=(17, 0.7)), psg.Button("Info", size=(17, 0.7)), psg.Button("Warning", size=(17, 0.7)), psg.Button("Error", size=(17, 0.7)), psg.Button("Critical", size=(17, 0.7)) ], [psg.Multiline(size=(180, 40), font=("Courier", 10), key='-Out-')], [ psg.Button(">>>", size=(4, 1), bind_return_key=True), psg.Input(size=(175.6, 1), do_not_clear=False, key="-In-") ]] self.win = psg.Window( f" {ConsoleWinName} - [Better Console <version: {v}> by ultraflame42 ]", layout, return_keyboard_events=True, ) self.consoleOutputText = '' self.GlobalLineCounter = 0 self.inputHistoryHandler = inputHistoryHandler(self.win) self.FilterButtonController = FilterButtonsController() self.commandHandler = CommandsHandler() print( "Finished Initialization. Please wait... Better Console window will show up shortly..." ) self.win.read(timeout=10) self.FilterButtonController._start(self.win)
[sg.Text("Nome:"), sg.Input(key="in_nome")], [ sg.Text("Foto: "), sg.Input(key="in_foto"), sg.FileBrowse( "Procurar", file_types=(("Imagem", "*.jpg;*.jpeg;*.png;*.JPG;*.JPEG;*.PNG"),), size=(10, 1), ), ], [sg.Text("Ingredientes separado por vírgula. Exemplo: cebola, alho, arroz...:")], [sg.Input(key="in_ingredientes")], [sg.Text("Categorias. Exemplo: assado, salgado, doce...:")], [sg.Input(key="in_cat")], [sg.Text("Modo de preparo:")], [sg.Multiline(key="in_preparo")], [sg.Stretch(), sg.Button("Salvar", size=(10, 1), key="in_salvar"), sg.Stretch()], ] ABA2_COL2 = [ [ sg.Text("Lista de ingredientes:"), sg.Button("Listar", size=(10, 1), key="in_list_ingred"), sg.Text("Lista de categorias:"), sg.Button("Listar", size=(10, 1), key="in_list_cat"), ], [ sg.Listbox([], key="in_ingred_list", enable_events=True), sg.Listbox([], key="in_cat_list", enable_events=True), ], ]
def welcome_layout(): frame_1 = [ [sg.Text('Balança: ')], [sg.Combo(['Nenhuma', 'Toledo', 'Filizola', 'Urano'], font=("verdana", 11), key="balance_name", enable_events=True, size=(13, 0.8))], [sg.Text('Porta Serial: ')], [sg.Combo(get_serial_names(), font=("verdana", 13), key="serial_port", size=(13, 0.8))], [sg.Text('Baud Rate: ')], [sg.Combo([2400, 4800, 9600, 14400, 19200, 38400, 56000, 57600], font=("verdana", 11), key="baudrate", size=(13, 0.8))], [sg.Text('Data Bits: ')], [sg.Combo([5, 6, 7, 8], font=("verdana", 11), key="data_bits", size=(13, 0.8))], [sg.Text('Parity: ')], [sg.Combo(['none', 'odd', 'even', 'mark', 'space'], font=("verdana", 11), key="parity", size=(13, 0.8))], [sg.Text('Stop Bits:')], [sg.Combo([1, 1.5, 2], font=("verdana", 11), key="stop_bits", pad=[1, 0], size=(13, 0.8))], [sg.Text('Handshaking: ')], [sg.Combo(['Nenhum', 'XON/XOFF', 'RTS/CTS', 'DTR/DSR'], font=("verdana", 11), key="handshaking", pad=[1, 0], size=(13, 0.8))] ] frame_2 = [ [sg.Text('')], [sg.Input(get_last_weight(), do_not_clear=True, size=(25, 0.8), tooltip='Último Peso Lido', disabled=True, key='last_weight'), sg.Text(' '), sg.Input('1', do_not_clear=True, size=(15, 0.8), tooltip='Timeout', key='timeout'), sg.Stretch()], [sg.Text('')], [sg.Text('Última Resposta: ')], [sg.Multiline(size=(41.5, 8.6), key='Textbox', disabled=True)], [sg.Text('Pesagem Apurada: ')], [sg.Multiline(size=(41.5, 4.6), default_text=get_last_weight() + ' KG', font=('Helvetica Bold', 48), key='Textbox2', disabled=True)], [sg.Text('')], [sg.Text('')], [sg.Text('')], ] frame_3 = [ [sg.Text('')], [sg.Text(''), sg.Text(' ' * 2), sg.Button('Ativar', size=[14, 0.8], button_color=('white', '#082567'), key="activate"), sg.Text(''), sg.Text('')], [sg.Text('')], [sg.Text(''), sg.Text(' ' * 2), sg.Button('Desativar', size=[14, 0.8], button_color=('white', '#082567'), key="deactivate", disabled=True), sg.Text(''), sg.Text('')], [sg.Text('')], [sg.Text(''), sg.Text(' ' * 2), sg.Button('Ler Peso', size=[14, 0.8], button_color=('white', '#082567'), key="weight_read"), sg.Text(''), sg.Text('')], [sg.Text('')], [sg.Text(''), sg.Text(' ' * 2), sg.Button('Localizar Portas', size=[14, 0.8], button_color=('white', '#082567'), key="find_ports"), sg.Text(''), sg.Text('')], [sg.Text('')], [sg.Text(''), sg.Text(' ' * 2), sg.Button('Limpar', size=[14, 0.8], button_color=('white', '#082567'), key="clean"), sg.Text(''), sg.Text('')], [sg.Text('')], [sg.Text(''), sg.Text(' ' * 2), sg.Button('Sair', size=[14, 0.8], button_color=('white', '#082567'), key="exit"), sg.Text(''), sg.Text('')], [sg.Text('')], ] layout_1 = [ [sg.Text('')], [sg.Text(' '), sg.Frame('Ajustes Técnicos', frame_1, title_color='black', element_justification="l", key='frame_1'), sg.Text(' '), sg.Frame('Visualização de dados', frame_2, title_color='black', element_justification="c", key='frame_2'), sg.Text(' '), sg.Frame('Serviços', frame_3, title_color='black', element_justification="r", key='frame_3'), sg.Stretch()], [sg.Text(f'Versão: {__version__} by {__author__}', text_color="black", font=("verdana", 8)), sg.Text(get_current_date(), justification="right", text_color="black", key="clock", font=("verdana", 8)) ], ] return layout_1
sg.InputText(key='save_waypoint'), sg.Button('Record waypoint', size=BUTTON_SIZE), sg.Button('Stop record', size=BUTTON_SIZE) ], [ sg.Text('Open waypoint'), sg.InputText(key='waypoint', enable_events=True), sg.FileBrowse(key='Browse', size=BUTTON_SIZE) ], ]) ] waypoints_loaded = {} lines = {} for meta in WAYPOINT_META: line = sg.Multiline() lines[meta] = line loaded = [sg.Frame(meta.capitalize(), [[line]])] waypoints_loaded[meta] = loaded waypoint_loaded_frame = [ sg.Frame('Loaded waypoints', waypoints_loaded.values()) ] waypoint_layout_list = [ waypoint_frame, waypoint_selector_frame, waypoint_loaded_frame ] def load_waypoints(path: str): def _format(waypoints: list):
sg.ChangeLookAndFeel('LightGreen') layout = [ [sg.Text('Widgets Currently Supported By PySimpleGUIQt')], [ sg.Text('Text', size=(200, 35)), sg.Text('Text In Any Color/Font', font=('Courier', 15), text_color='red') ], [sg.Text('Single Line Input', size=(200, 35)), sg.Input(size=(200, 25))], [ sg.Text('Multi Line\nInput/Output', size=(200, 60)), sg.Multiline(size=(200, 75)) ], [ sg.Text('ListBox', size=(200, 35)), sg.Listbox(['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(200, 85)) ], [ sg.Text('ComboBox / Dropdown', size=(200, 25)), sg.Combo([ 'Combo item 1', ], size=(200, 35)) ], [sg.Text('Spinner', size=(200, 35)), sg.Spin([1, 2, 3], size=(40, 30))], [ sg.Text('Checkbox', size=(200, 35)), sg.Checkbox('Checkbox', change_submits=True)
Layout = [[sg.T("Tecla para iniciar:"), sg.I(key='in', size=(20, 1))], [sg.T("Tecla acionada:"), sg.I(key='do', size=(20, 1))], [sg.T("Tecla para parar:"), sg.I(key='out', size=(20, 1))], [ sg.T("Intervalo:"), sg.I(default_text='0.1', key='tim', size=(20, 1)) ], [ sg.T("Status:"), sg.Stretch(), sg.B("Executar", key='exec', size=(10, 1)) ], [sg.Multiline(autoscroll=True, key='multi', disabled=True)]] Window = sg.Window("AutoClicker", layout=Layout, font="SEGOEUI 11") while True: event, values = Window.read(timeout=1000) if event is None: break if event == 'exec': START = Window['in'].Get() END = Window['out'].Get() DO = Window['do'].Get() TIME = float(Window['tim'].Get().replace(",", '.')) if (START == '' or START == ' ' or START is None) or ( END == '' or END == ' ' or END is None) or (DO == '' or DO == ' ' or DO is None) or (
def open_note(name, config): g.SetOptions(background_color=config.background_color, text_color=config.text_color, input_elements_background_color=config.background_color, input_text_color=config.text_color, button_color=(config.text_color, config.background_color), border_width=config.border_width, font=('Arial', int(config.font_size))) with open(NOTES_PATH, 'r+') as notes: note_obj = json.load(notes) match = False content = '' for k, v in note_obj.items(): if name == k: match = True content = v if match == False: print('No Note Found With That Name') exit(1) layout = [[ g.T(name, font=('Arial', int(config.title_size)), justification='center') ], [g.Multiline(content, size=(50, 5), key='content')], [g.B('Close'), g.B('Delete'), g.B('Save')]] window = g.Window('Create', no_titlebar=NTB, keep_on_top=True, grab_anywhere=True, layout=layout, alpha_channel=float(config.alpha)) while True: event, value = window.Read() if event == 'Close': window.Close() break elif event == 'Save': note_obj[name] = value['content'] with open(NOTES_PATH, 'r+') as notes: notes.seek(0) notes.truncate() json.dump(note_obj, notes, indent=4) window.Close() break elif event == 'Delete': new_layout = [[ g.T('Are you sure you want to delete {}?'.format(name), justification='center') ], [g.B('No'), g.B('Yes')]] confirm_window = g.Window('', no_titlebar=NTB, keep_on_top=True, grab_anywhere=True, layout=new_layout) while True: event1, value1 = confirm_window.Read() if event1 == 'Yes': note_obj.pop(name, []) with open(NOTES_PATH, 'r+') as notes: notes.seek(0) notes.truncate() json.dump(note_obj, notes, indent=4) confirm_window.Close() break else: confirm_window.Close() break window.Close() break
from class_yaml2dot import tran_yaml_str2dot_str from yaml2mermaid import tran_yaml_str2mermaid_str import logging as log log.basicConfig(level=log.DEBUG) log.debug("this is a demo massage") sg.theme("DarkAmber") # Add a touch of color # All the stuff inside your window. layout = [ [ sg.Multiline( key="in_yaml", size=(400, 300), enable_events=True, auto_size_text=True, default_text="input yaml here", # do_not_clear=False, ), sg.Column([ [sg.Button("tranDot")], [sg.Button("tranMermaid")], [sg.Button("tran bottom here")], ]), sg.MultilineOutput( size=(400, 300), key="out_dot", auto_size_text=True, default_text="output will be here", font=[sg.DEFAULT_FONT[0], 14], ),
"RADIO2", default=True, size=(180, 22), ), sg.Radio('Fourth Radio!', "RADIO2") ]], title='Options', title_color='red', relief=sg.RELIEF_SUNKEN, tooltip='Use these to set flags', ), sg.Stretch() ], [ sg.Multiline( default_text= 'This is the default Text should you decide not to type anything', size=(220, 80)), sg.Multiline(default_text='A second multi-line', size=(220, 80)) ], [ sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(150, 22)), sg.Stretch(), sg.Slider(range=(1, 100), orientation='h', size=(300, 22), default_value=85) ], [sg.InputOptionMenu(('Menu Option 1', 'Menu Option 2', 'Menu Option 3'))], [ sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(200, 100),
def main(): sg.ChangeLookAndFeel('GreenTan') # sg.SetOptions(element_padding=(0,0)) # ------ Menu Definition ------ # menu_def = [ ['&File', ['&Open', '&Save', '&Properties', 'E&xit']], [ '&Edit', ['&Paste', [ 'Special', 'Normal', ], 'Undo'], ], ['&Toolbar', ['Command &1', 'Command &2', 'Command &3', 'Command &4']], ['&Help', '&About...'], ] treedata = sg.TreeData() treedata.Insert( "", '_A_', 'Tree Item 1', [1, 2, 3], ) treedata.Insert( "", '_B_', 'B', [4, 5, 6], ) treedata.Insert( "_A_", '_A1_', 'Sub Item 1', ['can', 'be', 'anything'], ) treedata.Insert( "", '_C_', 'C', [], ) treedata.Insert( "_C_", '_C1_', 'C1', ['or'], ) treedata.Insert("_A_", '_A2_', 'Sub Item 2', [None, None]) treedata.Insert("_A1_", '_A3_', 'A30', ['getting deep']) treedata.Insert("_C_", '_C2_', 'C2', ['nothing', 'at', 'all']) for i in range(100): treedata.Insert('_C_', i, i, []) frame1 = [ [sg.Input('Input Text', size=(250, 35)), sg.Stretch()], [ sg.Multiline(size=(250, 75), default_text='Multiline Input'), sg.MultilineOutput(size=(250, 75), default_text='Multiline Output') ], ] frame2 = [ [sg.Listbox(['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(200, 85))], [ sg.Combo(['Combo item 1', 'Combo item 2', 'Combo item 3'], size=(200, 35)) ], [sg.Spin([1, 2, 3], size=(40, 30))], ] frame3 = [ [sg.Checkbox('Checkbox1', True), sg.Checkbox('Checkbox1')], [ sg.Radio('Radio Button1', 1), sg.Radio('Radio Button2', 1, default=True), sg.Stretch() ], ] frame4 = [ [ sg.Slider(range=(0, 100), orientation='v', size=(3, 30), default_value=40), sg.Dial(range=(0, 100), tick_interval=50, size=(150, 150), default_value=40), sg.Stretch() ], ] matrix = [[str(x * y) for x in range(4)] for y in range(3)] frame5 = [ [ sg.Table(values=matrix, max_col_width=25, auto_size_columns=True, display_row_numbers=True, change_submits=False, bind_return_key=True, justification='right', num_rows=8, alternating_row_color='lightblue', key='_table_', text_color='black'), sg.Tree(data=treedata, headings=['col1', 'col2', 'col3'], change_submits=True, auto_size_columns=True, num_rows=10, col0_width=10, key='_TREE_', show_expanded=True, size=(200, 150)), sg.Stretch() ], ] graph_elem = sg.Graph((880, 150), (0, 0), (600, 300), key='+GRAPH+') frame6 = [ [graph_elem, sg.Stretch()], ] tab1 = sg.Tab('Graph Number 1', frame6) tab2 = sg.Tab('Graph Number 2', [[]]) layout = [ [sg.Menu(menu_def)], [ sg.Image(data_base64=logo), sg.Frame('Input Text Group', frame1, title_color='red'), sg.Stretch() ], [ sg.Frame('Multiple Choice Group', frame2, title_color='green'), sg.Frame('Binary Choice Group', frame3, title_color='purple'), sg.Frame('Variable Choice Group', frame4, title_color='blue'), sg.Stretch() ], [ sg.Frame('Structured Data Group', frame5, title_color='red'), ], # [sg.Frame('Graphing Group', frame6)], [sg.TabGroup([[tab1, tab2]])], [ sg.ProgressBar(max_value=600, start_value=400, size=(600, 25), key='+PROGRESS+'), sg.Stretch(), sg.ButtonMenu('&Menu', ['Menu', ['&Pause Graph', 'Menu item']], key='_MENU_'), sg.Button('Button'), sg.Button('Exit') ], ] window = sg.Window('Window Title', font=('Helvetica', 13), default_button_element_size=(100, 30), auto_size_buttons=False, default_element_size=(200, 22)).Layout(layout).Finalize() graph_elem.DrawCircle((200, 200), 50, 'blue') i = 0 graph_paused = False while True: # Event Loop # sg.TimerStart() event, values = window.Read(timeout=0) if event is None or event == 'Exit': break if event == 'Button': print(event, values) if values['_MENU_'] == 'Pause Graph': graph_paused = not graph_paused if not graph_paused: i += 1 if i >= 600: graph_elem.Move(-1, 0) graph_elem.DrawLine((i, 0), (i, randint(0, 300)), width=1, color='#{:06x}'.format(randint(0, 0xffffff))) window.FindElement('+PROGRESS+').UpdateBar(i % 600) # sg.TimerStop() window.Close()
gClient.disconnect(wait=True) def im_login(): gClient.add_event_handler("message", tmessage) if gClient.connect(server): print("Connected, start processing messages.") gClient.send_presence() gClient.process(block=False) print("Done.") else: print("Unable to connect.") layout = [[sg.Text("Will start chat.")], [sg.Multiline(key='text', default_text="", do_not_clear=True)], [ sg.InputText(key='message', default_text='please input message here') ], [sg.InputText(key='recv')], [sg.Button("login", key='start')], [sg.Button('send', key='send'), sg.Button('exit', key='exit')]] window = sg.Window("chatting", layout) while True: event, values = window.read() print(event, values) if event == 'exit' or event is None: im_logout() window.close() sys.exit(0)
], [ sg.Checkbox("Tree Implementation", default=True, key='-Tree-', enable_events=True, background_color='NONE', visible=False), sg.Checkbox("Map Implementation", key='-Map-', enable_events=True, background_color='NONE') ], [ sg.Multiline(background_color='WHITE', default_text="Current Playlist:\n", key='-LIKED-') ] ] window = sg.Window('Playlists to improve? Let’s find your groove.', layout, icon="Logo.ico", resizable=False, element_justification='center', background_image="backb.png", force_toplevel=True) dschange = 0 idchange = 0 inputtedsongs = []
[ sg.Slider((1, 10), size=(200, 30), orientation='h', key='+SLIDER 2+'), sg.Stretch() ], [ sg.Checkbox('Checkbox 1', key='+CB1+'), sg.Checkbox('Checkbox 2', key='+CB2') ], [sg.Checkbox('Checkbox 3'), sg.Checkbox('Checkbox 4')], [sg.Radio('Radio1', group_id=1), sg.Radio('Radio2', group_id=1)], [sg.Spin((5, 8), size=(100, 30))], [ sg.Multiline('This is a Multiline Element', size=(300, 300), key='+MULTI+') ], [ sg.Button('My Button', size=(120, 30)), sg.Exit(), sg.Button('Change', key='_CHANGE_') ], ] window = sg.Window('My first QT Window', auto_size_text=True, auto_size_buttons=False, font=('Helvetica', 16)).Layout(layout) while True: