From 01a2806eef2861c91cf3418eac422a9e07280f5e Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 18 Oct 2018 00:13:33 -0400 Subject: [PATCH] NEW Demo - Font Previewer - shows all fonts available --- Demo_Font_Previewer.py | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Demo_Font_Previewer.py diff --git a/Demo_Font_Previewer.py b/Demo_Font_Previewer.py new file mode 100644 index 00000000..a97b2909 --- /dev/null +++ b/Demo_Font_Previewer.py @@ -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)) \ No newline at end of file