forked from PySimpleGUI/PySimpleGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo_PSG_SDK_Quick_Ref.py
More file actions
567 lines (515 loc) · 15.3 KB
/
Demo_PSG_SDK_Quick_Ref.py
File metadata and controls
567 lines (515 loc) · 15.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
#!/usr/bin/env python
import sys
if sys.version_info[0] >= 3:
import PySimpleGUI as sg
else:
import PySimpleGUI27 as sg
desc_text = """
Text( text
size=(None, None)
auto_size_text=None
click_submits=None
relief=None
font=None
text_color=None
background_color=None
justification=None
pad=None
key=None
tooltip=None)
Shortcuts: Txt, T
"""
desc_inputtext = """
InputText( default_text =''
size=(None, None)
disabled=False
auto_size_text=None
password_char=''
justification=None
background_color=None
text_color=None
font=None
tooltip=None
do_not_clear=False
key=None
focus=False
pad=None)
Shortcuts: In, Input
"""
desc_inputcombo = """
InputCombo( values
default_value=None
size=(None, None)
auto_size_text=None
background_color=None
text_color=None
change_submits=False
disabled=False
key=None
pad=None
tooltip=None)
Shortcuts: Combo, DropDown, Drop
"""
desc_inputoptionmenu = """
InputOptionMenu(values
default_value=None
size=(None, None)
disabled=False
auto_size_text=None
background_color=None
text_color=None
key=None
pad=None
tooltip=None)
Shortcuts: OptionMenu
"""
desc_listbox = """
Listbox(values
default_values=None
select_mode=None
change_submits=False
bind_return_key=False
size=(None, None)
auto_size_text=None
font=None
background_color=None
text_color=None
key=None
pad=None
tooltip=None)
"""
desc_checkbox = """
CheckBox( text
default=False
size=(None, None)
auto_size_text=None
font=None
background_color=None
text_color=None
change_submits=False
disabled=False
key=None
pad=None
tooltip=None)
Shortcuts: CB, CBox, Check
"""
desc_radio = """
Radio( text
group_id
default=False
disabled=False
size=(None, None)
auto_size_text=None
background_color=None
text_color=None
font=None
key=None
pad=None
tooltip=None)
"""
desc_spin = """
Spin( values
initial_value=None
disabled=False
change_submits=False
size=(None, None)
auto_size_text=None
font=None
background_color=None
text_color=None
key=None
pad=None
tooltip=None)
"""
desc_multiline = """
MultiLine( default_text=''
enter_submits = False
disabled=False
autoscroll=False
size=(None,None)
auto_size_text=None
background_color=None
text_color=None
do_not_clear=False
key=None
focus=False
pad=None
tooltip=None)
"""
desc_output = """
Output( size=(None, None)
background_color=None
text_color=None
pad=None
font=None
tooltip=None
key=None)
"""
desc_button = """
Button( button_text=''
button_type=BUTTON_TYPE_CLOSES_WIN
target=(None, None)
tooltip=None
file_types=(("ALL Files", "*.*"),)
initial_folder=None
disabled=False
image_filename=None
image_size=(None, None)
image_subsample=None
border_width=None
size=(None, None)
auto_size_button=None
button_color=None
default_value = None
font=None
bind_return_key=False
focus=False
pad=None
key=None)
"""
desc_progressbar = """
ProgressBar(max_value
orientation=None
size=(None, None)
auto_size_text=None
bar_color=(None, None)
style=None
border_width=None
relief=None
key=None
pad=None)
"""
desc_image = """
Image( filename=None
data=None
size=(None, None)
pad=None
key=None
tooltip=None)
"""
desc_canvas = """
Canvas( canvas=None
background_color=None
size=(None, None)
pad=None
key=None
tooltip=None)
"""
desc_graph = """
Graph( canvas_size
graph_bottom_left
graph_top_right
background_color=None
pad=None
key=None
tooltip=None)
"""
desc_frame = """
Frame( title
layout
title_color=None
background_color=None
title_location=None
relief=DEFAULT_FRAME_RELIEF
size=(None, None)
font=None
pad=None
border_width=None
key=None
tooltip=None)
"""
desc_tab = """
Tab(title
layout
title_color=None
background_color=None
font=None
pad=None
disabled=False
border_width=None
key=None
tooltip=None)
"""
desc_tabgroup = """
TabGroup( layout
tab_location=None
title_color=None
selected_title_color=None
background_color=None
font=None
change_submits=False
pad=None
border_width=None
theme=None
key=None
tooltip=None)
"""
desc_slider = """
Slider( range=(None,None)
default_value=None
resolution=None
orientation=None
border_width=None
relief=None
change_submits=False
disabled=False
size=(None, None)
font=None
background_color=None
text_color=None
key=None
pad=None
tooltip=None)
"""
desc_spin = """
Spin( values
initial_value=None
disabled=False
change_submits=False
size=(None, None)
auto_size_text=None
font=None
background_color=None
text_color=None
key=None
pad=None
tooltip=None)
"""
desc_tree = """
Tree( data=None,
headings=None,
visible_column_map=None,
col_widths=None,
col0_width=10,
def_col_width=10,
auto_size_columns=True,
max_col_width=20,
select_mode=None,
font=None,
justification='right',
text_color=None,
background_color=None,
num_rows=None,
pad=None,
key=None,
tooltip=None):
"""
desc_column = """
Column( layout
background_color = None
size=(None, None)
pad=None
scrollable=False
key=None)
"""
desc_table = """
Table( values
headings=None
visible_column_map=None
col_widths=None
def_col_width=10
auto_size_columns=True
max_col_width=20
select_mode=None
display_row_numbers=False
scrollable=None
font=None
justification='right'
text_color=None
background_color=None
size=(None, None)
pad=None
key=None
tooltip=None)
"""
desc_window = """
Window( title
default_element_size=DEFAULT_ELEMENT_SIZE
default_button_element_size = (None, None)
auto_size_text=None
auto_size_buttons=None
location=(None, None)
button_color=None
font=None
progress_bar_color=(None, None)
background_color=None
border_depth=None
auto_close=False
auto_close_duration=DEFAULT_AUTOCLOSE_TIME
icon=DEFAULT_WINDOW_ICON
force_toplevel = False
return_keyboard_events=False
use_default_focus=True
text_justification=None
no_titlebar=False
grab_anywhere=False
keep_on_top=False)
"""
desc_menu= """
Menu(menu_definition
background_color=None
size=(None, None)
tearoff=True
pad=None
key=None)
"""
desc_button_types = """
There are multiple button types / names to choose from
SimpleButton = Button
ReadFormButton = ReadButton = RButton
RealtimeButton
DummyButton
FolderBrowse
FileBrowse
FilesBrowse
FileSaveAs = SaveAs
CalendarButton
ColorChooserButton
Shortcuts - Normal buttons with predefined text
Save, Open, OK, Ok, Cancel, Quit, Exit, Yes, No, Help
"""
desc_popup= """
Popup(button_color=None
background_color=None
text_color=None
button_type=POPUP_BUTTONS_OK
auto_close=False
auto_close_duration=None
non_blocking=False
icon=DEFAULT_WINDOW_ICON
line_width=None
font=None
no_titlebar=False
grab_anywhere=False
keep_on_top=False
location=(None,None))
"""
desc_popups = """
PopupScrolled
PopupGetFolder
PopupGetFile
PopupGetText
POopup
PopupNoButtons
PopupNonBlocking = PopupNoWait
PopupQuick
PopupNoTitleBar = PopupNoFrame = PopupNoBorder = PopupAnnoying
PopupAutoClose = PopupTimed
PopupError
PopupCancel
PopupOK
PopupOKCancel
PopupYesNo
"""
desc_one_line_progress_meter = """
OneLineProgressMeter(title
current_value
max_value
key
*args
orientation=None
bar_color=(None,None)
button_color=None
size=DEFAULT_PROGRESS_BAR_SIZE
border_width=None
grab_anywhere=False):
"""
element_list = ('Window',
'Text',
'InputText',
'CheckBox',
'RadioButton',
'Listbox',
'InputCombo',
'Slider',
'Spinner',
'Multiline',
'Output',
'ProgressBar',
'OptionMenu',
'Menu',
'Frame',
'Column',
'Graph',
'Image',
'Table',
'Tab',
'TabGroup',
'Button Types')
descriptions = {'Window': desc_window, 'Text': desc_text, 'InputText': desc_inputtext, 'CheckBox': desc_checkbox,
'RadioButton': desc_radio, 'Listbox': desc_listbox, 'Slider': desc_slider, 'Spinner':desc_spin, 'Multiline': desc_multiline,
'Output': desc_output, 'ProgressBar': desc_progressbar, 'OptionMenu': desc_inputoptionmenu,
'InputCombo': desc_inputcombo, 'Menu': desc_menu, 'Frame': desc_frame, 'Column': desc_column,
'Graph': desc_graph, 'Image': desc_image, 'Table': desc_table, 'Tree': desc_tree,'Tab': desc_tab,
'TabGroup': desc_tabgroup, 'Button Types': desc_button_types}
tab_text = [[sg.Column([[sg.T('This is sample text')],[ sg.Text(desc_text, font=('Consolas 12'))]])]]
tab_input = [[sg.Column([[sg.Input(size=(15,1))],[sg.Text(desc_inputtext, font=('Consolas 12'))]])]]
tab_checkbox = [[sg.Column([[sg.Checkbox('Checkbox', size=(15,1))],[sg.Text(desc_checkbox, font=('Consolas 12'))]])]]
tab_radio = [[sg.Column([[sg.Radio('Radio Button', group_id=1, size=(15,1))],[sg.Text(desc_radio, font=('Consolas 12'))]])]]
tab_listbox = [[sg.Column([[sg.Listbox(values=[1,2,3,4] ,size=(15,4))],[sg.Text(desc_listbox, font=('Consolas 12'))]])]]
tab_slider = [[sg.Column([[sg.Slider((1,100), orientation='h', size=(15,15))],[sg.Text(desc_slider, font=('Consolas 12'))]])]]
tab_spinner = [[sg.Column([[sg.Spin((1,2,3,4,5),initial_value=1,size=(15,1))],[sg.Text(desc_spin, font=('Consolas 12'))]])]]
tab_multiline = [[sg.Column([[sg.Multiline(size=(15,1))],[sg.Text(desc_multiline, font=('Consolas 12'))]])]]
tab_output= [[sg.Column([[sg.Text(desc_output, font=('Consolas 12'))]])]]
tab_progressbar = [[sg.Column([[sg.Text(desc_progressbar, font=('Consolas 12'))]])]]
tab_optionmenu = [[sg.Column([[sg.OptionMenu([1,2,3,4,5], size=(15,1))],[sg.Text(desc_inputoptionmenu, font=('Consolas 12'))]])]]
tab_combo = [[sg.Column([[sg.Combo([1,2,3,4,5], size=(15,1))],[sg.Text(desc_inputoptionmenu, font=('Consolas 12'))]])]]
tab_frame = [[sg.Column([[sg.Frame('Frame',[[sg.T(' ')]], size=(15,1))],[sg.Text(desc_frame, font=('Consolas 12'))]])]]
tab_column = [[sg.Text(desc_column, font=('Consolas 12'))]]
tab_graph = [[sg.Text(desc_graph, font=('Consolas 12'))]]
tab_tab = [[sg.Text(desc_tab, font=('Consolas 12'))]]
tab_tabgroup = [[sg.Text(desc_tabgroup, font=('Consolas 12'))]]
tab_image = [[sg.Text(desc_image, font=('Consolas 12'))]]
tab_table = [[sg.Text(desc_table, font=('Consolas 12'))]]
tab_tree = [[sg.Text(desc_tree, font=('Consolas 12'))]]
tab_menu = [[sg.Text(desc_menu, font=('Consolas 12'))]]
tab_button_types = [[sg.Text(desc_button_types, font=('Consolas 12'))]]
tab_popup = [[sg.Text(desc_popup, font=('Consolas 12'))]]
tab_popups = [[sg.Text(desc_popups, font=('Consolas 12'))]]
tab_one_line_prog_meter = [[sg.Text(desc_one_line_progress_meter, font=('Consolas 12'))]]
tab_window = [[sg.Text(desc_window, font=('Consolas 12'))]]
layout = [[sg.TabGroup([[sg.Tab('Window',tab_window),
sg.Tab('Text',tab_text),
sg.Tab('InputText', tab_input),
sg.Tab('Checkbox', tab_checkbox),
sg.Tab('Radio',tab_radio),
sg.Tab('Listbox', tab_listbox),
sg.Tab('Slider', tab_slider),
sg.Tab('Spinner',tab_spinner),
sg.Tab('Multiline', tab_multiline),
sg.Tab('OptionMenu', tab_optionmenu),
sg.Tab('Combo', tab_combo),
sg.Tab('Image', tab_image),
sg.Tab('Output', tab_output),
sg.Tab('Table', tab_table),
sg.Tab('Tree', tab_tree),
sg.Tab('Graph', tab_graph),
sg.Tab('ProgressBar', tab_progressbar),
sg.Tab('Frame', tab_frame),
sg.Tab('Column', tab_column),
sg.Tab('Tab', tab_tab),
sg.Tab('TabGroup', tab_tabgroup),
sg.Tab('Menu', tab_menu),
sg.Tab('Button Types', tab_button_types),
sg.Tab('Popup', tab_popup),
sg.Tab('Popups', tab_popups),
sg.Tab('One Line Prog Meter', tab_one_line_prog_meter),
]], tab_location='lefttop', title_color='blue', selected_title_color='red')]]
# layout = [[sg.Text('The PySimpleGUI SDK Quick Reference Guide', font='Any 15', relief=sg.RELIEF_RAISED)],
# [sg.Listbox(values=element_list, size=(15, len(element_list) + 2), key='_in_', change_submits=True,
# font=('Consolas 12')),
# sg.Text(desc_text, size=(55, 25), font=('Consolas 13'), text_color='darkblue', key='_out_')]]
window = sg.Window('PySimpleGUI SDK Quick Reference',
font='Any 12',
grab_anywhere=True).Layout(layout)
while True:
event, values = window.Read()
if event is None or event == 'Exit':
break
element = values['_in_'][0]
try:
desc = descriptions[element]
except:
desc = ''
window.FindElement('_out_').Update(desc)
# print(button, values)