-
-
Save JeffersGlass/08fe7438de7b1adb751c7b95e308209e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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