Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ You can set and get the following properties:
| enabled | boolean | `True` if the app is enabled |
| height | int | The height of the window |
| font | string | The font that widgets should use |
| fonts | tuple | A sorted tuple of the fonts available for this application |
| full_screen | boolean | False |
| image | image_source (string) | The file path, tkinter.PhotoImage or PIL.Image you wish to use as the window icon. |
| layout | string | The layout being used by the App (`"auto"`) or (`"grid"`) |
Expand Down
17 changes: 17 additions & 0 deletions examples/pick_font.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from guizero import App, Combo, Text

app = App("Font picker")

Text(app, "Pick a font")

def change_font():
app.font = font_picker.value

font_picker = Combo(
app,
options=app.fonts,
selected=app.font,
command=change_font
)

app.display()
9 changes: 8 additions & 1 deletion guizero/App.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from tkinter import Tk, Toplevel
from tkinter import Tk, Toplevel, font
from .base import BaseWindow
from . import utilities as utils, system_config

Expand Down Expand Up @@ -87,3 +87,10 @@ def destroy(self):
if self == App._main_app:
App._main_app = None
self.tk.destroy()

@property
def fonts(self):
"""
Returns a tuple of available fonts ('Courier', 'Public Sans', 'Roman')
"""
return sorted(font.families())