alright i'm consulting a tkinter forum right now on this but i figured that i would ask here too.
i have a basic program that i would like to put into a class so i can use functions inside it. for example this is what i got so far.
i tried to put it into a class and this is what i came out with...
any help?
i have a basic program that i would like to put into a class so i can use functions inside it. for example this is what i got so far.
Code:
from Tkinter import *
root = Tk()
root.geometry('600x200')
c1 = "black"
p1 = 2
wd = 4
typeguess = StringVar()
Entry(root, textvariable = typeguess).grid(row = 4, column = 2, padx = p1, pady = p1, columnspan = 3)
Label(root, text = "Pick a Letter ").grid(row = 4, column = 0, padx = p1, pady = p1, columnspan = 2)
Button(root, text = "Go ", fg = c1, width = 3).grid(row = 4, column = 5, padx = p1, pady = p1)
Button(root, text = "Q", fg = c1, borderwidth = 3, relief = 'raised', width = wd).grid(row = 3, column = 0, padx = p1, pady = p1)
Button(root, text = "W", fg = c1, borderwidth = 3, relief = 'raised', width = wd).grid(row = 3, column = 1, padx = p1, pady = p1)
Button(root, text = "E", fg = c1, borderwidth = 3, relief = 'raised', width = wd).grid(row = 3, column = 2, padx = p1, pady = p1)
Button(root, text = "R", fg = c1, borderwidth = 3, relief = 'raised', width = wd).grid(row = 3, column = 3, padx = p1, pady = p1)
Button(root, text = "T", fg = c1, borderwidth = 3, relief = 'raised', width = wd).grid(row = 3, column = 4, padx = p1, pady = p1)
Button(root, text = "Y", fg = c1, borderwidth = 3, relief = 'raised', width = wd).grid(row = 3, column = 5, padx = p1, pady = p1)
root.mainloop()
i tried to put it into a class and this is what i came out with...
Code:
from Tkinter import *
root = Tk()
class App:
def __init__(self):
self.geometry('600x200')
c1 = "black"
p1 = 2
wd = 4
self.typeguess = StringVar()
self.Entry(root, textvariable = typeguess).grid(row = 4, column = 2, padx = p1, pady = p1, columnspan = 3)
self.Label(root, text = "Pick a Letter ").grid(row = 4, column = 0, padx = p1, pady = p1, columnspan = 2)
self.Button(root, text = "Go ", fg = c1, width = 3).grid(row = 4, column = 5, padx = p1, pady = p1)
self.Button(root, text = "Q", fg = c1, borderwidth = 3, relief = 'raised', width = wd).grid(row = 3, column = 0, padx = p1, pady = p1)
self.Button(root, text = "W", fg = c1, borderwidth = 3, relief = 'raised', width = wd).grid(row = 3, column = 1, padx = p1, pady = p1)
self.Button(root, text = "E", fg = c1, borderwidth = 3, relief = 'raised', width = wd).grid(row = 3, column = 2, padx = p1, pady = p1)
self.Button(root, text = "R", fg = c1, borderwidth = 3, relief = 'raised', width = wd).grid(row = 3, column = 3, padx = p1, pady = p1)
self.Button(root, text = "T", fg = c1, borderwidth = 3, relief = 'raised', width = wd).grid(row = 3, column = 4, padx = p1, pady = p1)
self.Button(root, text = "Y", fg = c1, borderwidth = 3, relief = 'raised', width = wd).grid(row = 3, column = 5, padx = p1, pady = p1)
app = App(root)
root.mainloop()
any help?