-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathYouTube_2020_Lesson - Source File 1.py
662 lines (499 loc) · 26.9 KB
/
YouTube_2020_Lesson - Source File 1.py
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
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
import FreeSimpleGUI as sg
import os
import time
import random
# 8888888b. .d8888b. 888
# 888 Y88b d88P Y88b 888
# 888 888 888 888 888
# 888 d88P 888 888 888 88888b. 8888b. 888d888 88888b.d88b.
# 8888888P" 888 888 888 888 "88b "88b 888P" 888 "888 "88b
# 888 888 888 888 888 888 888 .d888888 888 888 888 888
# 888 Y88b 888 Y88b d88P 888 888 888 888 888 888 888 888
# 888 "Y88888 "Y8888P" 888 888 "Y888888 888 888 888 888
# 888
# Y8b d88P
# "Y88P"
# Modify your color scheme. For me, comments are super-important
# and standout like a high-lighter
def test(x,y): # Note how "y" is grayed out
return x
# 8888888b.
# 888 Y88b
# 888 888
# 888 d88P .d88b. 88888b. 888 888 88888b. .d8888b
# 8888888P" d88""88b 888 "88b 888 888 888 "88b 88K
# 888 888 888 888 888 888 888 888 888 "Y8888b.
# 888 Y88..88P 888 d88P Y88b 888 888 d88P X88
# 888 "Y88P" 88888P" "Y88888 88888P" 88888P'
# 888 888
# 888 888
# 888 888
var = (1,2,3,4)
sg.popup('This is a basic popup', 'I can have multiple item arguments', var)
while True:
text = sg.popup_get_text('Enter "exit" to exit')
if text == 'exit':
break
sg.popup('You entered:', text)
sg.popup_auto_close('Closing the program', background_color='red', text_color='white')
exit()
# d888 888 d8b 888b d888 888
# d8888 888 Y8P 8888b d8888 888
# 888 888 88888b.d88888 888
# 888 888 888 88888b. .d88b. 888Y88888P888 .d88b. 888888 .d88b. 888d888
# 888 888 888 888 "88b d8P Y8b 888 Y888P 888 d8P Y8b 888 d8P Y8b 888P"
# 888 888888 888 888 888 888 88888888 888 Y8P 888 88888888 888 88888888 888
# 888 888 888 888 888 Y8b. 888 " 888 Y8b. Y88b. Y8b. 888
# 8888888 88888888 888 888 888 "Y8888 888 888 "Y8888 "Y888 "Y8888 888
for i in range(1000):
sg.one_line_progress_meter('My meter', i+1, 1000, 'key', 'Message 1', 'Message 2')
for i in range(1000):
if not sg.one_line_progress_meter('My meter', i+1, 1000, 'key', 'Message 1', 'Message 2'):
sg.popup('ABORTED')
break
exit()
# 8888888888 888 8888888888 888
# 888 888 888 888
# 888 888 888 888
# 8888888 888d888 .d88b. 88888b. 888888 8888888 88888b. .d88888
# 888 888P" d88""88b 888 "88b 888 888 888 "88b d88" 888
# 888 888 888 888 888 888 888 888 888 888 888 888
# 888 888 Y88..88P 888 888 Y88b. 888 888 888 Y88b 888
# 888 888 "Y88P" 888 888 "Y888 8888888888 888 888 "Y88888
# A typical command line program often has a hardcoded path with a comment
my_path = r'c:\Python' # If you want to use a different folder, change this variable
files = os.listdir(my_path)
print('\n'.join(files))
exit()
# Add popup_get_folder
# Change print to Print + Popup to stop from exiting
# 888888888 .d8888b. 888 d8b
# 888 d88P Y88b 888 Y8P
# 888 Y88b. 888
# 8888888b. "Y888b. .d88b. .d8888b 888888 888 .d88b. 88888b. .d8888b
# "Y88b "Y88b. d8P Y8b d88P" 888 888 d88""88b 888 "88b 88K
# 888 "888 88888888 888 888 888 888 888 888 888 "Y8888b.
# Y88b d88P Y88b d88P Y8b. Y88b. Y88b. 888 Y88..88P 888 888 X88
# "Y8888P" "Y8888P" "Y8888 "Y8888P "Y888 888 "Y88P" 888 888 88888P'
# 1 - The import
import FreeSimpleGUI as sg
# 2 - Layout definition
layout = [[sg.Text('My layout')],
[sg.Input(key='-INPUT-')],
[sg.Button('OK'), sg.Button('Cancel')]]
# 3 - Create window
window = sg.Window('Design Pattern 3 - Persistent Window', layout)
# 4 - Event Loop
while True:
event, values = window.read()
print(event, values)
if event in (None, 'Cancel'):
break
# 5 - Close window
window.close()
# .d88888b. .d8888b. 888 888
# d88P" "Y88b d88P Y88b 888 888
# 888 888 Y88b. 888 888
# 888 888 88888b. .d88b. "Y888b. 88888b. .d88b. 888888
# 888 888 888 "88b d8P Y8b "Y88b. 888 "88b d88""88b 888
# 888 888 888 888 88888888 "888 888 888 888 888 888
# Y88b. .d88P 888 888 Y8b. Y88b d88P 888 888 Y88..88P Y88b.
# "Y88888P" 888 888 "Y8888 "Y8888P" 888 888 "Y88P" "Y888
layout = [[sg.Text('Name:'), sg.Input(key='-NAME-')],
[sg.Text('Favorite Color:'), sg.Combo(['Red', 'Blue', 'Green', 'Purple'], key='-COLOR-')],
[sg.Button('Ok')]]
event, values = sg.Window('One shot', layout).read(close=True)
sg.popup(event, values)
exit()
# Add bind return key
# Turn into single-line solution
# 888 888 888 888 d8b
# 888 888 888 888 Y8P
# 888 888 888 888
# 888 888 88888b. .d88888 8888b. 888888 888 88888b. .d88b.
# 888 888 888 "88b d88" 888 "88b 888 888 888 "88b d88P"88b
# 888 888 888 888 888 888 .d888888 888 888 888 888 888 888
# Y88b. .d88P 888 d88P Y88b 888 888 888 Y88b. 888 888 888 Y88b 888
# "Y88888P" 88888P" "Y88888 "Y888888 "Y888 888 888 888 "Y88888
# 888 888
# 888 Y8b d88P
# 888 "Y88P"
# 1 - The import
import FreeSimpleGUI as sg
# 2 - Layout definition
layout = [[sg.Text('My layout')],
[sg.Input(key='-IN-')],
[sg.Text('You entered:'), sg.Text(size=(20,1), key='-OUT-')],
[sg.Button('OK'), sg.Button('Cancel')]]
# 3 - Create window
window = sg.Window('Update window with input value', layout)
# 4 - Event Loop
while True:
event, values = window.read()
print(event, values)
if event in (None, 'Cancel'):
break
window['-OUT-'].update(values['-IN-'])
# 5 - Close window
window.close()
exit()
# 88888888888 888
# 888 888
# 888 888
# 888 8888b. 888d888 .d88b. .d88b. 888888 .d8888b
# 888 "88b 888P" d88P"88b d8P Y8b 888 88K
# 888 .d888888 888 888 888 88888888 888 "Y8888b.
# 888 888 888 888 Y88b 888 Y8b. Y88b. X88
# 888 "Y888888 888 "Y88888 "Y8888 "Y888 88888P'
# 888
# Y8b d88P
# "Y88P"
layout = [ [sg.Text('Choose a file/Folder')],
[sg.Text('Choose output folder'), sg.FolderBrowse(target='-IN3-')],
[sg.Input(key='-IN-'), sg.FileBrowse()],
[sg.Input(key='-IN2-', visible=False), sg.FileBrowse()],
[sg.Input(key='-IN3-')],
[sg.Button('Go'), sg.Button('Exit')] ]
window = sg.Window('Window Title', layout)
while True: # Event Loop
event, values = window.read()
print(event, values)
if event in (None, 'Exit'):
break
window.close()
# Enable events
# 888888b. 888 d8b .d888 888
# 888 "88b 888 Y8P d88P" 888
# 888 .88P 888 888 888
# 8888888K. .d88b. 8888b. 888 888 888888 888 888888 888 888 888
# 888 "Y88b d8P Y8b "88b 888 888 888 888 888 888 888 888
# 888 888 88888888 .d888888 888 888 888 888 888 888 888 888
# 888 d88P Y8b. 888 888 Y88b 888 Y88b. 888 888 Y88b 888 888
# 8888888P" "Y8888 "Y888888 "Y88888 "Y888 888 888 "Y88888 888
#
#
#
# 888 888 d8b 888
# 888 o 888 Y8P 888
# 888 d8b 888 888
# 888 d888b 888 888 88888b. .d88888 .d88b. 888 888 888 .d8888b
# 888d88888b888 888 888 "88b d88" 888 d88""88b 888 888 888 88K
# 88888P Y88888 888 888 888 888 888 888 888 888 888 888 "Y8888b.
# 8888P Y8888 888 888 888 Y88b 888 Y88..88P Y88b 888 d88P X88
# 888P Y888 888 888 888 "Y88888 "Y88P" "Y8888888P" 88888P'
exit_button = b'iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAJ7ElEQVR42s2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QNaNNd1mshTHcfoVYD1VQ5teBn8tIcA+XiOxes4vJ8IMfNbuhrj/wGgHu/HiYKxbZuq78kY3weAgNdpCEAEX8HrLAgf2/pdx+jdHKhy5C0tgzEoVItCY52evg7zBxjkGqNXAcJKHM8er8dOMFPitbFOjv8BWgbOqQUuR6kAAAAASUVORK5CYII='
layout = [ [sg.Text('My Window')],
[sg.Button('Go'),
sg.Button(image_data=exit_button, border_width=0,
button_color=(sg.theme_background_color(), sg.theme_background_color()),
key='Exit')]]
window = sg.Window('Window Title', layout)
while True: # Event Loop
event, values = window.read()
print(event, values)
if event in (None, 'Exit'):
break
window.close()
# no titlebar, grab anywhere, alpht .8, black
exit()
# .d8888b. 888
# d88P Y88b 888
# 888 888 888
# 888 .d88b. 888 888 888 88888b.d88b. 88888b. .d8888b
# 888 d88""88b 888 888 888 888 "888 "88b 888 "88b 88K
# 888 888 888 888 888 888 888 888 888 888 888 888 "Y8888b.
# Y88b d88P Y88..88P 888 Y88b 888 888 888 888 888 888 X88
# "Y8888P" "Y88P" 888 "Y88888 888 888 888 888 888 88888P'
# Problem - How to get multiple rows next to an element that consumes multiple rows?
layout = [ [sg.Listbox(list(range(10)), size=(10,5), key='-LBOX-')],
[sg.T('Name'), sg.In()],
[sg.T('Address'), sg.In()],
[sg.Button('Go'), sg.Button('Exit')] ]
window = sg.Window('Window Title', layout,auto_size_text=False, default_element_size=(12,1))
while True: # Event Loop
event, values = window.read()
print(event, values)
if event in (None, 'Exit'):
break
window.close()
exit()
# 8888888888 888 888
# 888 888 888
# 888 888 888
# 8888888 888 .d88b. 88888b.d88b. .d88b. 88888b. 888888 .d8888b
# 888 888 d8P Y8b 888 "888 "88b d8P Y8b 888 "88b 888 88K
# 888 888 88888888 888 888 888 88888888 888 888 888 "Y8888b.
# 888 888 Y8b. 888 888 888 Y8b. 888 888 Y88b. X88
# 8888888888 888 "Y8888 888 888 888 "Y8888 888 888 "Y888 88888P'
import FreeSimpleGUI as sg
sg.theme('Dark Red')
# ------ Menu Definition ------ #
menu_def = [['&File', ['&Open', '&Save', 'E&xit', 'Properties']],
['&Edit', ['Paste', ['Special', 'Normal', ], 'Undo'], ],
['&Help', '&About...'], ]
# ------ Column Definition ------ #
column1 = [[sg.Text('Column 1', justification='center', size=(10, 1))],
[sg.Spin(values=('Spin Box 1', 'Spin Box 2', 'Spin Box 3'),
initial_value='Spin Box 1')],
[sg.Spin(values=['Spin Box 1', 'Spin Box 2', 'Spin Box 3'],
initial_value='Spin Box 2')],
[sg.Spin(values=('Spin Box 1', 'Spin Box 2', 'Spin Box 3'),
initial_value='Spin Box 3')]]
layout = [
[sg.Menu(menu_def, tearoff=True)],
[sg.Text('(Almost) All widgets in one Window!', 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.CBox('Checkbox', size=(10, 1)),
sg.CBox('My second checkbox!', default=True)],
[sg.Radio('My first Radio! ', "RADIO1", default=True, size=(10, 1)),
sg.Radio('My second Radio!', "RADIO1")]], title='Options', relief=sg.RELIEF_SUNKEN, tooltip='Use these to set flags')],
[sg.MLine(default_text='This is the default Text should you decide not to type anything', size=(35, 3)),
sg.MLine(default_text='A second multi-line', size=(35, 3))],
[sg.Combo(('Combobox 1', 'Combobox 2'),default_value='Combobox 1', size=(20, 1)),
sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85)],
[sg.OptionMenu(('Menu Option 1', 'Menu Option 2', 'Menu Option 3'))],
[sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3)),
sg.Frame('Labelled Group', [[
sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25, tick_interval=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.Col(column1)]])
],
[sg.Text('_' * 80)],
[sg.Text('Choose A Folder', size=(35, 1))],
[sg.Text('Your Folder', size=(15, 1), justification='right'),
sg.InputText('Default Folder'), sg.FolderBrowse()],
[sg.Submit(tooltip='Click to submit this form'), sg.Cancel()]]
window = sg.Window('Everything bagel', layout)
event, values = window.read()
sg.popup('Title',
'The results of the window.',
'The button clicked was "{}"'.format(event),
'The values are', values)
window.close()
exit()
# 888 888
# 888 888
# 888 888
# 888 888 .d8888b .d88b. 888d888
# 888 888 88K d8P Y8b 888P"
# 888 888 "Y8888b. 88888888 888
# Y88b. .d88P X88 Y8b. 888
# "Y88888P" 88888P' "Y8888 888
#
#
#
# 8888888b. .d888 d8b 888
# 888 "Y88b d88P" Y8P 888
# 888 888 888 888
# 888 888 .d88b. 888888 888 88888b. .d88b. .d88888
# 888 888 d8P Y8b 888 888 888 "88b d8P Y8b d88" 888
# 888 888 88888888 888 888 888 888 88888888 888 888
# 888 .d88P Y8b. 888 888 888 888 Y8b. Y88b 888
# 8888888P" "Y8888 888 888 888 888 "Y8888 "Y88888
#
#
#
# 8888888888 888 888
# 888 888 888
# 888 888 888
# 8888888 888 .d88b. 88888b.d88b. .d88b. 88888b. 888888 .d8888b
# 888 888 d8P Y8b 888 "888 "88b d8P Y8b 888 "88b 888 88K
# 888 888 88888888 888 888 888 88888888 888 888 888 "Y8888b.
# 888 888 Y8b. 888 888 888 Y8b. 888 888 Y88b. X88
# 8888888888 888 "Y8888 888 888 888 "Y8888 888 888 "Y888 88888P'
#
#
#
# Without user defined element
layout = [ [sg.Text('Enter your information', font='Any 20')],
[sg.Text('Name', size=(8,1), justification='r', font='Any 14'), sg.Input(key='-NAME-')],
[sg.Text('Address', size=(8,1), justification='r', font='Any 14'), sg.Input(key='-ADDRESS-')],
[sg.Text('Phone', size=(8,1), justification='r', font='Any 14'), sg.Input(key='-PHONE-')],
[sg.Button('Go'), sg.Button('Exit')] ]
window = sg.Window('Window Title', layout)
while True: # Event Loop
event, values = window.read()
print(event, values)
if event in (None, 'Exit'):
break
window.close()
##########################################################################################
# User defined element that defines an entire row
def InfoIn(text, key):
return [sg.Text(text, size=(8, 1), justification='r', font='Any 14'), sg.Input(key=key)]
layout = [ [sg.Text('Enter your information', font='Any 20')],
InfoIn('Name', '-NAME-'),
InfoIn('Address', '-ADDRESS-'),
InfoIn('Phone', '-PHONE-'),
[sg.Button('Go'), sg.Button('Exit')] ]
window = sg.Window('Window Title', layout)
while True: # Event Loop
event, values = window.read()
print(event, values)
if event in (None, 'Exit'):
break
window.close()
exit()
# 888888b. d8b 888 888
# 888 "88b Y8P 888 888
# 888 .88P 888 888
# 8888888K. 888 888 888 888 .d88888
# 888 "Y88b 888 888 888 888 d88" 888
# 888 888 888 888 888 888 888 888
# 888 d88P Y88b 888 888 888 Y88b 888
# 8888888P" "Y88888 888 888 "Y88888
#
#
#
# 888 888
# 888 888
# 888 888
# 888 8888b. 888 888 .d88b. 888 888 888888 .d8888b
# 888 "88b 888 888 d88""88b 888 888 888 88K
# 888 .d888888 888 888 888 888 888 888 888 "Y8888b.
# 888 888 888 Y88b 888 Y88..88P Y88b 888 Y88b. X88
# 88888888 "Y888888 "Y88888 "Y88P" "Y88888 "Y888 88888P'
# 888
# Y8b d88P
# "Y88P"
import FreeSimpleGUI as sg
# Build layout using list comprehension
# Make a grid of buttons
layout = [[sg.B(' X ',key=(r,c)) for r in range(3)]for c in range(4)]
# Add on an OK button
layout += [[sg.OK()]]
window = sg.Window('title', layout)
while True:
event, values = window.read()
print(event, values)
if event is None:
break
# Build layout using loops
layout = [[]]
for row in range(5):
row_layout = []
for col in range(5):
row_layout.append(sg.Button('X', key=(row,col)))
layout.append(row_layout)
layout += [[sg.Button('OK'), sg.Button('Cancel')]]
window = sg.Window('Window Title', layout)
while True: # Event Loop
event, values = window.read()
print(event, values)
if event in (None, 'Exit'):
break
if event == 'Go':
window['-OUT-'].update(values['-IN-'])
window.close()
exit()
# .d8888b. 888 888
# d88P Y88b 888 888
# Y88b. 888 888
# "Y888b. 888 888 .d88888 .d88b. 888 888 888 888
# "Y88b. 888 888 d88" 888 d88""88b 888 .88P 888 888
# "888 888 888 888 888 888 888 888888K 888 888
# Y88b d88P Y88b 888 Y88b 888 Y88..88P 888 "88b Y88b 888
# "Y8888P" "Y88888 "Y88888 "Y88P" 888 888 "Y88888
sg.Window('Sudoku',[[sg.Frame('',[[sg.I(random.randint(1,9), justification='r', size=(3,1),key=(frow*3+row,fcol*3+col)) for col in range(3)] for row in range(3)]) for fcol in range(3)] for frow in range(3)]+ [[sg.B('Exit')]]).read()
exit()
# d8888 888 888 d8b
# d88888 888 o 888 Y8P
# d88P888 888 d8b 888
# d88P 888 .d8888b 888 888 88888b. .d8888b 888 d888b 888 888 88888b.
# d88P 888 88K 888 888 888 "88b d88P" 888d88888b888 888 888 "88b
# d88P 888 "Y8888b. 888 888 888 888 888 88888P Y88888 888 888 888
# d8888888888 X88 Y88b 888 888 888 Y88b. 8888P Y8888 888 888 888
# d88P 888 88888P' "Y88888 888 888 "Y8888P 888P Y888 888 888 888
# 888
# Y8b d88P
# "Y88P"
# 88888888888 d8b 888
# 888 Y8P 888
# 888 888
# 888 888 88888b.d88b. .d88b. .d88b. 888 888 888888 .d8888b
# 888 888 888 "888 "88b d8P Y8b d88""88b 888 888 888 88K
# 888 888 888 888 888 88888888 888 888 888 888 888 "Y8888b.
# 888 888 888 888 888 Y8b. Y88..88P Y88b 888 Y88b. X88
# 888 888 888 888 888 "Y8888 "Y88P" "Y88888 "Y888 88888P'
import FreeSimpleGUI as sg
layout = [ [sg.Text('My Timer')],
[sg.Text(size=(12,1), key='-OUT-')],
[sg.Button('Exit')] ]
window = sg.Window('Timer', layout, font='Any 20')
counter = 0
while True: # Event Loop
event, values = window.read(timeout=100)
# print(event, values)
if event in (None, 'Exit'):
break
window['-OUT-'].update(counter)
counter += 1
window.close()
exit()
# .d8888b. 888 88888888888
# d88P Y88b 888 888
# Y88b. 888 888
# "Y888b. 888 888 .d8888b 888888 .d88b. 88888b.d88b. 888 888d888 8888b. 888 888
# "Y88b. 888 888 88K 888 d8P Y8b 888 "888 "88b 888 888P" "88b 888 888
# "888 888 888 "Y8888b. 888 88888888 888 888 888 888 888 .d888888 888 888
# Y88b d88P Y88b 888 X88 Y88b. Y8b. 888 888 888 888 888 888 888 Y88b 888
# "Y8888P" "Y88888 88888P' "Y888 "Y8888 888 888 888 888 888 "Y888888 "Y88888
# 888 888
# Y8b d88P Y8b d88P
# "Y88P" "Y88P"
# import FreeSimpleGUIWx as sg
# import FreeSimpleGUIQt as sg
import FreeSimpleGUI as sg
tray = sg.SystemTray(menu=['UNUSED', ['My', 'Simple', '---', 'Menu', 'Exit']], data_base64=sg.DEFAULT_BASE64_ICON)
while True:
event = tray.read()
if event == 'Exit':
tray.show_message('Exiting', 'Exiting the program', messageicon=sg.SYSTEM_TRAY_MESSAGE_ICON_INFORMATION)
break
exit()
# 8888888b. 888
# 888 "Y88b 888
# 888 888 888
# 888 888 .d88b. 88888b. 888 888 .d88b. .d88b. .d88b. 888d888
# 888 888 d8P Y8b 888 "88b 888 888 d88P"88b d88P"88b d8P Y8b 888P"
# 888 888 88888888 888 888 888 888 888 888 888 888 88888888 888
# 888 .d88P Y8b. 888 d88P Y88b 888 Y88b 888 Y88b 888 Y8b. 888
# 8888888P" "Y8888 88888P" "Y88888 "Y88888 "Y88888 "Y8888 888
# 888 888
# Y8b d88P Y8b d88P
# "Y88P" "Y88P"
import FreeSimpleGUI as sg
layout = [ [sg.Text('My Window')],
[sg.Input(key='-IN-'), sg.Text(size=(12,1), key='-OUT-')],
[sg.Button('Go'), sg.Button('Exit')] ]
window = sg.Window('Window Title', layout)
count = 0
while True: # Event Loop
event, values = window.read(timeout=100)
if event in (None, 'Exit'):
break
count += 1
window.close()
# 8888888888 888 888 d8b
# 888 888 888 Y8P
# 888 888 888
# 8888888 888 888 888888 .d88b. 88888b. .d88888 888 88888b. .d88b.
# 888 `Y8bd8P' 888 d8P Y8b 888 "88b d88" 888 888 888 "88b d88P"88b
# 888 X88K 888 88888888 888 888 888 888 888 888 888 888 888
# 888 .d8""8b. Y88b. Y8b. 888 888 Y88b 888 888 888 888 Y88b 888
# 8888888888 888 888 "Y888 "Y8888 888 888 "Y88888 888 888 888 "Y88888
# 888
# Y8b d88P
# "Y88P"
import FreeSimpleGUI as sg
window = sg.Window('test', layout=[[sg.ProgressBar(max_value=100, size=(30, 10), key='bar')]], finalize=True)
window['bar'].Widget.config(mode='indeterminate')
while True:
event, values = window.read(timeout=100)
if event is None:
break
window['bar'].Widget['value'] += 5