def start_dialog(): left_frame = [[sg.Image(filename='', key='_IMAGE_')]] right_frame = [[sg.Image(filename='', key='_PERSON_')], [sg.Text("Who is it?")], [sg.Input()], [sg.Button('Capture')], [sg.Button('Quit')]] layout = [[sg.Frame("", left_frame), sg.Frame("", right_frame)]] window = sg.Window('Face recognition training centre', layout) cap = cv2.VideoCapture(0) ret, frame = cap.read() mirror = flipHorizontal = cv2.flip(frame, 1) while True: event, values = window.Read(timeout=20, timeout_key='timeout') if event is None or event == 'Quit': break if event == 'Capture': person_name = values[0] if person_name is not None and person_name != "": process_image(person_name, frame) ret, frame = cap.read() mirror = flipHorizontal = cv2.flip(frame, 1) imgbytes = cv2.imencode('.png', mirror)[1].tobytes() window.FindElement('_IMAGE_').Update(data=imgbytes) person_img = get_first_face(mirror, 200, 200) if person_img is not None: imgbytes = cv2.imencode('.png', person_img)[1].tobytes() window.FindElement('_PERSON_').Update(data=imgbytes) window.close() cap.release()
def restore_from_seed(self): logger.debug('In restore_from_seed') from mnemonic import Mnemonic MNEMONIC = Mnemonic(language="english") info1 = ( "Please enter your BIP39 seed phrase in order to restore your wallet." ) layout = [[sg.Text("Enter Seed")], [sg.Text(info1)], [sg.InputText(key='seed')], [ sg.Checkbox('Extends this seed with custom words', key='use_passphrase') ], [sg.Button('Back'), sg.Button('Next')]] window = sg.Window("Satochip-Bridge: Enter seed", layout, icon=self.satochip_icon) while True: event, values = window.read() if event == 'Next': if not MNEMONIC.check( values['seed']): # check that seed is valid self.client.request( 'show_error', "Invalid BIP39 seed! Please type again!") else: break else: # event=='Back' break window.close() del window # logger.debug("Event:"+str(type(event))+str(event)) # logger.debug("Values:"+str(type(values))+str(values)) return (event, values)
def category_to_layout(category_info): titles = [] links = [] frameworks = [] col1 = [] col2 = [] count = 0 for model in category_info['models']: if model.get('title'): titles.append(model['title'][0:60]) else: titles.append('null') if model.get('link'): links.append(model['link'].replace('https://github.com/', '')) else: links.append('null') if model.get('framework'): frameworks.append(model['framework']) else: frameworks.append('null') for x in range(len(titles)): if (count % 2) != 0: col1.append([ g.Button(titles[x] + ' | ' + frameworks[x], key='https://github.com/' + links[x]) ]) else: col2.append([ g.Button(titles[x] + ' | ' + frameworks[x], key='https://github.com/' + links[x]) ]) count += 1 return col1, col2
def themewindow(): config = ConfigParser() config.read('config.cfg') layout = [[gui.T('Choose Theme')], [ gui.Radio('Light', 'RADIO1'), gui.Radio('Dark', 'RADIO01', key='_THEME_') ], [gui.Button('Exit'), gui.Button('Enter')]] window = gui.Window('Theme Picker', no_titlebar=True, keep_on_top=True, grab_anywhere=True).Layout(layout) while True: event, values = window.Read() if event == 'Exit': break elif event == 'Enter': if values['_THEME_'] == True: config['DEFAULT']['theme'] = 'dark' with open('config.cfg', 'w') as f: config.write(f) break elif values['_THEME_'] == False: config['DEFAULT']['theme'] = 'light' with open('config.cfg', 'w') as f: config.write(f) break config.read('config.cfg') theme = config['DEFAULT']['theme'] window.Close() return theme
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 futureRestoreQuestion(): p.SetOptions(background_color='white', button_color=('white', '#4286f4')) layout = [ [ p.Text('I noticed this is your first time running EGTR!', font=('Arial', 12, 'bold'), justification='center') ], [ p.Text( 'You have to download FutureRestore first. Press Continue to do so.', font=('Arial', 10, 'italic'), justification='center') ], [p.Button('Cancel'), p.Button('Continue')] ] window = p.Window('EGTR', no_titlebar=True, keep_on_top=True, grab_anywhere=True).Layout(layout) while True: event, values = window.Read() if event == 'Cancel': window.Close() exit() elif event == 'Continue': downloadFutureRestore() window.Close() exit()
def selectMetricsToCollectPopup( listOptions, listAlreadySelectedValues ): #opens "select metrics" dialog window, returns the checked values. checkBoxColumn = [[ pygui.Checkbox( text=str(option), key=str(option), default=(True if (option in listAlreadySelectedValues) else False)) ] for option in listOptions if option not in ["unixTime"]] checkWindow = pygui.Window( title="Select metrics to be collected", layout=[[pygui.Text("Selct metrics to be collected")], [ pygui.Column(checkBoxColumn, size=(300, 300), scrollable=True) ], [ pygui.Button("OK"), pygui.Button("Select all"), pygui.Button("Select none") ]]) #create window #main window loop event, values = checkWindow.read() if (event == "Select all"): checkWindow.close() return selectMetricsToCollectPopup(listOptions, listOptions) if (event == "Select none"): checkWindow.close() return selectMetricsToCollectPopup(listOptions, {}) if event in [pygui.WIN_CLOSED, "OK"]: #if window is closed or "OK" button pressed checkWindow.close() #close window we opened earlier return [key for key in values if values[key]] + ["unixTime"]
def QRDialog(self, data, parent=None, title="Satochip-Bridge: QR code", show_text=False, msg=''): logger.debug('In QRDialog') import pyqrcode code = pyqrcode.create(data) image_as_str = code.png_as_base64_str(scale=5, quiet_zone=2) #string image_as_str = base64.b64decode(image_as_str) #bytes layout = [[sg.Image(data=image_as_str, tooltip=None, visible=True)], [sg.Text(msg)], [ sg.Button('Ok'), sg.Button('Cancel'), sg.Button('Copy 2FA-secret to clipboard') ]] window = sg.Window(title, layout, icon=self.satochip_icon) while True: event, values = window.read() if event == 'Ok' or event == 'Cancel': break elif event == 'Copy 2FA-secret to clipboard': pyperclip.copy(data) window.close() del window pyperclip.copy('') #purge 2FA from clipboard # logger.debug("Event:"+str(type(event))+str(event)) # logger.debug("Values:"+str(type(values))+str(values)) return (event, values)
def main_layout(self): """ A method that returns a frame layout object for the entire window's frame Returns: frame layout object """ layout = [[ Qt.Frame('Sensor Information', layout=self.sense_frame_layout(), size=(450, 450)) ], [ Qt.Button('', enable_events=True, key='quit_button', image_data=self.icons.quit, tooltip='Quit', button_color=(Qt.theme_text_color(), Qt.theme_background_color()), border_width=0), Qt.Button('', enable_events=True, key='refresh_all_button', tooltip='Refresh All', image_data=self.icons.refresh, border_width=0, button_color=(Qt.theme_text_color(), Qt.theme_background_color())) ]] return layout
def build_ext_window(self): self.layout = self.build_basic_layout() for param, param_info in self.effect_params.items(): if param in ['self', 'area']: continue if param_info.annotation is Color: self.layout.extend([[sg.Text(param)], [ sg.Input(visible=False, enable_events=True, key=f'COLOR_{param}'), sg.ColorChooserButton( 'Pick a color', key=f'COLOR_{param}_btn', target=f'COLOR_{param}') ]]) elif param_info.annotation is List[Color]: self.layout.extend([[sg.Text(param)]]) for i in range(8): self.layout.extend( [[ sg.Input(visible=False, enable_events=True, key=f'COLOR_LIST_{i}_{param}') ], [ sg.ColorChooserButton( 'Pick a color', key=f'COLOR_LIST_{i}_{param}_btn', target=f'COLOR_LIST_{i}_{param}') ]]) else: self.layout.extend([[ sg.Text(param) ], [sg.InputText(key=param, default_text=param_info.default)]]) self.layout.extend( [[sg.Button('Run', key='RUN')], [sg.Button('Stop', key='STOP', visible=False)], [sg.Button('Save as default', key='SAVE', visible=True)], [ sg.Button('Load defaults', key='LOAD', visible=self.has_defaults) ], [ sg.Text('Waiting for the effect thread to stop...', justification='center', key='STOP_TXT', visible=False), sg.Input(visible=False, enable_events=True, key='THREAD_STOPPED') ]]) self.window = sg.Window('Mystic Why', self.layout, finalize=True)
def _button_frame_(): """ Create a frame for our buttons at the bottom of the window :returns: Button frame object :rtype: """ import PySimpleGUIQt as qt b_frame = [[ qt.Button('Make Another', key='dupe'), qt.Button('Exit', key='top_win_exit') ]] return b_frame
def main(): sg.ChangeLookAndFeel('LightGreen') # define the window layout layout = [[ sg.Text('OpenCV Demo', size=(40, 1), justification='center', font='Helvetica 20') ], [sg.Image(filename='', key='image')], [ sg.Button('Record', size=(10, 1), font='Helvetica 14'), sg.Button('Stop', size=(10, 1), font='Any 14'), sg.Button('Exit', size=(10, 1), font='Helvetica 14'), sg.Button('About', size=(10, 1), font='Any 14') ]] # create the window and show it without the plot window = sg.Window('Demo Application - OpenCV Integration', location=(800, 400)) window.Layout(layout) # ---===--- Event LOOP Read and display frames, operate the GUI --- # cap = cv2.VideoCapture(0) recording = False while True: event, values = window.Read(timeout=0, timeout_key='timeout') if event == 'Exit' or event is None: sys.exit(0) pass elif event == 'Record': recording = True elif event == 'Stop': recording = False img = np.full((480, 640), 255) imgbytes = cv2.imencode('.png', img)[1].tobytes( ) #this is faster, shorter and needs less includes window.FindElement('image').Update(data=imgbytes) elif event == 'About': sg.PopupNoWait( 'Made with PySimpleGUI', 'www.PySimpleGUI.org', 'Check out how the video keeps playing behind this window.', 'I finally figured out how to display frames from a webcam.', 'ENJOY! Go make something really cool with this... please!', keep_on_top=True) if recording: ret, frame = cap.read() imgbytes = cv2.imencode('.png', frame)[1].tobytes() #ditto window.FindElement('image').Update(data=imgbytes)
def first_menu(self): layout = [ [g.T('Charlatano GUI Settings v1.1', font=('Arial', 15))], [g.T('Made by Max Bridgland', font=('Arial', 10))] ] count = 0 col1 = [] col2 = [] for k, v in self.parser.current_settings.items(): title = str(k[0].upper() + k[1:].lower().replace('_', ' ')) if (count % 2) == 0: col1.append([ g.B(' ' + title + ' ', key=k) ]) count += 1 else: col2.append([ g.B(' ' + title + ' ', key=k) ]) count += 1 layout.append([ g.Column(col1), g.Column(col2) ]) layout.append([ g.Button('Close'), g.Button('Restart Charlatano', key='__RESTART__'), g.Button('Start Charlatano', key='__START__') ]) window = g.Window('Charlatano GUI Settings', no_titlebar=True, grab_anywhere=True, keep_on_top=True, layout=layout) charla = Runner() while True: event, values = window.Read() print(event) if event == 'Close': window.Close() exit() elif event == '__START__': if charla.running and charla.proc: charla.killCharlatano() window.FindElement('__START__').Update('Start Charlatano') else: charla.runCharlatano() window.FindElement('__START__').Update('Stop Charlatano') elif event == '__RESTART__': charla.restartCharlatano() if charla.running: window.FindElement('__START__').Update('Stop Charlatano') else: window.Close() self.settings_gui(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 __init__(self): super().__init__("Exercise-Loop") self.current_ex_sol_pair_id = None self.btn_show_solution = sg.Button("Show Solution", enable_events=True, key="-Solution-") self.display_solution = False self.keys = ["-Solution-"] self.children = [] self.solution_image = None self.exercise_image = None self.rows = [] self.check_boxes = [] self.valid_ids = [] self.all_ids = [] self.id_collecion_name_dict = {} self.current_human_id = 0 # Todo: Limit to Toplevel/Add another limit, otherwise the ui will # turn crowded with BackendSession() as session: collections: List[ExerciseCollection] = session.query( ExerciseCollection).all() self.all_ids = [el.collection_id for el in collections] self.valid_ids = [el.collection_id for el in collections] for collection_el in collections: self.id_collecion_name_dict.update( {collection_el.collection_id: collection_el.name}) self.load_exercise_solution()
def show_clip_list_window(self, clips): """ Show all received clips in a Windows with a Listview and allow user select and copy an entry """ # TODO: Show Only preview of Clip to reduce length layout = [ [ sg.Listbox( values=clips, size=(60, 6), select_mode="LISTBOX_SELECT_MODE_SINGLE", key="sel_clip", ) ], [sg.Button("Copy to clipboard", size=(20, 1)), sg.Cancel(size=(20, 1))], ] window = sg.Window( title=f"{Config.APP_NAME} - Your Clips", layout=layout, size=(600, 300), icon=Config.ICON_B64, ) event, values = window.read() if event in (sg.WIN_CLOSED, "Cancel"): log.debug("List Clips selection canceled") pass elif event == "Copy to clipboard": Api.paste(values.get("sel_clip")[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()
def init_gui(): global window global adapters global values sg.theme("Reddit") layout_frame = [ [sg.Checkbox("DHCP", key="DHCP", enable_events=True)], [sg.Text("")], [sg.Text("IP: ", size=(15, 1)), sg.Input(size=(15, 1), key="IP")], [sg.Text("Sub: ", size=(15, 1)), sg.Input(size=(15, 1), key="SUB")], [ sg.Text("Gateway: ", size=(15, 1)), sg.Input(size=(15, 1), key="GATE") ], ] layout = [[ sg.Combo(adapters, enable_events=True, key="DROP", readonly=True), ], [ sg.Frame( "Network", layout_frame, ), ], [sg.Button("Update", size=(15, 1), key="UPDATE")]] window = sg.Window("IP", layout, icon="favicon.png") window.read(1) update_text(window, 0)
def continue_anyway(issue): # Set-up the logger log = getLogger(f'{PROG}.{__name__}') log.debug('Received request to produce a "continue?" popup window.') # Provide a layout for our window logo_frame = [[Qt.Image('/home/taylor/Pictures/logo.png', key='img_elm')]] button_frame = [ [Qt.Button('Yes')] ] main_layout = [ [Qt.Frame('', layout=logo_frame, element_justification='center', size=(40, 40))], [] ] window = Qt.Window('Continue Anyway?', layout=main_layout) while True: event, vals = window.read(timeout=100) if event is None or vals == 'exit': log.debug('User leaving window by click')
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 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 button_frame(): _layout = [[ qt.Button('OK', enable_events=True, key='settings_win_ok_bttn', bind_return_key=True), qt.Button('Apply', enable_events=True, key='settings_win_apply_bttn', visible=False), qt.Button('Cancel', enable_events=True, key='settings_win_cancel_bttn', visible=False) ]] _frame = qt.Frame('', _layout) return _frame
def reset_seed_dialog(self, msg): logger.debug('In reset_seed_dialog') layout = [[sg.Text(msg)], [sg.InputText(password_char='*', key='pin')], [sg.Checkbox('Also reset 2FA', key='reset_2FA')], [sg.Button('Ok'), sg.Button('Cancel')]] window = sg.Window("Satochip-Bridge: Reset seed", layout, icon=self.satochip_icon) event, values = window.read() window.close() del window # logger.debug("Event:"+str(type(event))+str(event)) # logger.debug("Values:"+str(type(values))+str(values)) #Event:<class 'str'>Ok #Values:<class 'dict'>{'passphrase': 'toto', 'reset_2FA': False} return (event, values)
def yes_no_question(self, question): logger.debug('In yes_no_question') layout = [[sg.Text(question)], [sg.Button('Yes'), sg.Button('No')]] #window = sg.Window('Satochip-Bridge: Confirmation required', layout, icon=SatochipBase64) #NOK window = sg.Window('Satochip-Bridge: Confirmation required', layout, icon=self.satochip_icon) #ok #window = sg.Window('Satochip-Bridge: Confirmation required', layout, icon="satochip.ico") #ok event, value = window.read() window.close() del window #logger.debug("Type of event from getpass:"+str(type(event))+str(event)) if event == 'Yes': return True else: # 'No' or None return False
def approve_action(self, question): logger.debug('In approve_action') layout = [ [sg.Text(question)], [ sg.Checkbox( 'Skip confirmation for this connection (not recommended)', key='skip_conf') ], [sg.Button('Yes'), sg.Button('No')] ] window = sg.Window('Satochip-Bridge: Confirmation required', layout, icon=self.satochip_icon) #ok event, values = window.read() window.close() del window return (event, values)
def __init__(self): layout = [[sg.Text('Enter Text')], [sg.Input(size=(17, 1), key='input1', do_not_clear=True)], [ sg.InputText(size=(17, 1), key='input2', do_not_clear=True) ], [sg.Button('on-screen keyboard', key='keyboard')], [sg.Button('close', key='close')]] self.mainWindow = sg.Window( 'On-screen test', grab_anywhere=True, no_titlebar=False, ).Layout(layout).Finalize() self.keyboard = keyboard() self.focus = None
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(): layout = [[ gui.T('Have You Installed Theos Before? ', font=('Arial', 10), justification='center') ], [ gui.Radio('No', 'RADIO1', default=True), gui.Radio('Yes', 'RADIO1', key='_RADIOYES_', default=True) ], [gui.Button('Exit'), gui.Button('Enter')]] window = gui.Window('Check Theos Install', no_titlebar=True, keep_on_top=True, grab_anywhere=True).Layout(layout) while True: event, values = window.Read() if event == 'Exit': exit() break if event == 'Enter': if values['_RADIOYES_'] == True: window.Close() break elif values['_RADIOYES_'] == False: while True: window2 = gui.Window( 'Open Tutorial', no_titlebar=True, keep_on_top=True, grab_anywhere=True).Layout([[ gui.Text('Please Install Theos First ', justification='center') ], [gui.Button('Exit'), gui.Button('Open Link')]]) event, values = window2.Read() if event == 'Exit': window2.Close() break elif event == 'Open Link': webbrowser.open_new_tab( 'https://github.com/theos/theos') window2.Close() break theosgui()
def __init__(self): self.result = "" self.layout = [ [sg.Text("Enter the linear equation"), sg.In(key="lneq")], [sg.Button("Evaluate", enable_events=True, key="eval")], [sg.Text("Result:"), sg.Text(text="", key="result")], ]
def create_seed(self, seed): logger.debug('In create_seed') warning1 = ( "Please save these 12 words on paper (order is important). \nThis seed will allow you to recover your wallet in case of computer failure." ) warning2 = ("WARNING:") warning3 = ( "*Never disclose your seed.\n*Never type it on a website.\n*Do not store it electronically." ) layout = [[sg.Text("Your wallet generation seed is:")], [sg.Text(seed)], [ sg.Checkbox('Extends this seed with custom words', key='use_passphrase') ], [sg.Text(warning1)], [sg.Text(warning2)], [sg.Text(warning3)], [ sg.Button('Back'), sg.Button('Next'), sg.Button('Copy seed to clipboard') ]] window = sg.Window("Satochip-Bridge: Create seed", layout, icon=self.satochip_icon) while True: event, values = window.read() if event == 'Back' or event == 'Next': break elif event == 'Copy seed to clipboard': try: pyperclip.copy(seed) except PyperclipException as e: logger.warning("PyperclipException: " + str(e)) self.client.request('show_error', "PyperclipException: " + str(e)) window.close() del window logger.debug("Event:" + str(type(event)) + str(event)) logger.debug("Values:" + str(type(values)) + str(values)) #Event:<class 'str'>Next #Values:<class 'dict'>{'use_passphrase': False} return (event, values)