MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / main

Function main

DemoPrograms/Demo_SDK_Help_Func_Parms.py:15–105  ·  view source on GitHub ↗

Display a window that will display the docstrings for each PySimpleGUI Element and the Window object

()

Source from the content-addressed store, hash-verified

13"""
14
15def main():
16 """
17 Display a window that will display the docstrings for each PySimpleGUI Element and the Window object
18
19 """
20
21 sg.set_options(font='courier 12')
22
23 functions = [m for m in inspect.getmembers(sys.modules['PySimpleGUI'], inspect.isfunction)]
24 functions_names_lower = [f for f in functions if f[0][0].islower()]
25 functions_names_upper = [f for f in functions if f[0][0].isupper()]
26 # functions_names = sorted(functions_names_lower) + sorted(functions_names_upper)
27 # func_names_str = [f[0] for f in functions if f[0][0].islower()]
28 func_names_str = [f[0] for f in functions]
29
30 func_parm_dict = {}
31
32 # for func_str, func in functions_names_lower:
33 for func_str, func in functions:
34 # Build info about init method
35 args = inspect.signature(func)
36 params = args.parameters
37 func_parm_list = []
38 for a in params.values():
39 func_def = str(a).split('=')
40 if len(func_def) == 1:
41 name, default = func_def[0], '*Required*'
42 if name[0] == '*':
43 default = '*Optional*'
44 elif len(func_def) == 2:
45 name, default = func_def[0], func_def[1]
46 elif len(func_def) == 0:
47 name, default = '', ''
48 else:
49 name, default = func_def[0], '*Object*'
50 func_parm_list.append((name, default))
51 func_parm_dict[func_str] = func_parm_list
52
53 sg.theme('black')
54 sg.theme_background_color('#131314')
55 sg.theme_text_element_background_color('#131314')
56 sg.theme_input_background_color('#131314')
57 ml = sg.Multiline(size=(35, 20), key='-ML-', write_only=True, reroute_stdout=False, expand_y=True, expand_x=True)
58
59 layout = [
60 [sg.Titlebar('Func Parm Viewer', background_color='#131314', text_color='white')],
61 # [sg.Combo([e for e in sorted(func_names_str)],background_color='#131314', size=(25,30), enable_events=True, key='-COMBO-'), sg.T(' '*6, grab=True)],
62 [sg.Combo([e for e in sorted([f[0] for f in functions if f[0][0].islower()])],background_color='#131314', size=(25,30), enable_events=True, readonly=True, expand_x=True, key='-COMBO-')],
63 sg.vtop([ml], expand_x=True, expand_y=True)] + [[sg.Sizegrip()]]
64
65 window = sg.Window('Func Parms', layout, use_default_focus=False, keep_on_top=True, no_titlebar=True, margins=(0,0), right_click_menu=[[],['Edit Me', 'Upper Case Too', 'Lower Case Only', 'Exit']], resizable=True)
66 while True: # Event Loop
67 event, values = window.read()
68 if event in (sg.WIN_CLOSED, 'Exit'):
69 break
70 if event == 'Edit Me':
71 sg.execute_editor(__file__)
72 continue

Callers 1

Calls 6

readMethod · 0.95
printMethod · 0.95
closeMethod · 0.95
valuesMethod · 0.80
set_vscroll_positionMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected