tkinter frames problem
walter hanagriff
walter111 at structurex.net
Thu Jul 6 03:45:57 EDT 2000
it has been over a week since i posted this message with no response
while i see most others get an answer the same or next day, so i
reposted, i hope thats acceptable, or should i wait longer?
am i missing something to this letter that makes the problem
unanswerable? because i sent it in once without source and one person
finally told me to provicde the source with my problem so i did and i
got no responses to it, any advice for getting more help will be greatly
appreciated
this is just a framework i am using as a simplified test case for adding
tkinter to my main program
The first class makes the first frame of the program giving the user 3
options, whichever option he
chooses opens up a second frame from the second class, but they just
keep piling up
i want it so that if an options frame is there when they pick another
frame, the first options frame will
disappear.
i can easily delete the main frame from the Main class, but dont know
how to call the frames
from the defs in the second class, whether i try to call them from Main
or Step2, so how do i make what
i want happen
i think that best explains what i want, any help would be appreciated
from Tkinter import *
# this class makes the main frame and which frames are opened
class Main:
# this function makes the first frame for the program
def __init__(self, root):
Label(root, text = "this program figures the area, perimeter,
and power of n \n"
"____________________________________________").pack()
self.v = IntVar()
self.v.set("1")
Radiobutton(root, text = "1 = Find the power of a number",
variable = self.v, value = 1).pack(anchor = W)
Radiobutton(root, text = "2 = Find the area of a shape",
variable = self.v, value = 2).pack(anchor = W)
Radiobutton(root, text = "3 = Find the perimeter of a shape",
variable = self.v, value = 3).pack(anchor = W)
next = Button(root, text = "Next", padx = 10, command =
self.func.frame2)
next.pack(side = LEFT, padx = 5)
close = Button(root, text = "Close", padx = 10, command =
root.destroy)
close.pack(side = LEFT, padx = 5)
# this says which frame to open depending on which radiobutton above
is picked by user
def ifpick(self):
if self.v.get() == 1: self.func.frame2()
if self.v.get() == 2: self.func.frame3()
if self.v.get() == 3: self.func.frame4()
# This class makes the frames for each function
class Functions:
# this frame is for the power of a number, radiobutton option v == 1
def frame2(self):
Label(root, text = "this frame is where you put information to
get power of n \n"
"______________________________________________").pack(side =
TOP)
# this frame is for the area of a shape, radiobutton option v == 2
def frame3(self):
Label(root, text = "this frame is where you put information to
get the area of a shape \n"
"______________________________________________").pack(side =
BOTTOM)
# this frame is for the perimeter of a shape, radiobutton option v
== 3
def frame4(self):
Label(root, text = "this frame is where you put information to
get the perimeter of a shape \n"
"______________________________________________").pack(side =
BOTTOM)
if __name__== '__main__':
root = Tk()
root.title(title)
start = Main(Toplevel)
root.mainloop()
More information about the Python-list
mailing list