NEW Demo - Font Previewer - shows all fonts available

This commit is contained in:
MikeTheWatchGuy 2018-10-18 00:13:33 -04:00
parent 9e722269f0
commit 01a2806eef
1 changed files with 49 additions and 0 deletions

49
Demo_Font_Previewer.py Normal file
View File

@ -0,0 +1,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))