def load_exercise_solution(self) -> None: session: Session with BackendSession.begin() as session: if self.current_ex_sol_pair_id: current_pair: ExerciseSolutionPair = session.query( ExerciseSolutionPair).filter_by( internal_id=self.current_ex_sol_pair_id).one() current_pair.attempt_counter += 1 next_pair = determine_next_exercise_solution_pair( session, self.valid_ids) self.current_ex_sol_pair_id = next_pair.internal_id self.current_human_id = next_pair.human_id exercise_file_path = retrieve_file(BaseConfig.exercise_path, next_pair.human_id) solution_file_path = retrieve_file(BaseConfig.solution_path, next_pair.human_id) image_bytes_exercise = convert_to_bytes(str(exercise_file_path), resize=(700, 700)) image_bytes_solution = convert_to_bytes(str(solution_file_path), resize=(700, 700)) self.exercise_image = sg.Image(data=image_bytes_exercise, size=(100, 100)) self.solution_image = sg.Image(data=image_bytes_solution, size=(100, 100))
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 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 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 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(): 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 statusMenu(): if os.path.exists(CONF_PATH) == True: config = ConfigParser() config.read(CONF_PATH) devId = config['DEVICE']['model'] else: devId = '' layout = [[p.T('Enter Device Identifier [ex: iPhone8,1]: ')], [p.Input(devId, key='_DEVID_', do_not_clear=True)], [ p.Image(data_base64=Images.close_b, click_submits=True, key='Close'), p.Image(data_base64=Images.start_b, click_submits=True, key='Start') ]] lmao = p.Window('Sushi Status', no_titlebar=True, keep_on_top=True, grab_anywhere=True).Layout(layout) while True: event, values = lmao.Read() if event == 'Start': devId = values['_DEVID_'] signed = getSignedFirmwares(devId) p.Window( 'Signed Firmwares', keep_on_top=True, grab_anywhere=True, no_titlebar=True, auto_close=True, auto_close_duration=5).Layout([[ p.T('Signed Firmwares:' + signed, justification='center') ]], ).Read() elif event == 'Close': break lmao.Close()
def test2(): layout = [[sg.Text('请输入用户名和密码',text_color='blue', background_color='green')], [sg.Image(filename="/Users/netbox-wangdong/Downloads/logo-srap.png")], [sg.Input(default_text="请输入账号",background_color='yellow',text_color='blue')], [sg.Input(default_text="请输入密码",password_char='*')], [sg.Button('登录',size=(5,2),button_color=('red','yellow'),visible=True,tooltip="click me" ), sg.Button("退出",size=(5,1))]] window = sg.Window('pyRoboartIM登录窗口', layout,location=(500,100)) while True: event, values = window.Read() if event is None or event == 'Exit': break print(event, values) window.Close()
def finishedPopup(devId, ecid, boardconfig, version, latest): output = saveBlobs(ecid, devId, boardconfig, version, latest) layout = [[ p.MultilineOutput(str(output), background_color='#000000', text_color='#ffffff', key='_OUTPUT_', do_not_clear=True, size=(1000, 500)) ], [p.Image(data_base64=Images.close_b, key='Close', click_submits=True)]] window = p.Window('Finished', keep_on_top=True, grab_anywhere=True, no_titlebar=True).Layout(layout) while True: event, values = window.Read() if event == 'Close': window.Close() break
def layout(self): # fmt: off self.img = psg.Image(filename=None) return [ [self.img], [ psg.Text(self.cfg.uie.eval_text), psg.Input(key=self.cfg.uie.eval_key), psg.FileBrowse(self.cfg.uie.browse_btn, file_types=self.cfg.uie.allowed_files) ], [ psg.Text(self.cfg.uie.gt_text), psg.Input(key=self.cfg.uie.gt_key), psg.FileBrowse(self.cfg.uie.browse_btn, file_types=self.cfg.uie.allowed_files) ], [psg.Button(cfg.uie.eval_btn)], ]
def create_main_window(settings, status, loc=(None,None)): sg.theme(settings['color_theme']) layout = [ [sg.Image('assets/RVB_FRAMATOME_HD_15pct.png')], [sg.Text('REPS Tracking System', justification='center', font=('Work Sans', 14))], [sg.Text(' '*30)], [sg.Text(' '*30)], [sg.Text(size=(16,1)), sg.Text(justification='left', font=('Work Sans', 20), key='-XPOS-')], [sg.Text(size=(16,1)), sg.Text(justification='left', font=('Work Sans', 20), key='-YPOS-')], [sg.Text(size=(16,1)), sg.Text(justification='left', font=('Work Sans', 20), key='-ZPOS-')], [sg.Text(' '*40)], [sg.Button('Save Current Position', font=('Work Sans', 12))], [sg.Text('_'*64)], [sg.Text(' '*40)], [sg.Text(' Status: ', size=(11,1), font=('Work Sans', 20)), #sg.Text('Acquiring Location', size=(34,2), font=('Work Sans', 20), justification='left', text_color='yellow', key='-MSG-')], sg.Text(status, size=(34,2), font=('Work Sans', 20), justification='left', text_color='yellow', key='-MSG-')], [sg.Text(' '*40)], [sg.Text(' '*40)], [sg.Button('Exit', font=('Work Sans', 12)), sg.Button('Settings', font=('Work Sans', 12))], ] return sg.Window('REPS', layout=layout, keep_on_top=True, location=loc, resizable=False, icon='assets/favicon.ico')
def helpMenu(): layout = [[p.T('Help Menu', font=('Corbel', 13), justification='left')], [ p.T('''Status: - Use the Status tool to check for signed firmwares. - Press the Status button on the bottom. - Enter Device Identifier [ex. iPhone8,1] - Press Start and it will display available signed firmwares. Saving Blobs: - You only have to enter information the first time you save blobs. - Enter ECID - Enter Device Identifier - Enter Boardconfig (You can obtain this from BMSSM) - Enter Version You Would Like To Save Blobs For Or Check Latest iOS - Press Start and Check Your Terminal For Output - For some reason it seems to save blobs for all signed versions automatically so either way you should be safe ¯\_(ツ)_/¯ Support: - Either open up an Issue on GitHub (click the logo on the main screen) or contact me on Twitter (@maxbridgland or click my name on the main screen).''' ) ], [ p.Image(data_base64=Images.close_b, click_submits=True, key='Close') ]] lol = p.Window('Sushi Help', no_titlebar=True, keep_on_top=True, grab_anywhere=True).Layout(layout) while True: event, values = lol.Read() if event == 'Close': break lol.Close()
def mainScreen(): p.SetOptions(background_color='white', button_color=('white', '#4286f4')) layout = [ [ p.Image(data_base64=Images.logo, background_color='white', size=(450, 100), click_submits=True, key='_IMAGE_') ], [p.T('Required:', font=('Arial', 13, 'bold'), justification='center')], [p.T('▬' * 35, justification='center')], [ p.T('Choose IPSW Filepath: ', font=('Arial', 10, 'italic'), justification='left') ], [ p.Input('', key='_IPSW_'), p.FileBrowse(button_color=('white', '#4286f4')) ], [ p.T('Choose Blobs Filepath: ', font=('Arial', 10, 'italic'), justification='left') ], [ p.Input('', key='_BLOBS_'), p.FilesBrowse(button_color=('white', '#4286f4')) ], [ p.T('Choose SEP Filepath: ', font=('Arial', 10, 'italic'), justification='left') ], [ p.Input('', key='_SEP_'), p.FileBrowse(button_color=('white', '#4286f4')) ], [ p.Checkbox( 'Use Latest SEP \n(Do Not Set SEP Filepath If Using This!)', key='_LATESTSEP_') ], [ p.T('Choose Baseband Filepath: ', font=('Arial', 10, 'italic'), justification='left') ], [ p.Input('', key='_BASE_'), p.FileBrowse(button_color=('white', '#4286f4')) ], [ p.Checkbox( 'Use Latest Baseband \n(Do Not Set Baseband Filepath If Using This!)', key="_LATESTBASE_") ], [ p.T('Optional: ', font=('Arial', 13, 'bold'), justification='center') ], [p.T('▬' * 35, justification='center')], [ p.T('SEP Manifest: ', font=('Arial', 10, 'italic'), justification='left') ], [ p.Input('', key='_SEPMANI_'), p.FileBrowse(button_color=('white', '#4286f4')) ], [ p.T('Baseband Build Manifest: ', font=('Arial', 10, 'italic'), justification='left') ], [ p.Input('', key='_BASEMANI_'), p.FileBrowse(button_color=('white', '#4286f4')) ], [ p.T('Optional Flags:', justification='center', font=('Arial', 13, 'bold')) ], [p.T('▬' * 35, justification='center')], [ p.Checkbox('Debug', key='_DEBUG_'), p.Checkbox('No Baseband', key='_NOBASEBAND_') ], [ p.Checkbox('Update', key='_UPDATE_'), p.Checkbox('Wait', key="_WAIT_") ], [p.T('▬' * 35, justification='center')], [ p.Button('Exit Recovery', size=(23, 1)), p.Button('Start', size=(23, 1)) ], [p.Button('Exit', size=(23, 1)), p.Button('Donate', size=(23, 1))], [ p.Button('Open TSSSaver', size=(23, 1)), p.Button('Open ipsw.me', size=(23, 1)) ], [ p. T('\nVersion: 1.0.6 | Licensed Under GNU GPLv3 | Click Here For GitHub', click_submits=True, key='_FOOTER_', font=('Arial', 8, 'italic'), justification='center') ] ] window = p.Window('EGTR', no_titlebar=True, keep_on_top=True, grab_anywhere=True).Layout(layout) while True: event, values = window.Read() if event == 'Exit': window.Close() break elif event == 'Exit Recovery': if getTypeFutureRestore() == 1: futurerestore = getRealPath(DOWNLOAD_DIRECTORY + '/futurerestore') elif getTypeFutureRestore() == 2: futurerestore = getRealPath(DOWNLOAD_DIRECTORY + '/futurerestore.exe') os.system(futurerestore + '--exit-recovery') p.Window('Logs:', no_titlebar=True, keep_on_top=True, grab_anywhere=True, auto_close=True, auto_close_duration=5).Layout( [[p.T('Refer To The Terminal For Output ')]]).Read() elif event == 'Donate': webbrowser.open_new_tab('https://paypal.me/m4csdev') elif event == 'Open TSSSaver': webbrowser.open_new_tab('https://tsssaver.1conan.com/') elif event == 'Open ipsw.me': webbrowser.open_new_tab('https://ipsw.me') elif event == '_FOOTER_': webbrowser.open_new_tab( 'https://github.com/M4cs/EGTR-Futurerestore') elif event == 'Start': if values['_LATESTSEP_'] == True: latestsep = ' --latest-sep' sep_path = '' elif values['_LATESTSEP_'] == False: latestsep = '' if values['_LATESTBASE_'] == True: latestbase = ' --latest-baseband' base_path = '' elif values['_LATESTBASE_'] == False: latestbase = '' if values['_IPSW_'] == '': p.Window('Error', auto_close=True, auto_close_duration=3, keep_on_top=True, no_titlebar=True, grab_anywhere=True).Layout([[ p.T('Error: You must enter an IPSW! ') ]]).Read() elif values['_IPSW_'] != '': ipsw_path = " " + getRealPath(values['_IPSW_']) if values['_SEP_'] == '': if values['_LATESTSEP_'] == True: latestsep = '--latest-sep' sep_path = '' elif values['_LATESTSEP_'] == False: p.Window( 'Error', auto_close=True, auto_close_duration=3, keep_on_top=True, no_titlebar=True, grab_anywhere=True ).Layout([[ p. T('Error: You must enter an SEP path or choose Use Latest! ' ) ]]).Read() elif values['_SEP_'] != '': if values['_LATESTSEP_'] == True: sep_path = '' latestsep = ' --latest-sep' elif values['_LATESTSEP_'] == False: sep_path = ' -s ' + getRealPath(values['_SEP_']) latestsep = '' if values['_BASE_'] == '': if values['_LATESTBASE_'] == True: base_path = '' latestbase = ' --latest-base' elif values['_LATESTBASE_'] == False: p.Window( 'Error', auto_close=True, auto_close_duration=3, keep_on_top=True, no_titlebar=True, grab_anywhere=True ).Layout([[ p. T('Error: You must enter an Base path or choose Use Latest! ' ) ]]).Read() elif values['_BASE_'] != '': if values['_LATESTBASE_'] == True: base_path = '' latestbase = ' --latest-base' elif values['_LATESTBASE_'] == False: base_path = ' -b ' + getRealPath(values['_BASE_']) latestbase = '' if values['_BLOBS_'] == '': p.Window('Error', auto_close=True, auto_close_duration=3, keep_on_top=True, no_titlebar=True, grab_anywhere=True).Layout([[ p.T('Error: You must choose SHSH2 Blobs! ') ]]).Read() elif values['_BLOBS_'] != '': blobs_path = ' -t' + getRealPath(values['_BLOBS_']) if values['_DEBUG_'] == True: debug = ' -d' elif values['_DEBUG_'] == False: debug = '' if values['_BASEMANI_'] == '': basemani = '' elif values['_BASEMANI_'] != '': basemani = ' -p' + values['_BASEMANI_'] if values['_SEPMANI_'] == '': sepmani = '' elif values['_SEPMANI_'] != '': sepmani = ' -m ' + values['_SEPMANI_'] if values['_NOBASEBAND_'] == True: nobaseband = ' --no-baseband' base_path = '' basemani = '' elif values['_NOBASEBAND_'] == False: nobaseband = '' if values['_UPDATE_'] == True: update = ' -u' elif values['_UPDATE_'] == False: update = '' if values['_WAIT_'] == True: wait = ' -w' elif values['_WAIT_'] == False: wait = '' if getTypeFutureRestore() == 1: futurerestore = getRealPath(DOWNLOAD_DIRECTORY + '/futurerestore') elif getTypeFutureRestore() == 2: futurerestore = getRealPath(DOWNLOAD_DIRECTORY + '/futurerestore.exe') query = futurerestore + blobs_path + base_path + sep_path + latestbase + latestsep + debug + basemani + sepmani + update + nobaseband + wait + ipsw_path print(query) outputscreen = p.Window( 'Logs:', no_titlebar=True, keep_on_top=True, grab_anywhere=True ).Layout([[ p. T('Are You Sure? You may risk bootlooping or bricking your device! ' ) ], [p.Button('Cancel'), p.Button('Continue')]]) while True: event, values = outputscreen.Read() if event == 'Continue': p.Window('Logs:', no_titlebar=True, keep_on_top=True, grab_anywhere=True, auto_close=True, auto_close_duration=5).Layout([[ p.T('Refer To The Terminal For Output ') ]]).Read() outputscreen.Close() os.system(query) break elif event == 'Cancel': outputscreen.Close() break window.Close()
def displayImages(): sg.ChangeLookAndFeel('LightGrey') folder = sg.popup_get_folder('Image folder to open', title='Choose Folder', default_path='') img_types = (".png", ".jpg", "jpeg", ".tiff", ".bmp") flist0 = os.listdir(folder) fnames = [f for f in flist0 if os.path.isfile( os.path.join(folder, f)) and f.lower().endswith(img_types)] num_files = len(fnames) del flist0 def get_img_data(f, maxsize=(1200, 850), first=False): img = Image.open(f) img.thumbnail(maxsize) if first: bio = io.BytesIO() img.save(bio, format="PNG") del img return bio.getvalue() return ImageTk.PhotoImage(img) filename = os.path.join(folder, fnames[0]) image_elem = sg.Image(data=get_img_data(filename, first=True)) filename_display_elem = sg.Text(filename, size=(80, 3)) file_num_display_elem = sg.Text('File 1 of {}'.format(num_files), size=(15, 1)) col = [[filename_display_elem], [image_elem]] col_files = [[sg.Text('List of images')], [sg.Listbox(values=fnames, change_submits=True, size=(60, 10), key='listbox')], [sg.Button('Next', size=(8, 1)), sg.Button('Prev', size=(8, 1)), file_num_display_elem], [sg.Button('Enhance Resolution', size=(16, 1))], [sg.Button('Exit', size=(8, 1))]] layoutSavedImages = [[sg.Column(col_files), sg.Column(col)]] window = sg.Window('Image Browser', layoutSavedImages, return_keyboard_events=True, location=(0, 0), use_default_focus=False) i = 0 im = 0 while True: event, values = window.read() print(event, values) if event == sg.WIN_CLOSED or event == 'Exit': raise SystemExit() elif event in ('Next', 'MouseWheel:Down', 'Down:40', 'Next:34'): i += 1 if i >= num_files: i -= num_files filename = os.path.join(folder, fnames[i]) elif event in ('Prev', 'MouseWheel:Up', 'Up:38', 'Prior:33'): i -= 1 if i < 0: i = num_files + i filename = os.path.join(folder, fnames[i]) elif event == 'listbox': f = values["listbox"][0] filename = os.path.join(folder, f) i = fnames.index(f) elif event == 'Enhance Resolution': filename = os.path.join(folder, fnames[i]) super_res(filename, im) im += 1 print(filename) else: filename = os.path.join(folder, fnames[i]) image_elem.update(data=get_img_data(filename, first=True)) filename_display_elem.update(filename) file_num_display_elem.update('File {} of {}'.format(i+1, num_files)) window.close()
# some information on processing single frame if total > 0: elap = (end - start) print("[INFO] single frame took {:.4f} seconds".format(elap)) print("[INFO] estimated total time to finish: {:.4f}".format( elap * total)) #write the output frame to disk writer.write(frame) imgbytes = cv2.imencode('.png', frame)[1].tobytes() # ditto if not win_started: win_started = True layout = [[ sg.Text('Yolo Playback in PySimpleGUI Window', size=(30, 1)) ], [sg.Image(data=imgbytes, key='_IMAGE_')], [ sg.Text('Confidence'), sg.Slider(range=(0, 10), orientation='h', resolution=1, default_value=5, size=(15, 15), key='confidence'), sg.Text('Threshold'), sg.Slider(range=(0, 10), orientation='h', resolution=1, default_value=3, size=(15, 15), key='threshold')
def mainScreen(): if os.path.exists(CONF_PATH) == True: config = ConfigParser() config.read(CONF_PATH) model = config['DEVICE']['model'] ecid = config['DEVICE']['ecid'] boardconfig = config['DEVICE']['boardconfig'] config_loaded = True else: model = 'None - Enter Device Identifier' ecid = 'None - Enter ECID' config_loaded = False boardconfig = 'None - Enter Boardconfig' version = '1.0.1~beta' col1 = [[p.T('Enter Device Identifier:', justification='center')], [p.Input(model, do_not_clear=True, key='_ID_')]] col2 = [[p.T('Enter Board Config:', justification='center')], [p.Input(boardconfig, do_not_clear=True, key='_BOARDCONF_')]] logo = [[ p.Image(data_base64=Images.logo, click_submits=True, key='_LOGO_') ]] title = [[ p.T('Sushi | GUI Wrapper for TSSChecker', font=('Corbel', 15), text_color='#ffffff', justification='left') ], [p.T('Sushi Version: ' + version, font=('Corbel', 10))], [ p.T('Developed by @maxbridgland', click_submits=True, key='_TWITTER_') ], [p.T('Licensed Under GNU GPLv3 | Made with Python')]] layout = [[p.Column(logo), p.Column(title)], [p.HorizontalSeparator()], [p.T('Enter ECID:', justification='center')], [p.Input(ecid, do_not_clear=True, key='_ECID_', focus=True)], [p.Column(col1), p.VerticalSeparator(), p.Column(col2)], [ p.T('iOS Version To Save:', justification='center'), p.Input('12.1.1', size=(10, 1), justification='center', key='_VER_'), p.Check('Save Latest Firmware', key='_LATEST_') ], [p.HorizontalSeparator()], [ p.Image(data_base64=Images.close_b, click_submits=True, key='Close'), p.Image(data_base64=Images.status_b, click_submits=True, key='Status'), p.Image(data_base64=Images.help_b, click_submits=True, key='Help'), p.Image(data_base64=Images.start_b, click_submits=True, key='Start') ]] window = p.Window('Sushi', no_titlebar=True, keep_on_top=True, grab_anywhere=True).Layout(layout) while True: event, values = window.Read() if event == 'Close': exit() break elif event == 'Help': helpMenu() elif event == 'Status': statusMenu() elif event == 'Start': devId = values['_ID_'] boardconfig = values['_BOARDCONF_'] ecid = values['_ECID_'] if values['_LATEST_'] == True: latest = '-l' version = '' elif values['_LATEST_'] == False: latest = '' version = values['_VER_'] finishedPopup(devId, ecid, boardconfig, version, latest) if os.path.exists(CONF_PATH) == False: configMenu(ecid, devId, boardconfig) elif event == '_LOGO_': webbrowser.open_new_tab('https://github.com/M4cs/Sushi') elif event == '_TWITTER_': webbrowser.open_new_tab('https://twitter.com/maxbridgland')
import sys import PySimpleGUIQt as sg layout = [[sg.Image(filename="/Users/netbox-wangdong/Downloads/42-logo.png")], [sg.Text(' 请登录')], [sg.InputText()], [sg.InputText()], [sg.Button("ok"), sg.Cancel()]] window = sg.Window('登录', layout) event, values = window.Read() window.Close() text_input = values[1] print(text_input)
header = [[ sg.Text("Currently playing", font="proximanova 16", justification="l", background_color="transparent", text_color="#b3b3b3", size=(30, 1)) ], [ sg.Text("", justification="c", background_color="transparent", font="Proximanova 13", key="songname", size=(15, 3)), sg.Image(data_base64="", key="songimage") ]] playlist = [[ sg.Button('', image_data=spotifyicon, button_color=(sg.theme_background_color(), sg.theme_background_color()), border_width=0, key='-spotify-', tooltip="Opens spotify main program") ], [ sg.Text("Playlists", font="proximanova 16", background_color="transparent",
enable_events=True, size=(7, 0.8)) ], [ sg.Button('Delete', size=(7, 1), disabled=True, key='_DELBUTTON_', button_color=('gray', 'gray')), sg.Checkbox('', key='_LOCKDEL_', enable_events=True, background_color='Dark Grey'), # sg.Text('', justification='left'), sg.Image(key='_IMAGE_', filename=empty_image, visible=True, pad=((0, 0), (0, 0))), sg.Image(key='_IMAGE2_', filename=empty_image, visible=True, pad=((0, 0), (0, 0))), # sg.Image(key='_IMAGE3_', filename=empty_image, visible=True, # pad=((0, 0), (0, 0))), # sg.Text('', justification='right'), sg.Checkbox('skip', key='_SKIPPROCESS_', enable_events=True, background_color='Dark Grey'), sg.Button('Add', size=(7, 1), key='_ADDBUTTON_',
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()
def url(ID): spotify = spotipy.Spotify( client_credentials_manager=SpotifyClientCredentials( "5d2c27886c8a4836844580b11c289dac", "1372129a4a254c2a9642956dbe7b75f0")) track = spotify.track(ID) return track['preview_url'] #track['album']['images'][0]['url'] #GUI IMPLEMENTATION# layout = [ [sg.Image(filename="Logo4.png", key="-IMAGE-")], [ sg.Text("Song Suggestion Algorithm", key='-TITLE-', justification='left', background_color='NONE', auto_size_text=True, font=["Gotham Medium", 16]) ], [ sg.Text( "Add Songs you Enjoy One by One to Receive a Personalized Playlist", key='-SUBTITLE-', justification='center', background_color='NONE', auto_size_text=True)
""" Get absolute path to resource, works for dev and for PyInstaller """ base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__))) return os.path.join(base_path, relative_path) prototext = resource_path("colorization_deploy_v2.prototxt") caffemodel = resource_path("colorization_release_v2.caffemodel") npyfile = resource_path("pts_in_hull.npy") sg.ChangeLookAndFeel('Reddit') sg.set_options(button_color=("0079d3", "0079d3"), button_element_size=(10, 1), text_justification="center") col1 = [[sg.T("IMAGEM:", size=(44, 1)), sg.I(size=(0, 0), visible=False, key="img", enable_events=True), sg.FileBrowse("SELECIONAR", file_types=(("Imagem", "*.png; *.jpg; *.jpeg"),), target="img")], [sg.Image(filename=resource_path("placeholder.png"), key="img_display")]] col2 = [[sg.T('RESULTADO:', size=(44, 1)), sg.I(size=(0, 0), visible=False, key="savefile", enable_events=True), sg.B("COLORIR", key="processar")], [sg.Image(filename=resource_path("placeholder.png"), key="img_display2", )]] tab1_layout = [[sg.Column(col1), sg.Column(col2)], [sg.Exit(key="EXIT"), sg.FileSaveAs("SALVAR", file_types=(("Imagem", "*.jpg"),), target='savefile', key="savefilebrowse", disabled=True, button_color=("black","grey"))]] tab2_layout = [[sg.T('PASTA:'), sg.I(key="pasta", size=(98,1)), sg.FolderBrowse()], [sg.B("COLORIR")], [sg.Exit(key="Exit")]] layout = [[sg.T("\t\t\t\t\tCOLORIZADOR DE FOTOS EM PRETO E BRANCO", font=("Arial 12 bold"))], [sg.TabGroup([[sg.Tab('COLORIR ARQUIVO ÚNICO', tab1_layout), sg.Tab('COLORIR LOTE', tab2_layout)]])]] window = sg.Window('Monografia do vértice genérica', layout, size=(1000, 700), auto_size_text=True, auto_size_buttons=False, resizable=False)
verbose=verbose) # extract the RGB image imgData, imgResizeLabel = cf.prep_img_for_display( displayImage, maxDisplayWidth=MAX_WINDOW_WIDTH, maxDisplayHeight=MAX_WINDOW_HEIGHT, verbose=verbose) # Convert to GUI window format except IndexError: # If no images of the correct type could be found: print( '\n > > > > > > > > No "{}" images found in directory "{}". Quitting.\n' .format(imgExtensionType, refDirectoryPath)) exit(0) # Initialize image_elem to the first file in the list image_elem = sg.Image( data=imgData ) # Image display element; will be updated later with other images filename_display_elem = sg.Text(img_files[0], size=(80, 1), font=("Helvetica", 18)) resize_display_elem = sg.Text(imgResizeLabel, size=(80, 1), font=("Helvetica", 18)) file_num_display_elem = sg.Text('File 1 of {}'.format(len(img_files)), size=(10, 1), font=("Helvetica", 18)) ref_dir_elem = [[ sg.Text('Choose a directory containing the REFERENCE images: ', font=("Helvetica", 18))
def findID(_song): returnedSongs = songRec.search_track(self, _song) if len(returnedSongs) > 1: return "input artist" else: return returnedSongs[0]["id"] returnedSongs = songRec.search_track(self, "Feeling Whitney") for i in returnedSongs: print(i["id"]) layout = [ [sg.Image(filename="Logo4.png", pad=((0.0), (50, 0)))], [ sg.Text("Song Suggestion Algorithm", key='-TITLE-', justification='left', background_color='NONE', auto_size_text=True, font=["Gotham Medium", 16]) ], [ sg.Text( "Add Songs you Enjoy One by One to Receive a Personalized Playlist", key='-SUBTITLE-', justification='center', background_color='NONE', auto_size_text=True)
for i in idxs.flatten(): # extract the bounding box coordinates (x, y) = (boxes[i][0], boxes[i][1]) (w, h) = (boxes[i][2], boxes[i][3]) # draw a bounding box rectangle and label on the image color = [int(c) for c in COLORS[classIDs[i]]] cv2.rectangle(image, (x, y), (x + w, y + h), color, 2) text = "{}: {:.4f}".format(LABELS[classIDs[i]], confidences[i]) cv2.putText(image, text, (x, y - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2) # show the output image imgbytes = cv2.imencode('.png', image)[1].tobytes() # ditto layout = [ [sg.Text('Yolo Output')], [sg.Image(data=imgbytes)], [sg.OK(), sg.Cancel()] ] win = sg.Window('YOLO', default_element_size=(14,1), text_justification='right', auto_size_text=False).Layout(layout) event, values = win.Read() win.Close() # cv2.imshow("Image", image) cv2.waitKey(0)
img.shrink(shrinkN) # Set the x,y location of img based on width (to keep it centered) img.x, img.y = int((MAX_WINDOW_WIDTH - img.width) / 2), int( (MAX_WINDOW_HEIGHT - img.height) / 2) blank_pix.copyPixmap(img, img.irect) # Copy the image onto the background imgDdata = blank_pix.getImageData( "png") # Convert to data string in png format # Make these 3 elements outside the layout because we want to "update" them later # Initialize image_elem to the first file in the list # Initialize wait_elem to "loading" image_elem = sg.Image( data=imgDdata) # Image display element; can be updated later filename_display_elem = sg.Text(img_files[0], size=(80, 1), font=("Helvetica", 18)) resize_display_elem = sg.Text(imgResizeLabel, size=(80, 1), font=("Helvetica", 18)) file_num_display_elem = sg.Text('File 1 of {}'.format(len(img_files)), size=(10, 1), font=("Helvetica", 18)) ref_dir_elem = [[ sg.Text('Choose a directory containing the REFERENCE images: ', font=("Helvetica", 18)) ],
story.append(PageBreak()) doc.build(story) def open_file(filepath): if platform.system() == 'Darwin': # macOS subprocess.call(('open', filepath)) elif platform.system() == 'Windows': # Windows os.startfile(filepath) else: # linux variants subprocess.call(('xdg-open', filepath)) layout = [ [sg.Image("0.png", key="screenshot")], [ sg.Input("./data/chap28", key="folderPath", size=(50, 0.5)), sg.FolderBrowse(initial_folder=".", key="browseFolder", target="folderPath"), sg.Button("Analyze", key="analyze"), ], [ sg.Text('Capture frequency (s): '), sg.Input(5, key="delayTime", size=(3, 1), justification='center'), sg.Button("Record", key="recordBtn"), sg.Text('Current capture index:'), sg.Text("0", key="imgIdx"), ], [