tab4_layout = [[sg.T('Enter a year')], [sg.In(key='Groceries1')]] tab5_layout = [[sg.T('Enter a year1')], [sg.In(key='Housing1')]] tab6_layout = [[sg.T('Enter a year')], [sg.In(key='Automotive1')]] tab7_layout = [[sg.T('Enter a year')], [sg.In(key='Tithes1')]] tab8_layout = [[sg.T('Enter a year')], [sg.In(key='Misc1')]] tab9_layout = [[sg.T('Enter a year')], [sg.In(key='Total1')]] col_1 = [[ sg.Text( 'WELCOME TO EXPENSE TRACKER\nInstructions For Use\nSubmit = Enter or edit or zero specific data (default for each bill is 0)\nView Data = View current data \ \nCancel = Erase all expense data\nPlot = Plot monthly bill data for a given expense category and year \n(intermediate months with no data default to $0.00) \ \nAverage = Computes seasonal and monthly averages for a given year for data' ) ], [sg.Text('Please enter the year and month as numbers')], [sg.Text('Year', size=(15, 1)), sg.InputText(do_not_clear=False)], [sg.Text('Month', size=(15, 1)), sg.InputText(do_not_clear=False)], [ sg.Text( 'Please fill out at least one of the relevant expense data fields below (default is 0)' ) ], [sg.Text('Water', size=(15, 1)), sg.InputText(do_not_clear=False)], [sg.Text('Phone', size=(15, 1)), sg.InputText(do_not_clear=False)], [sg.Text('Electric', size=(15, 1)), sg.InputText(do_not_clear=False)], [ sg.Text('Groceries', size=(15, 1)), sg.InputText(do_not_clear=False)
def Everything_NoContextManager(): form = sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) layout = [ [ sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25)) ], [sg.Text('Here is some text.... and a place to enter text')], [sg.InputText('This is my text')], [ sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True) ], [ sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1") ], [ sg.Multiline( default_text= 'This is the default Text should you decide not to type anything', size=(35, 3)), sg.Multiline(default_text='A second multi-line', size=(35, 3)) ], [ sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(20, 3)), sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85) ], [ sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3)), sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25), sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75), sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10), sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1') ], [sg.Text('_' * 80)], [sg.Text('Choose A Folder', size=(35, 1))], [ sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Default Folder'), sg.FolderBrowse() ], [ sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', '#7E6C92')) ] ] button, values = form.LayoutAndRead(layout) del (form) sg.MsgBox('Title', 'The results of the form.', 'The button clicked was "{}"'.format(button), 'The values are', values)
import wolframalpha import PySimpleGUI as sg import wikipedia app_id = "censored api key" client = wolframalpha.Client(app_id) sg.theme('DarkPurple') # Add a touch of color # All the stuff inside your window. layout = [ [sg.Text('Enter a command'), sg.InputText()], [sg.Button('Ok'), sg.Button('Cancel')] ] # Create the Window window = sg.Window('Lieutenant - At your duty!', layout) import pyttsx3 engine = pyttsx3.init() # Event Loop to process "events" and get the "values" of the inputs while True: event, values = window.read() if event in (None,'Cancel'): break try: wiki_ans = wikipedia.summary(values[0],sentences=2) wolfram_ans = next(client.query(values[0]).results).text engine.say(wolfram_ans) sg.PopupNonBlocking("Wolfram Result: "+wolfram_ans,"Wikipedia Result: "+wiki_ans) except wikipedia.exceptions.DisambiguationError: wolfram_ans = next(client.query(values[0]).results).text engine.say(wolfram_ans)
], [sg.Text('_' * 80, background_color="#FFF", text_color="#000")], [ sg.Text('Select Result File:', size=(35, 1), background_color="#FFF", text_color="#000") ], [ sg.Text('Result File: ', size=(15, 1), auto_size_text=False, justification='right', background_color="#FFF", text_color="#000"), sg.InputText('Select result file', background_color="#fff2e5", text_color="#000", key="result_file_path"), sg.FileBrowse(), sg.Button("Submit", size=(9, 1)) ], [ sg.Text('K V BHADARWAH DISTT DODA J&K', size=(52, 1), justification='center', font=("Helvetica", 15), relief=sg.RELIEF_RIDGE, background_color="#fff2e5", text_color="#000") ], [ sg.Text('School Code: ',
if sys.version_info[0] >= 3: import PySimpleGUI as sg else: import PySimpleGUI27 as sg sdir_ = os.path.dirname(__file__) w_, h_ = 400, 300 # need a global because we don't want img_ to be garbage collected. img_ = None layout = [ [ sg.Text('Server Adress', size=(15, 1)), sg.InputText('ghevar.ncbs.res.in:31417', key='server') ], [sg.Text('Main file'), sg.Input(key='main_file'), sg.FileBrowse()], [sg.Text('Other files'), sg.Input(key='other_files'), sg.FilesBrowse()], [sg.Canvas(size=(w_, h_), key='canvas')] # Output size is in chars x line , [sg.Output(key='output', size=(80, 10))], [sg.Submit(), sg.Exit()] ]
def inputFilenameLayout(displayImage): layout = [[displayImage], [sg.InputText(key="Answer", do_not_clear=False)], [prevBtn(), nextBtn()]] return layout
def get_inputs_via_gui(): layout = [ [ sg.Radio('Simple Report (no RR data)', "simple_or_complex", key='simple', default=True, size=(10, 1)), sg.Radio('Complex Report (RR data)', "simple_or_complex", key='complex') ], [ sg.Checkbox('All live projects', default=False, key="include_all_live_jobs") ], [ sg.Text('Surveys to exclude', size=(20, 1), justification='center', font=("Helvetica", 15)) ], [ sg.Checkbox('Welcome survey', size=(10, 1), default=True, key="Welcome Survey"), sg.Checkbox('Education survey', default=True, key="Education Screener") ], [ sg.Checkbox('Member sat survey', default=True, key="Member Experience Survey") ], [ sg.Text('Manual inclusions', size=(30, 1), justification='center', font=("Helvetica", 15)) ], [sg.Text('Survey 1', size=(25, 1)), sg.InputText('', key="survey_1")], [sg.Text('Survey 2', size=(25, 1)), sg.InputText('', key="survey_2")], [sg.Text('Survey 3', size=(25, 1)), sg.InputText('', key="survey_3")], [sg.Text('Survey 4', size=(25, 1)), sg.InputText('', key="survey_4")], [sg.Submit(), sg.Cancel()] ] window = sg.Window('Create Project Summaries').Layout(layout) button, values = window.Read() include_all_live_jobs = values['include_all_live_jobs'] print(f'include_all_live_jobs = {include_all_live_jobs}') if include_all_live_jobs: manually_select_projects = False else: manually_select_projects = True if values['complex']: complex_report = True else: complex_report = False print(f"values['Welcome Survey'] = {values['Welcome Survey']}") print(f"values['Education Screener'] = {values['Education Screener']}") print( f"values['Member Experience Survey'] = {values['Member Experience Survey']}" ) print(f"values['simple'] = {values['simple']}") print(f"values['complex'] = {values['complex']}") # manual_survey_1 = values['survey_1'] # manual_survey_2 = values['survey_2'] # manual_survey_3 = values['survey_3'] # manual_survey_4 = values['survey_4'] # section: this will look at the exclusion checkboxes and create a list surveys_to_exclude = [] potential_exclusions = [ 'Welcome Survey', 'Education Screener', 'Member Experience Survey' ] for potential_exclusion in potential_exclusions: if values[f'{potential_exclusion}']: surveys_to_exclude.append(f'{potential_exclusion}') print('surveys_to_exclude looks like this:') print(surveys_to_exclude) # section: this will look at the manual inclusions text entry boxes and create a list manual_inclusions = [] for i in range(1, 5): if values[f'survey_{i}'] != "": manual_inclusions.append(values[f'survey_{i}']) print('manual_inclusions looks like this:') print(manual_inclusions) window.close() return manually_select_projects, surveys_to_exclude, manual_inclusions, complex_report
import PySimpleGUI as sg layout = [[sg.Text('Please enter your Name, Address, Phone')], [sg.Text('Name', size=(15, 1)), sg.InputText('name')], [sg.Text('Address', size=(15, 1)), sg.InputText('address')], [sg.Text('Phone', size=(15, 1)), sg.InputText('phone')], [sg.Submit(), sg.Cancel()]] window = sg.Window('Simple data entry window').Layout(layout) button, values = window.Read() print(button, values[0], values[1], values[2])
import PySimpleGUI as sg #1 - DEFINIR EL TEMA sg.theme('SystemDefault') # Add a touch of color #2. # All the stuff inside your window. layout = [ [sg.Text('Clase GUI APAD 20')], #row 1 [sg.Text('Enter something on Row 2'), sg.InputText()], #row2 [sg.Text('Tercera línea'), sg.InputText()], #row3 [sg.Button('Ok'), sg.Button('Cancel')] #row4 ] #3 Create the Window window = sg.Window('Window Title', layout) # Event Loop to process "events" and get the "values" of the inputs while True: event, values = window.read() if event == sg.WIN_CLOSED or event == 'Cancel': # if user closes window or clicks cancel break print('You entered ', values[0], values[1]) window.close()
remempwindow_active = False statwindow_active = False payhistorywindow_active = False while True: ev1, vals1 = mainwindow.Read(timeout=100) if ev1 == 'Exit': mainwindow.Close() if ev1 == 'Add Employee To Payroll' and not addempwindow_active: addempwindow_active = True mainwindow.Hide() addemplayout = [ [sg.Text('Employee Details:')], [ sg.Text('Employee ID:', size=(10, 1)), sg.InputText('', size=(25, 1)) ], [sg.Text('First Name:', size=(10, 1)), sg.InputText('')], [sg.Text('Middle Name:', size=(10, 1)), sg.InputText('')], [sg.Text('Last Name:', size=(10, 1)), sg.InputText('')], [ sg.Text('Address:', size=(10, 1)), sg.InputText('', size=(45, 4)) ], [ sg.Text('Pincode:', size=(10, 1)), sg.InputText('', size=(10, 1)), sg.Text('City:', size=(4, 1)), sg.InputText('', size=(20, 1))
sg.Multiline( tooltip="Add each course link in a row as follows:" "\nhttps://www.linkedin.com/learning/photoshop-cc-2015-new-features-3\nhttps://www.linkedin.com/learning/photoshop-cs6-image-optimization\n https://www.linkedin.com/learning/photoshop-cc-for-photographers-sharpening \n ", font=("Helvetica", 7), autoscroll=True, enable_events=True, enter_submits=True, auto_size_text=True, size=(650, 15), default_text=results.strip() + "\n", background_color="#FFF") ], [ sg.Text("Save Directory", size=(14, 1), pad=(0, 5)), sg.InputText(config.get("mainConfig", "saveDirectory"), background_color="#FFF", size=(30, 1)), sg.FolderBrowse(button_text="Select", button_color=default_button_color, size=(15, 1)) ], ] config3 = [ [ sg.T("Chrome Driver Options", size=(500, 1), auto_size_text=True, justification='center', font=("Arial", 10), background_color="#888",
import PySimpleGUI as sg import os sg.theme("DarkAmber") layout = [[sg.Text('500 $', size=(5, 1)), sg.InputText(key='-ccent-')], [sg.Text('200 $', size=(5, 1)), sg.InputText(key='-duec-')], [sg.Text('100 $', size=(5, 1)), sg.InputText(key='-cent-')], [sg.Text('50 $', size=(5, 1)), sg.InputText(key='-cant-')], [sg.Text('20 $', size=(5, 1)), sg.InputText(key='-venti-')], [sg.Text('10 $', size=(5, 1)), sg.InputText(key='-dieci-')], [sg.Button('Calcola')], [ sg.Text('TOTALE:'), sg.Text(size=(5, 1), key='-tot-'), sg.Text(size=(5, 1), key='-outduec-'), sg.Text(size=(5, 1), key='-outcent-'), sg.Text(size=(5, 1), key='-outcant-'), sg.Text(size=(5, 1), key='-outventi-'), sg.Text(size=(5, 1), key='-outdieci-') ]] window = sg.Window("ATM", layout, grab_anywhere=True) if os.path.exists("File.csv"): pass
def login_window(): # the main login window sg.theme('Default1') layout = [ [ sg.Text('Host IP:'), sg.InputText("192.168.2.151", key='ip', size=(30, 1)) ], # TODO get rid of the default text [ sg.Text('Host Port:'), sg.InputText("8000", key='port', size=(20, 1)) ], [sg.Button('Connect to host')], [sg.Button('Host new connection')], ] window = sg.Window('DoggyDoor', layout, icon=logo) while True: try: event, values = window.read() except Exception as e: print("Error in login_window: %s" % str(e)) break if event is None: break if event == 'Connect to host': # become a client conn = None try: name = "User: "******":" + values['port']) n = Node(name, 8000, values['ip'], int(values['port'])) window.close() conn = client_node(n) except SystemExit: break except WindowsError as e: pop("Could not connect to host: " + str(e)) login_window() except: break if conn: client_clear_folder() t = threading.Thread(target=client_listen, args=("client_listener", conn, n)) t.start() client_console(conn, n) if event == 'Host new connection': # become a host try: name = "User: "******"Could not host new connection: " + str(e)) login_window()
import PySimpleGUI as sg sg.change_look_and_feel('DarkAmber') # Add a touch of color # All the stuff inside your window. layout = [[sg.Text('Some text on Row 1')], [sg.Text('Enter something on Row 2'), sg.InputText()], [sg.Button('Ok'), sg.Button('Cancel')]] # Create the Window window = sg.Window('Window Title', layout) # Event Loop to process "events" and get the "values" of the inputs while True: event, values = window.read() if event in (None, 'Cancel'): # if user closes window or clicks cancel break print('You entered ', values[0]) window.close()
pass #with keyboard.Listener(on_press=on_press, on_release=on_release) as listener: #'blocking' listener no good for GUI # listener.join() listener = keyboard.Listener( on_press=on_press, on_release=on_release) #'non-blocking' listener good for GUI listener.start() sg.theme('DarkAmber') # Add a touch of color # All the stuff inside your window. layout = [[sg.Text('Some text on Row 1')], [sg.Text('Enter something on Row 2'), sg.InputText()], [sg.Button('Ok', bind_return_key=True), sg.Button('Cancel')]] # Create the Window window = sg.Window('My Factorio Tools', layout, keep_on_top=True) #windows key to bring up gui # Event Loop to process "events" and get the "values" of the inputs while True: event, values = window.read() if event == sg.WIN_CLOSED or event == 'Cancel': # if user closes window or clicks cancel break print(event, ' You entered ', values[0]) window.close() listener.stop()
background_color="#d3dfda", justification="center", size=(10, 1)) ], [sg.Spin(values=("Spin Box 1", "2", "3"), initial_value="Spin Box 1")], [sg.Spin(values=("Spin Box 1", "2", "3"), initial_value="Spin Box 2")], [sg.Spin(values=("Spin Box 1", "2", "3"), initial_value="Spin Box 3")], ] layout = [ [ sg.Text("All graphic widgets in one window!", size=(30, 1), font=("Helvetica", 25)) ], [sg.Text("Here is some text.... and a place to enter text")], [sg.InputText("This is my text")], [ sg.Checkbox("My first checkbox!"), sg.Checkbox("My second checkbox!", default=True), ], [ sg.Radio("My first Radio! ", "RADIO1", default=True), sg.Radio("My second Radio!", "RADIO1"), ], [ sg.Multiline( default_text= "This is the default Text should you decide not to type anything", size=(35, 3), ), sg.Multiline(default_text="A second multi-line", size=(35, 3)),
roi_dict["img_y0"] = img_y0 roi_dict["img_x1"] = img_x1 roi_dict["img_y1"] = img_y1 roi_dict["crop_x0"] = crop_x0 roi_dict["crop_y0"] = crop_y0 roi_dict["crop_x1"] = crop_x1 roi_dict["crop_y1"] = crop_y1 path = os.getcwd() # working directory # DEFINING THE INITIAL FRAME PATH sg.theme('DarkBlue') # Add a touch of color # All the stuff inside your window. layout = [[sg.Text('Enter the initial frame path')], [sg.Text('Path :'), sg.InputText()], [sg.Button('Ok'), sg.Button('Cancel')]] # Create the Window window = sg.Window('INITAL FRAME', layout) # Event Loop to process "events" and get the "values" of the inputs event, values = window.read() window.close() # IMAGE PROCESSING img = cv2.imread(values[0]) # create a window cv2.namedWindow('SELECT ROI AND CLICK ENTER', flags=cv2.WINDOW_NORMAL | cv2.WINDOW_FREERATIO) # 1 definition window
sg.Text(size=(50, 3), key="url_image"), ], [ sg.Image(key="image_source"), ], # Phần output [ sg.Button("Show Result", key='bnt_find'), sg.Button("Processed Image", key='bnt_image_sign'), sg.Button("Result Image", key='bnt_image_result'), sg.Button("Exit", key='Exit'), ], [ sg.Text("Result: "), sg.InputText(size=(45, 1), key="result"), ], ] # Full layout layout = [[ sg.Column(input_column, justification='center'), ]] # Layout window GUI window = sg.Window("LPI 55", layout, size=(450, 600)).Finalize() #---------------------------end GUI----------------------------------------- # ------------------------- event Bnt -------------------------------------------- while True:
form = sg.FlexForm( title, return_keyboard_events=True, location=(0, 0), use_default_focus=False ) cur_page = 0 data, clip_pos = get_page( cur_page, # read first page zoom=False, # not zooming yet max_size=max_size, # image max dim ) image_elem = sg.Image(data=data) # make image element goto = sg.InputText( str(cur_page + 1), size=(5, 1), do_not_clear=True, key="PageNumber" ) # for display & input layout = [ # the form layout [ sg.ReadFormButton("Next"), sg.ReadFormButton("Prior"), sg.Text("Page:"), goto, sg.Text("(%i)" % page_count), sg.ReadFormButton("Zoom"), sg.Text("(toggle on/off, use arrows to navigate while zooming)"), ], [image_elem], ]
def main(self): build_state = BuildState.NOTHING self.logger.info(_("Locating dependencies...")) self.find_dependencies() self.logger.info(_("Locating and importing exising settings...")) self.read_settings() libs = self.libs entry_size = self.entry_size small_entry_size = (int(entry_size[0] / 3), entry_size[1]) text_field_size = (int(entry_size[0] * 2.5), entry_size[1]) sg.theme(GUI_THEME) tab1_layout = [ [ sg.Frame(layout=[[ sg.Text(_("Project Name"), size=entry_size), sg.InputText(key=PROJ_NAME, default_text=EMPTY_STRING, size=text_field_size) ], [ sg.Text(_("Author Name"), size=entry_size), sg.InputText(key=AUTHOR_NAME, size=text_field_size, default_text=_("Your Name")) ], [ sg.Text(_("Version"), size=entry_size), sg.InputText(key=PROJ_VERSION, size=text_field_size, default_text="1.0.0") ], [ sg.Text(_("Project Directory"), size=entry_size), sg.Input(key=PROJ_DIR, size=text_field_size), sg.FolderBrowse() ], [ sg.Text(_("Project HTML File"), size=entry_size), sg.InputText(key=PROJ_HTML, size=text_field_size), sg.FileBrowse() ], [ sg. Text(_("Project Output Directory"), size=entry_size, tooltip =_("Where you want the executable to be stored" )), sg.Input(key=PROJ_PARENT_DIR, size=text_field_size, enable_events=True), sg.FolderBrowse() ]], title=_("Project Details")) ], [ sg.Frame(layout=[ [ sg.Text(_("Email"), size=entry_size ), sg.InputText(key=AUTHOR_EMAIL, size=text_field_size) ], [ sg.Text(_("Repository"), size=entry_size ), sg.InputText(key=AUTHOR_REPO, size=text_field_size) ], [ sg.Text(_("Window Width"), size=entry_size), sg.InputText( key=PROJ_DIMS_WIDTH, size=small_entry_size, default_text="800" ), sg.Text(_("Window Height"), size=entry_size ), sg.InputText( key=PROJ_DIMS_HEIGHT, size=small_entry_size, default_text="600" ) ], [ sg.Text("Keywords (comma separated)", size=entry_size), sg.InputText(key=PROJ_KEYWORDS, size=text_field_size) ], [ sg.Text( _("Icon Location" ), size=entry_size, tooltip= _("Automatically create an icon and assign it to the executable" )), sg.InputText(key=PROJ_ICON_LOCATION, size=text_field_size), sg.FileBrowse() ], ], title=_("Author Details")) ], [ sg.Input(key=EXISTINGPATH, enable_events=True, visible=False), sg.FileBrowse(button_text=_("Open Existing Project"), enable_events=True, key=OPENEXISTING, target=EXISTINGPATH), sg.Button( _("Setup New Build Files"), tooltip= _("Sets up the project build directory by installing various Electron packages" ), key=SETUPBUTTON), sg.Button(_("Update Information"), key=UPDATEBUTTON, disabled=True), sg.Button(_("Build for ") + self.system_type, disabled=True, key=BUILDBUTTON), sg.Button(_("Build for Web"), disabled=True, key=BUILDWEBBUTTON) ] ] tab2_layout = [[ sg.Frame(layout=[[ sg.Text(_( "The Project Organiser parses a Twine Story HTML file for various media (images, audio, video)," "copies them and your HTML file to the selected output directory in a neat structure and attempts " "to replace the links in your Story with the new ones, so that the Story will behave correctly." ), size=(int(text_field_size[0] * 1.3), None)) ], [ sg.Text(_("Twine HTML File"), size=entry_size), sg.InputText(key=TWINEHTML, size=text_field_size), sg.FileBrowse() ], [ sg.Text(_("Output Directory"), size=entry_size), sg.InputText(key=ORGANISEDDIR, size=text_field_size), sg.FolderBrowse() ], [ sg.Button(_("Organise"), key=ORGANISE, enable_events=True) ]], title=_("Project Organiser")) ]] # Icon stuff tab3_layout = [[ sg.Frame(layout=[[ sg.Text(_( "This tool can be used to create icons (for anything). Select the image you wish to use,\n" "and generate ICO (Windows icon format) and ICNS (macOS icon format) " "using those respective systems"), size=(int(text_field_size[0] * 1.3), None)) ], [ sg.Text(_("Icon Location"), size=entry_size), sg.InputText(EMPTY_STRING, key=ICONLOCATIONTEXT, enable_events=True), sg.FileBrowse() ], [ sg.Text(_("Icon Destination"), size=entry_size), sg.InputText(EMPTY_STRING, key=ICONDESTINATIONTEXT, enable_events=True), sg.FileSaveAs(file_types=(self.icon_type, )) ], [ sg.Frame(layout=[[ sg.Image( size=(256, 256), key=ICONIMAGE, filename='', ) ]], title=_("Image Preview"), size=(256, 256)), sg.Button(_("Convert"), key=CONVERT) ]], title=_("Icon Creator")) ]] tab4_layout = [[ sg.Frame(layout=[[ sg.Text( _("NPM and NPX are required to use the executable generator.\n" "TweeGo is required to use the Project Organiser")) ], [ sg.Text(_("NPM Location"), size=entry_size), sg.InputText(libs[NPM_LOCATION], key=NPM_LOCATION, size=text_field_size, enable_events=True), sg.FileBrowse(enable_events=True, key="NPM_FIND") ], [ sg.Text(_("NPX Location"), size=entry_size), sg.InputText(libs[NPX_LOCATION], key=NPX_LOCATION, size=text_field_size, enable_events=True), sg.FileBrowse(enable_events=True, key="NPX_FIND") ], [ sg.Text(_("TweeGo Location"), size=entry_size), sg.InputText( key=TWEEGO_LOCATION, default_text=libs[TWEEGO_LOCATION], size=text_field_size, enable_events=True), sg.FileBrowse(enable_events=True, key="TWEEGO_FIND") ]], title=_("Libraries")) ]] layout = [[ sg.TabGroup([[ sg.Tab(_("Executable Generator"), tab1_layout, tooltip=_("Executable Generator")), sg.Tab(_("Project Organiser"), tab2_layout, tooltip=_("Project Organiser")), sg.Tab(_("IconCreator"), tab3_layout, tooltip=_("IconCreator")), sg.Tab(_("Library Info"), tab4_layout, tooltip=_("Library Info")) ]]) ], [ sg.Button(_("Open Twine2 Directory (Local)"), key=TWINE2LOCAL), sg.Button(_("Help"), key=HELP), sg.Button(_("About"), key=ABOUT), sg.Button(_("Exit"), key=EXIT) ], [ sg.Multiline(EMPTY_STRING, size=(entry_size[0] * 4, entry_size[1] * 8), key=DIALOGUE_BOX_KEY, autoscroll=True, disabled=True) ], [ sg.ProgressBar(100, size=(entry_size[0] * 2.8, entry_size[1] * 6), orientation="h", key=PROGRESSBAR) ]] window = sg.Window(_("Twine Executable Generation Tool"), layout) self.dialogue_box = window.find_element(DIALOGUE_BOX_KEY) while True: event, values = window.read(timeout=100) self.update_dictionaries(values) if event in (None, EXIT): # if user closes window or clicks cancel win_keys = window.AllKeysDict for k in win_keys: try: window[k].update(disabled=True) except: pass self.write_settings() self.terminate_processes() break if event in (None, NPM_LOCATION): self.write_settings() if event in (None, NPX_LOCATION): self.write_settings() if event in (None, TWEEGO_LOCATION): self.write_settings() if event in (None, ABOUT): sg.popup( "About this program\n" "Made by Locke Birdsey (@lockebirdsey)\n" "Submit bugs at https://github.com/LockeBirdsey/TwEGeT/issues", title=_("About TwEGeT"), ) if event in (None, ICONLOCATIONTEXT): try: img_path = Path(values[ICONLOCATIONTEXT]) if img_path.exists(): icon_tool = IconTool(img_path) img_as_64 = icon_tool.convert_to_base64() window[ICONIMAGE].update(data=img_as_64, size=(256, 256)) except Exception as e: print(e) self.logger.debug(_("Error with loading icon image")) if event in (None, BUILDWEBBUTTON): build_state = BuildState.BUILDING_WEB if event in (None, SETUPBUTTON): build_state = BuildState.SETUP self.build_new() if event in (None, ORGANISE): html_path = values[TWINEHTML] out_dir = values[ORGANISEDDIR] if html_path is EMPTY_STRING or out_dir is EMPTY_STRING: self.logger.info( "Project Organiser: Incomplete paths were provided") else: t = TMO(html_path, out_dir) t.run() if event in (None, TWINE2LOCAL): # System specific open commands # Twine2 files lives in ~/Documents/Twine home = Path.home() try: if self.system_type is WINDOWS: os.startfile( home.joinpath("Documents").joinpath("Twine")) else: opener = "open" if self.system_type == DARWIN else "xdg-open" twine_path = home.joinpath("Documents").joinpath( "Twine") self.run_command_store_output( [opener, str(twine_path)]) except Exception as e: self.logger.debug( _("An error occurred. If needed, submit the following error message to the TwET Github." ) + str(e)) if event in (None, UPDATEBUTTON): self.update_dictionaries(values) self.create_lock_file(Path(self.project[PROJ_BUILD_DIR])) self.replace_js_parameters( Path(self.project[PROJ_BUILD_DIR]).joinpath( ELECTRON_SOURCE_DIR).joinpath(INDEX_JS)) self.logger.info( _("Updating project files located at ") + self.project[PROJ_BUILD_DIR]) if event in (None, EXISTINGPATH): path = values[EXISTINGPATH] try: self.load_lock_file(Path(path)) self.update_widgets(window) self.activate_buttons(window) sg.Popup("Successfully loaded project: " + self.project[PROJ_NAME]) except: sg.Popup(_("Existing project file could not be loaded.")) if event in (None, HELP): sg.popup(HELP_STRING, title=_("Help with TwEGeT")) if event in (None, PROJ_PARENT_DIR): potential_lock_path = Path( self.project[PROJ_PARENT_DIR]).joinpath(DETAILS_FILE_NAME) if potential_lock_path.exists(): sg.Popup( _("A config file has been detected at " + str(potential_lock_path) + "\nWill load its contents")) self.load_lock_file(potential_lock_path) # update widgets with new values self.update_widgets(window) self.activate_buttons(window) if event in (None, BUILDBUTTON): if self.libs[NPX_LOCATION] is EMPTY_STRING or self.libs[ NPM_LOCATION] is EMPTY_STRING: self.logger.info( _("Either NPM or NPX are unable to be found which means the project cannot be built.\n" "Please locate them using the \"Library Info\" Tab")) else: build_state = BuildState.BUILDING_NEW self.logger.info( _("Building executable for ") + self.system_type) self.create_lock_file(Path(self.project[PROJ_BUILD_DIR])) self.update_package_json( Path(self.project[PROJ_BUILD_DIR]).joinpath( YARN_PACKAGE_FILE)) self.replace_js_parameters( Path(self.project[PROJ_BUILD_DIR]).joinpath( ELECTRON_SOURCE_DIR).joinpath(INDEX_JS)) # icon setup if self.project[PROJ_ICON_LOCATION] != EMPTY_STRING: icon_path = Path(self.project[PROJ_ICON_LOCATION]) icon_tool = IconTool(icon_path) icon_tool.convert(Path(self.project[PROJ_BUILD_DIR]), target_system=self.system_type) self.logger.info( _("Creating ") + self.system_type + _(" compatible icons")) self.run_command_with_output( [ self.libs[NPM_LOCATION] + self.cmd_extension, "run", "make" ], cwd=self.project[PROJ_BUILD_DIR]) # The buildstates if build_state == BuildState.SETUP: if not self.lock.locked(): self.build_directories(Path(self.project[PROJ_BUILD_DIR])) self.activate_buttons(window) build_state = BuildState.NOTHING # TODO Generate build files elif build_state == BuildState.BUILDING_NEW: if not self.lock.locked(): build_state = BuildState.NOTHING elif build_state == BuildState.BUILDING_WEB: zip_path = Path(self.project[PROJ_BUILD_DIR]).joinpath( self.project[PROJ_NAME]) shutil.make_archive(zip_path, "zip", (Path( self.project[PROJ_BUILD_DIR]).joinpath(ELECTRON_SOURCE_DIR) )) # TODO thread this command so for very large zip files we can update the progress bar self.logger.info( _("Zip file located at " + str(zip_path) + ".zip")) build_state = BuildState.NOTHING elif build_state == BuildState.UPDATING: pass try: line = self.log_queue.get_nowait() self.reset_progress_bar(window) except Empty: if build_state != BuildState.NOTHING: self.arbitrary_waiting_value += 1 self.PROGRESS_BAR_MAX += 1 self.update_progress_bar(window) sleep(0.1) pass else: self.update_dialogue(self.queue_handler.format(line)) window.close() quit(self.return_code)
justification='center', size=(10, 1)) ], [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1')], [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 2')], [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 3')] ] layout = [ [ sg.Text('All graphic widgets in one form!', size=(30, 1), justification='center', font=("Helvetica", 25), relief=sg.RELIEF_RIDGE) ], [sg.Text('Here is some text.... and a place to enter text')], [sg.InputText('This is my text')], [ sg.Frame(layout=[[ sg.Checkbox('Checkbox', size=(10, 1)), sg.Checkbox('My second checkbox!', default=True) ], [ sg.Radio('My first Radio! ', "RADIO1", default=True, size=(10, 1)), sg.Radio('My second Radio!', "RADIO1") ]], title='Options', title_color='red', relief=sg.RELIEF_SUNKEN)
def keyw_get_items(key): """ Displays a Dialog Window to get the Section Keyword Options Date Parameters """ keyitems = dict() keyitems['ans' ] = 'No' keyitems['comment' ] = '' keyitems['filepath'] = None keyitems['filename'] = None keyitems['sch' ] = None keyitems['step' ] = None keyitems['yearstr' ] = None keyitems['yearend' ] = None keyheadr = ['HEADER-INCLUDE', 'HEADER-LONG', 'HEADER-SHORT'] keysectn = ['RUNSPEC', 'GRID', 'EDIT', 'PROPS', 'SOLUTION', 'SUMMARY', 'SCHEDULE'] # # COMMENT Keyword Processing # if key == 'COMMENT': keyitems['comment'] = sg.PopupGetText('Enter ' + key + ' Text', no_titlebar=True, grab_anywhere=True, keep_on_top=True) if keyitems['comment'] is None: keyitems['comment'] = '' return (keyitems) # # TSTEP Keyword Processing # if key == 'TSTEP': keyitems['ans'] = sg.Popup ('Select ' + key + ' Step Option \n', custom_text=('Monthly', 'Quarterly'), no_titlebar=True, grab_anywhere=True, keep_on_top=True) return (keyitems) # # # HEADER File Processing # if key in keyheadr: filename = sg.PopupGetFile('Save ' + key +' to File', save_as=True, initial_folder=str(os.getcwd()), default_path=str(os.getcwd()), file_types=[('OPM', ['*.data', '*.DATA']), ('All', '*.*')], no_titlebar=True, grab_anywhere=True, keep_on_top=True) try: keyitems['filename'] = Path(filename).name keyitems['filepath'] = Path(filename).parent except Exception: keyitems['filename'] = '' keyitems['filepath'] = '' keyitems['ans'] = sg.PopupYesNo('Do You Wish to Include the OPM License for the ' + key + ' Header?', no_titlebar=True, grab_anywhere=True, keep_on_top=True) return(keyitems) # # Ask if SECTION Keywords Should be Generated # if key in keysectn: keyitems['ans'] = sg.PopupYesNo('Do You Wish to Generate the Standard Keywords for the ' + key + ' Section?', no_titlebar=True, grab_anywhere=True, keep_on_top=True) # # Generate SCHEDULE Section Date Keywords # if key == 'SCHEDULE': keyitems['yearstr'] = 2000 keyitems['yearend'] = 2020 keyitems['sch' ] = sg.PopupYesNo('Do You Wish to Generate ' + key + ' Section Date Keywords?', no_titlebar=True, grab_anywhere=True, keep_on_top=True) if keyitems['sch'] == 'Yes': layout1 = [ [sg.Text('Generate ' + key + ' Section Date Keywords Parameters') ], [sg.Text('') ], [sg.Text('Start Year', size=(14,None)), sg.InputText(keyitems['yearstr'], key = '_yearstr_') ], [sg.Text('End Year' , size=(14,None)), sg.InputText(keyitems['yearend'], key = '_yearend_') ], [sg.Radio('Annual Report and Time Steps' , 'bRadio', key='_annual_' )], [sg.Radio('Annual Report and Quarterly Time Steps' , 'bRadio', key='_quarter_' )], [sg.Radio('Annual Report and Monthly Time Steps' , 'bRadio', key='_month_' , default=True )], [sg.Submit(), sg.Cancel() ]] window2 = sg.Window('Generate Schedule Date Keywords', layout= layout1, no_titlebar=True, grab_anywhere=True, keep_on_top=True) (button, values) = window2.Read() window2.Close() if button == 'Submit': keyitems['sch' ] = 'Yes' keyitems['yearstr'] = int(values['_yearstr_']) keyitems['yearend'] = int(values['_yearend_']) if values['_annual_']: keyitems['step'] = 'Annual' if values['_quarter_']: keyitems['step'] = 'Quarterly' if values['_month_'] : keyitems['step'] = 'Monthly' else: keyitems['sch' ] = 'No' keyitems['step'] = 'Monthly' else: keyitems['sch' ] = 'No' keyitems['step'] = 'Monthly' return(keyitems)
def main(): # Window theme sg.theme('Dark Blue 3') # Window layout for the username window username_layout = [[sg.Text('Welcome to ClassChat!')], [sg.Text('Username:'******'ClassChat Login', username_layout) event, values = window.read() window.close() # Retrieve the username username = values[0] # Main window layout main_layout = [[sg.Text('Chat', size=(152, 1)), sg.Text('Users')], [ sg.Multiline(size=(150, 50), disabled=True, autoscroll=True, key="-CHATBOX-", write_only=True), sg.Multiline(size=(20, 50), disabled=True, key="-USERLIST-", write_only=True) ], [ sg.InputText(size=(152, 1), key="-INPUTBOX-"), sg.Button('Send ->', bind_return_key=True), sg.Button('Exit') ]] window = sg.Window(f'ClassChat - connected as {username}', main_layout, finalize=True) # Create socket communication_socket = socket.socket() # Attempt a connection on port 8080 communication_socket.connect(('127.0.0.1', 8080)) message_json = dumps({'action': 'connection_event', 'from': username}) communication_socket.send(message_json.encode()) # Spawn the listener thread thread = Thread(target=listen_from_socket, args=[communication_socket, window]) thread.start() while True: event, values = window.read() print(event, values) # If the exit button is pressed or the window is closed, stop gracefully if event == sg.WIN_CLOSED or event == 'Exit': # Say goodbye to the server! message_json = dumps({ 'action': 'disconnect_event', 'from': username }) communication_socket.send(message_json.encode()) # Kill the listener thread thread.join() # Break our main loop break if event == 'Send ->': # Don't allow blank messages to be sent if values['-INPUTBOX-'] == '': continue # Clear our inputbox window['-INPUTBOX-'].update('') # Check if we are dealing with a command if values['-INPUTBOX-'][0] == '/': split_message = values['-INPUTBOX-'].split(' ') command = split_message[0].split('/')[1] del split_message[0] if command == 'msg' or command == 'message': if len(split_message) < 2: window['-CHATBOX-'].print( 'Invalid amount of arguments required, message requires at least 2.' ) continue if len(split_message[0]) == 0: window['-CHATBOX-'].print( 'You must supply a username to send a message to.') continue if len(split_message[1]) == 0: window['-CHATBOX-'].print('You must supply a message.') continue else: window['-CHATBOX-'].print('Unknown command.') continue message_json = dumps({ 'action': 'command', 'from': username, 'command': command, 'args': split_message }) else: message_json = dumps({ 'action': 'send_to_server', 'from': username, 'message': values['-INPUTBOX-'] }) communication_socket.send(message_json.encode()) window.close()
cv2.destroyAllWindows() print("Finished processing the directory") if __name__ == "__main__": print("Running main module") sg.theme('DarkAmber') # Add a little color to your windows # All the stuff inside your window. This is the PSG magic code compactor... layout = [[ sg.Text('Select the base directory path, and the required resolution') ], [sg.In(key='-FOLDER_PATH-'), sg.FolderBrowse()], [ sg.InputText(key='-WIDTH-'), sg.Text('Image Width'), ], [sg.InputText(key='-HEIGHT-'), sg.Text('Image Height')], [ sg.Button("Process"), sg.Cancel(), ]] location = (100, 100) # Create the Window window = sg.Window('Image Pre-Processing', layout, location=location) # Event Loop to process "events" while True: event, values = window.read() width = int(values['-WIDTH-']) height = int(values['-HEIGHT-'])
import PySimpleGUI as sg l=[ ] layout = [ [sg.Text('Enter your name'),sg.InputText("", key='name')], [sg.Button("Add"),sg.Button('Exit')], ] window = sg.Window('My first GUI', layout) while True: button, values = window.Read() if button == 'Add': l.append(values['name']) window.FindElement('name').Update("") elif button == 'Exit': sg.Popup('Names are:', l) break
def prepare_user_layout(OOOOOO000OO00000O: UserModel, O0O0000000OOOO00O: str): #line:119 OO0OO0O00000O00O0 = [ [ sg.Button('Reload'), sg.Button('Update my status'), sg.Button('Logout', key='Cancel') ], [sg.Text(O0O0000000OOOO00O, text_color='red')], [ sg.Text('username: '******'Yellow'), sg.Text('role: ', size=(5, 1)), sg.Text(ROLES[OOOOOO000OO00000O.role], size=(10, 1), text_color='Yellow'), sg.Text('status: ', size=(5, 1)), sg.InputText(OOOOOO000OO00000O.status, size=(15, 1), key='status', text_color='Black'), ], ] #line:135 O00O0000OOOOO000O = get_all_users(OOOOOO000OO00000O.role) #line:137 for OOOO00O0OOOOO0OOO in O00O0000OOOOO000O: #line:138 if OOOO00O0OOOOO0OOO.username != OOOOOO000OO00000O.username: #line:139 if check_role(OOOOOO000OO00000O.role, Action.ModifyUsers): #line:140 OO0OO0O00000O00O0 += [[ sg.Text('username: '******'Black', key=str(OOOO00O0OOOOO0OOO.id) + '-username'), sg.Text('role: ', size=(5, 1)), sg.InputCombo(ROLES, default_value=ROLES[OOOO00O0OOOOO0OOO.role], text_color='Black', key=str(OOOO00O0OOOOO0OOO.id) + '-role'), sg.Text('status: ', size=(5, 1)), sg.InputText(OOOO00O0OOOOO0OOO.status, size=(15, 1), text_color='Black', key=str(OOOO00O0OOOOO0OOO.id) + '-status'), sg.Button('U', button_color=('black', 'green'), key=str(OOOO00O0OOOOO0OOO.id) + '-update') ]] #line:149 elif check_role(OOOOOO000OO00000O.role, Action.ModifyStatuses): #line:150 OO0OO0O00000O00O0 += [[ sg.Text('username: '******'Yellow'), sg.Text('role: ', size=(5, 1)), sg.Text(ROLES[OOOO00O0OOOOO0OOO.role], size=(10, 1), text_color='Yellow'), sg.Text('status: ', size=(5, 1)), sg.InputText(OOOO00O0OOOOO0OOO.status, size=(15, 1), text_color='Black', key=str(OOOO00O0OOOOO0OOO.id) + '-status'), sg.Button('U', button_color=('black', 'green'), key=str(OOOO00O0OOOOO0OOO.id) + '-' + 'update') ]] #line:159 else: #line:160 OO0OO0O00000O00O0 += [[ sg.Text('username: '******'Yellow'), sg.Text('role: ', size=(5, 1)), sg.Text(ROLES[OOOO00O0OOOOO0OOO.role], size=(10, 1), text_color='Yellow'), sg.Text('status: ', size=(5, 1)), sg.Text(OOOO00O0OOOOO0OOO.status, size=(15, 1), text_color='Yellow') ]] #line:168 return OO0OO0O00000O00O0 #line:170
def amt_of_returns(self): # this method was mainly for testing because the attributes take the # place of it later in the program # I left it just to give an idea of how the program morphed over time return f'{self.queue_size} Customers have made returns' if __name__ == '__main__': # making my return queue object return_queue = ReturnQueue() # Creating my Theme sg.theme('Topanga') # Creating my layout layout = [[sg.Text('Enter your returns (Separate values by comma)')], [sg.InputText(key="returned")], [sg.Radio('Kohl\'s', "RADIO1", default=False, key="kohls")], [sg.Radio( 'Amazon', "RADIO1", default=False, key="amazon", )], [sg.Button('Enter')], [sg.Text('Amazon to process'), sg.Text('Kohl\'s to process')], [ sg.Text('', key='amazon_text', size=(16, 12)), sg.Text('', key='kohls_text', size=(10, 12)) ], [ sg.Button('Process all'),
def Layout(self): Connect = [sg.Button("Connect or Disconnect", key="-Connect-")] SetPose = [ [ sg.Button("Set pose", size=(7, 1), key="-SetJointPose-"), sg.Button("Set pose", size=(7, 1), key="-SetCoordinatePose-"), ], [ sg.Text("J1", size=(2, 1)), sg.InputText("", size=(5, 1), key="-JointPose1-"), sg.Text("X", size=(1, 1)), sg.InputText("", size=(5, 1), key="-CoordinatePose_X-"), ], [ sg.Text("J2", size=(2, 1)), sg.InputText("", size=(5, 1), key="-JointPose2-"), sg.Text("Y", size=(1, 1)), sg.InputText("", size=(5, 1), key="-CoordinatePose_Y-"), ], [ sg.Text("J3", size=(2, 1)), sg.InputText("", size=(5, 1), key="-JointPose3-"), sg.Text("Z", size=(1, 1)), sg.InputText("", size=(5, 1), key="-CoordinatePose_Z-"), ], [ sg.Text("J4", size=(2, 1)), sg.InputText("", size=(5, 1), key="-JointPose4-"), sg.Text("R", size=(1, 1)), sg.InputText("", size=(5, 1), key="-CoordinatePose_R-"), ], ] # 画像上の位置とDobotの座標系との位置合わせを行うGUI Alignment = [ [sg.Button('MoveToThePoint', size=( 16, 1), key='-MoveToThePoint-'), ], [sg.Button('Set', size=(8, 1), key='-Record-'), sg.Button('Set', size=(8, 1), key='-Set_x1-'), sg.Button('Set', size=(8, 1), key='-Set_x2-'), ], [sg.Text('X0', size=(2, 1)), sg.InputText('', size=(5, 1), disabled=True, key='-x0-'), sg.Text('X1', size=(2, 1)), sg.InputText( '', size=(5, 1), disabled=True, key='-x1-'), sg.Text('X2', size=(2, 1)), sg.InputText('', size=(5, 1), disabled=True, key='-x2-'), ], [sg.Text('Y0', size=(2, 1)), sg.InputText('', size=(5, 1), disabled=True, key='-y0-'), sg.Text('Y1', size=(2, 1)), sg.InputText( '', size=(5, 1), disabled=True, key='-y1-'), sg.Text('Y2', size=(2, 1)), sg.InputText('', size=(5, 1), disabled=True, key='-y2-'), ], [sg.Text('Z0', size=(2, 1)), sg.InputText( '', size=(5, 1), disabled=True, key='-z0-'), ], [sg.Text('R0', size=(2, 1)), sg.InputText( '', size=(5, 1), disabled=True, key='-r0-'), ] ] WebCamConnect = [ [ # Web_Cameraの接続/解放 sg.Button("WEB CAM on/off", size=(15, 1), key="-SetWebCam-"), # カメラのプレビュー sg.Button("Preview Opened", size=(11, 1), key="-Preview-"), # 静止画撮影 sg.Button("Snapshot", size=(7, 1), key="-Snapshot-"), ], [ # PCに接続されているカメラの選択 sg.InputCombo( ("TOSHIBA_Web_Camera-HD", "Logicool_HD_Webcam_C270",), default_value="TOSHIBA_Web_Camera-HD", size=(15, 1), key="-WebCam_Name-", readonly=True, ), # 解像度の選択 sg.InputCombo( ( "640x480", "352x288", "320x240", "176x144", "160x120", "1280x720", "1280x800", ), default_value="1280x800", size=(11, 1), key="-WebCam_FrameSize-", readonly=True, ), # 画像のサイズ・チャンネル数 sg.Text("width", size=(4, 1)), sg.InputText( default_text="0", size=(5, 1), disabled=True, justification="right", key="-IMAGE_width-", ), sg.Text("height", size=(4, 1)), sg.InputText( default_text="0", size=(5, 1), disabled=True, justification="right", key="-IMAGE_height-", ), sg.Text("channel", size=(6, 1)), sg.InputText( default_text="0", size=(5, 1), disabled=True, justification="right", key="-IMAGE_channel-", ), ], # 画像の色・濃度・フィルタリング [ sg.Text('色空間', size=(5, 1)), sg.InputCombo( ( 'RGB', 'Glay', ), default_value='RGB', size=(4, 1), key='-Color_Space-', readonly=True ), sg.Text('濃度変換', size=(7, 1)), sg.InputCombo( ( 'なし', '線形濃度変換', '非線形濃度変換', # ガンマ処理 'ヒストグラム平坦化', ), default_value="なし", size=(18, 1), key='-Color_Density-', readonly=True ), sg.Text('空間フィルタリング', size=(16, 1)), sg.InputCombo( ( 'なし', '平均化', 'ガウシアン', 'メディアン', ), default_value="なし", size=(10, 1), key='-Color_Filtering-', readonly=True ), ], ] # 二値化処理 Binary = [ [ sg.InputCombo( ( 'なし', 'Global', 'Otsu', 'Adaptive', 'Two' ), default_value="なし", size=(10, 1), enable_events=True, key='-Binarization-', readonly=True ), sg.InputCombo( ( 'Mean', 'Gaussian', 'Wellner' ), default_value='Mean', size=(12, 1), disabled=True, key='-AdaptiveThreshold_type-', readonly=True ) ], [ sg.Text('Lower', size=(4, 1)), sg.Slider( range=(0, 127), default_value=10, orientation='horizontal', disabled=True, size=(12, 12), key='-LowerThreshold-' ), sg.Text('Block Size', size=(8, 1)), sg.InputText( default_text='11', size=(4, 1), disabled=True, justification='right', key='-AdaptiveThreshold_BlockSize-', ), ], [ sg.Text('Upper', size=(4, 1)), sg.Slider( range=(128, 256), default_value=138, orientation='horizontal', disabled=True, size=(12, 12), key='-UpperThreshold-' ), sg.Text('Constant', size=(8, 1)), sg.InputText( default_text='2', size=(4, 1), disabled=True, justification='right', key='-AdaptiveThreshold_Constant-' ) ], [sg.Radio(text='R', group_id='color', disabled=True, background_color='grey59', text_color='red', key='-color_R-'), sg.Radio(text='G', group_id='color', disabled=True, background_color='grey59', text_color='green', key='-color_G-'), sg.Radio(text='B', group_id='color', disabled=True, background_color='grey59', text_color='blue', key='-color_B-'), sg.Radio(text='W', group_id='color', disabled=True, background_color='grey59', text_color='snow', key='-color_W-'), sg.Radio(text='Bk', group_id='color', default=True, disabled=True, background_color='grey59', text_color='grey1', key='-color_Bk-') ], ] # 画像から物体の輪郭を切り出す関数の設定部分_GUI ContourExtractionSettings = [ # 輪郭のモードを指定する [sg.Button(button_text='Contours', size=(7, 1), key='-Contours-'), ], [sg.Text('輪郭', size=(3, 1)), sg.InputCombo(('親子関係を無視する', '最外の輪郭を検出する', '2つの階層に分類する', '全階層情報を保持する',), default_value='全階層情報を保持する', size=(20, 1), key='-RetrievalMode-', readonly=True), ], # 近似方法を指定する [sg.Text('近似方法', size=(7, 1)), sg.InputCombo(('中間点を保持する', '中間点を保持しない'), default_value='中間点を保持する', size=(18, 1), key='-ApproximateMode-', readonly=True), ], [sg.Text('Gx', size=(2, 1)), sg.InputText(default_text='0', size=(5, 1), justification='right', key='-CenterOfGravity_x-', readonly=True), sg.Text('Gy', size=(2, 1)), sg.InputText(default_text='0', size=(5, 1), justification='right', key='-CenterOfGravity_y-', readonly=True), ], ] layout = [ Connect, [sg.Col(SetPose, size=(165, 136)), ], [sg.Col(WebCamConnect),], [sg.Frame(title="二値化処理", layout=Binary), sg.Frame(title='画像の重心計算', layout=ContourExtractionSettings), ], [sg.Image(filename='', size=(self.Image_width, self.Image_height), key='-IMAGE-'), sg.Canvas(size=(self.Image_width, self.Image_height), key='-CANVAS-') ], [sg.Quit()], ] return layout
import PySimpleGUI as sg import PySimpleGUIQt as sg_qt # PySimpleGUI is a wrapper for Tkinter and Qt # Text # Input Text # Checkbox # Radio Button # Slider # layout layout = [[sg.Text('Wghat is your name?')], [sg.InputText()], [sg.Button('OK')]] layout2 = [ [sg.Text('Hello what is your name?')], [sg.Input()], [sg.Text('Do you like:')], [sg.Checkbox('Ice cream'), sg.Checkbox('Hot dogs'), sg.Checkbox('Beer')], [sg.Text('What is your favorite ice cream flavor')], [ sg.Radio('Vanilla', 'icecream'), sg.Radio('Chocolate', 'icecream'), sg.Radio('Strawberry', 'icecream') ], [sg.Text('How much do you like Python')], [sg.Slider((0, 100), orientation='h', size=(15, 20))], # size in pixel [sg.OK(), sg.Cancel()]
def añadir_o_modificar(values): datos = leerArchivo() nombre = str(values["__nombre__"]).lower() datos[nombre] = { "Nivel": values["__nivel__"], "PuntajeMAX": values["__puntajeMAX__"], "Tiempo": values["__tiempo__"] + " horas" } escribirArchivo(datos) layout = [[sg.Text("Nombre"), sg.InputText(key="__nombre__")], [sg.Text("Nivel"), sg.InputText(key="__nivel__")], [sg.Text("PuntajeMAX"), sg.InputText(key="__puntajeMAX__")], [sg.Text("Tiempo"), sg.InputText(key="__tiempo__")], [sg.Button("Añadir", key="__añadir__")], [sg.Exit()]] window = sg.Window("Ejercicio 2", layout, finalize=True) while True: event, values = window.read() print(event, values) if event in (sg.WIN_CLOSED, "Exit"): break