forked from PySimpleGUI/PySimpleGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo_Font_Previewer.py
More file actions
49 lines (43 loc) · 1.43 KB
/
Demo_Font_Previewer.py
File metadata and controls
49 lines (43 loc) · 1.43 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
#!/usr/bin/env python
import sys
if sys.version_info[0] >= 3:
import PySimpleGUI as sg
else:
import PySimpleGUI27 as sg
from tkinter import font
import tkinter
root = tkinter.Tk()
fonts = list(font.families())
fonts.sort()
root.destroy()
sg.ChangeLookAndFeel('Dark')
layout = [[ sg.Text('My Text Element',
size=(20,1),
auto_size_text=False,
click_submits=True,
relief=sg.RELIEF_GROOVE,
font = 'Courier` 25',
text_color='red',
background_color='white',
justification='center',
pad=(5,3),
key='_text_',
tooltip='This is a text element',
) ],
[sg.Listbox(fonts, size=(30,20), change_submits=True, key='_list_')],
[sg.Input(key='_in_')],
[ sg.RButton('Read', bind_return_key=True), sg.Exit()]]
window = sg.Window('My new window',
# grab_anywhere=True,
# force_toplevel=True,
).Layout(layout)
while True: # Event Loop
event, values = window.Read()
if event is None or event == 'Exit':
break
text_elem = window.FindElement('_text_')
print(event, values)
if values['_in_'] != '':
text_elem.Update(font=values['_in_'])
else:
text_elem.Update(font=(values['_list_'][0], 25))