MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / Launcher2

Function Launcher2

DemoPrograms/Demo_Script_Launcher.py:49–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47
48
49def Launcher2():
50 sg.theme('GreenTan')
51
52 filelist = glob.glob(LOCATION_OF_YOUR_SCRIPTS+'*.py')
53 namesonly = []
54 for file in filelist:
55 namesonly.append(ntpath.basename(file))
56
57 layout = [
58 [sg.Listbox(values=namesonly, size=(30, 19),
59 select_mode=sg.SELECT_MODE_EXTENDED, key='demolist'),
60 sg.Output(size=(88, 20), font='Courier 10')],
61 [sg.CBox('Wait for program to complete', default=False, key='wait')],
62 [sg.Button('Run'), sg.Button('Shortcut 1'), sg.Button('Fav Program'), sg.Button('EXIT')],
63 ]
64
65 window = sg.Window('Script launcher', layout)
66
67 # ---===--- Loop taking in user input --- #
68 while True:
69 event, values = window.read()
70 if event in ('EXIT', None):
71 break # exit button clicked
72 if event in ('Shortcut 1', 'Fav Program'):
73 print('Quickly launch your favorite programs using these shortcuts')
74 print('''
75 Or copy files to your github folder.
76 Or anything else you type on the command line''')
77 # copyfile(source, dest)
78 elif event == 'Run':
79 for index, file in enumerate(values['demolist']):
80 print('Launching %s' % file)
81 window.refresh() # make the print appear immediately
82 if values['wait']:
83 execute_command_blocking(LOCATION_OF_YOUR_SCRIPTS + file)
84 else:
85 execute_command_nonblocking(
86 LOCATION_OF_YOUR_SCRIPTS + file)
87
88 window.close()
89
90
91if __name__ == '__main__':

Callers 1

Calls 5

readMethod · 0.95
refreshMethod · 0.95
closeMethod · 0.95
execute_command_blockingFunction · 0.70

Tested by

no test coverage detected