Demonstrates using a class with Tkinter
from Tkinter import *
class Application(Frame):
def __init__(self, master):
Frame.__init__(self, master)
self.grid()
self.create_widgets()
def create_widgets(self):
self.bttn1 = Button(self, text = "OK")
self.bttn1.grid()
self.bttn2 = Button(self)
self.bttn2.grid()
self.bttn2.configure(text = "Cancel")
self.bttn3 = Button(self)
self.bttn3.grid()
self.bttn3["text"] = "Apply"
root = Tk()
root.title("Use button")
root.geometry("200x85")
app = Application(root)
root.mainloop()
Related examples in the same category