Skip to content

Instantly share code, notes, and snippets.

@JeffersGlass
Created November 9, 2020 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffersGlass/08fe7438de7b1adb751c7b95e308209e to your computer and use it in GitHub Desktop.
Save JeffersGlass/08fe7438de7b1adb751c7b95e308209e to your computer and use it in GitHub Desktop.
import tkinter as tk
from functools import partial
import tkinter.font as tkfont
class App(tk.Frame):
def __init__(self, master):
super().__init__(master)
self.basicFont = tkfont.Font(family='Lucida Grande', size=30)
self.makeLabels()
self.config(bg="#FFCCCC", width=300, height = 300)
self.pack(fill=tk.BOTH, expand=1)
def makeLabels(self):
self.firstLabel = tk.Label(self, text="I'm a variable label!", font=self.basicFont, bg="#CCFFCC")
self.firstLabel.pack(fill=tk.X, expand=1)
self.myVar = tk.StringVar()
self.myVar.trace_add("write", self.textchange)
self.entry = tk.Entry(self, textvariable=self.myVar)
self.entry.pack()
def textchange(self, *args):
self.firstLabel['text'] = self.myVar.get()
if __name__ == '__main__':
myApp = App(tk.Tk())
myApp.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment