Skip to content

Instantly share code, notes, and snippets.

@haraonline
Last active May 2, 2018 14:05
Show Gist options
  • Save haraonline/b6da4a25ceb1cfd84a78c0033f94d1d6 to your computer and use it in GitHub Desktop.
Save haraonline/b6da4a25ceb1cfd84a78c0033f94d1d6 to your computer and use it in GitHub Desktop.
tkinter slider that changes font size dynamically
from tkinter import *
from tkinter import ttk
master = Tk()
master.geometry('750x350+200+200')
scale_1 = ttk.Scale(master, orient='horizontal', length=200, from_=10, to=30)
scale_1.pack(padx=10, pady=30, anchor='nw')
label_1 = ttk.Label(master, text='Hello World', background='orange', font=('Candara', 10, 'italic'))
label_1.pack(padx=10, pady=10, fill='both', expand=True)
def fontSize():
label_1.config(font=('Candara', int(scale_1.get())))
scale_1.config(command=lambda e: fontSize())
master.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment