Destroy a frame : Frame « Tkinker « Python Tutorial






Destroy a frame
from Tkinter import *

class MyApp:
  def __init__(self, parent):
    self.myParent = parent   
    self.myContainer1 = Frame(parent)
    self.myContainer1.pack()
    
    self.button1 = Button(self.myContainer1, command=self.button1Click)
    self.button1.configure(text="OK", background= "green")
    self.button1.pack(side=LEFT)
    self.button1.focus_force()         

    
    self.button2 = Button(self.myContainer1, command=self.button2Click) 
    self.button2.configure(text="Cancel", background="red")     
    self.button2.pack(side=RIGHT)

    
  def button1Click(self): 
    print "button1Click event handler" 
    if self.button1["background"] == "green":  
      self.button1["background"] = "yellow"
    else:
      self.button1["background"] = "green"
  
  def button2Click(self):
    print "button2Click event handler" 
    self.myParent.destroy()      
      
root = Tk()
myapp = MyApp(root)
root.mainloop()








18.14.Frame
18.14.1.Demonstrates creating a windowDemonstrates creating a window
18.14.2.Frame with three buttonsFrame with three buttons
18.14.3.Set size of main windowSet size of main window
18.14.4.Add button to frameAdd button to frame
18.14.5.Bind mouse action to a methodBind mouse action to a method
18.14.6.Two top level windowsTwo top level windows
18.14.7.Destroy a frameDestroy a frame
18.14.8.Set window title for main frameSet window title for main frame