I have an app that has a base frame, and some other frames inside of that
base frame. My question is if there is some way to clear out the base frame.
Meaning leaving an empty baseframe. See I have a function that pulls up
frames inside that base frame. The problem comes when I hit a button(this
button is the button that first shows the frames inside the base frame,
basically you click it and the internal frames show up.) and then I hit it
again, I get some weird stuff. Okay, this is getting really complicated. I
really just want to know if I can clear out a frame, and still be able to
fill it back up again. If you want ot uunderstand further I'll post the code
at the bottom and just run it, then hit the "Word List" button, then hit it
again, you'll see what I am talking about. 

Here's the code:

from Tkinter import*

class App:
    def __init__(self, parent):
        self.parent = parent
        self.parent.geometry("500x250")

        #----------------------------Contstants for Buttons------------
      
        button_padx = "2m"
        button_pady = "1m"
        
        #--------------------------end constants-----------------------

        self.baseContainer = Frame(self.parent)
        self.baseContainer.pack(side=TOP, fill = BOTH, expand=NO)

        #the Top Frame with all the buttons
        self.topContainer = Frame(self.baseContainer)
        self.topContainer.pack(side=TOP, expand=YES, ipadx=5,
                               ipady=5, fill = X, anchor=N)

        

        #the frame with the main things the user will use
        self.mainContainer = Frame(self.baseContainer)
        self.mainContainer.pack(side=TOP,
                                ipadx = 5,
                                ipady = 5,
                                anchor=CENTER,
                                expand=YES,
                                fill=BOTH)
        
        #---------------------Top Buttons-----------------------------        
        self.defineButton = Button(self.topContainer, padx=button_padx,
                                   pady=button_pady)
        self.defineButton.configure(text="Word List",
command=self.define_Frame)
        self.defineButton.pack(side=LEFT)
        
        #--------------------------------------------------------------
    def define_Frame(self):    
        myMessage="Please type in all the words that you would like to
define"
        Label(self.mainContainer, text=myMessage,
                    justify=LEFT).pack(side=TOP, anchor=N)

        #The LEFT Frame that comes up when you hit define
        self.defineContainer1 = Frame(self.mainContainer)
        self.defineContainer1.pack(side=LEFT, ipadx = 5,
                                    ipady = 5, expand=YES, fill=BOTH)
        
        #The RIGHT Frame that comes up when you hit define
        self.defineContainer2 = Frame(self.mainContainer)
        self.defineContainer2.pack(side=LEFT, ipadx=5,
                                    ipady=5, expand=YES, fill=BOTH)

        #This frame is where the define button goes
        self.defineButtonF = Frame(self.baseContainer)
        self.defineButtonF.pack(side=TOP,
                                anchor=S,
                                ipady=5,
                                ipadx=5,
                                fill=BOTH,
                                expand=NO)
        

        #----------------------------Contstants for Buttons------------
      
        self.button_padx = "2m"
        self.button_pady = "1m"
        
        #--------------------------end constants-----------------------




        #----------------------STUFF FOR DEFINE
FRAME-------------------------

        self.e1 = Entry(self.defineContainer1)
        self.e1.pack(fill=X)
    
        self.e2 = Entry(self.defineContainer1)
        self.e2.pack(fill=X)

        self.e3 = Entry(self.defineContainer1)
        self.e3.pack(fill=X)

        self.e4 = Entry(self.defineContainer1)
        self.e4.pack(fill=X)

        self.e5 = Entry(self.defineContainer1)
        self.e5.pack(fill=X)
        
        self.e6 = Entry(self.defineContainer1)
        self.e6.pack(fill=X)
        
        self.e7 = Entry(self.defineContainer1)
        self.e7.pack(fill=X)

        self.e8 = Entry(self.defineContainer2)
        self.e8.pack(fill=X)
    
        self.e9 = Entry(self.defineContainer2)
        self.e9.pack(fill=X)

        self.e10 = Entry(self.defineContainer2)
        self.e10.pack(fill=X)

        self.e11 = Entry(self.defineContainer2)
        self.e11.pack(fill=X)

        self.e12 = Entry(self.defineContainer2)
        self.e12.pack(fill=X)

        self.e13 = Entry(self.defineContainer2)
        self.e13.pack(fill=X)

        self.e14 = Entry(self.defineContainer2,)
        self.e14.pack(fill=X)

#-------------------------Define Button Stuff-------------------------
    
        #Define it button
        self.defineIt= Button(self.defineButtonF, command=self.DefineClick)
        self.defineIt.configure(text="Define!")
        self.defineIt.bind("<Return>", self.DefineClickE)
        self.defineIt.pack(side=TOP,
                            anchor=N,
                            padx=self.button_padx,
                            pady=self.button_pady,)
    def DefineClickE(self, event):
        print "Define was hit with Enter"
        self.DefineClick()
    def DefineClick(self):
        print "Define was activated."

#----------------------------end define Button Stuff----------------------



root = Tk()
app = App(root)
root.mainloop()
-- 
View this message in context: 
http://www.nabble.com/Clearing-out-a-Frame-tp18230530p18230530.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to