Hi, I am making a GUI with the help of python.In the program, when "ADD" button is pressed new frames build up and when you press "delete" button those frames will be destroyed . My problem is that these frames only get destroyed in Tk but the data structure associated with it (in Python) doesn't change.
#!/usr/bin/python from Tkinter import* class Frame_1(LabelFrame): def __init__(self,master): LabelFrame.__init__(self,master) self.configure(text="Frame1") self.grid() def control_buttons(self,frame): Button( self, text = "Add", command = frame.add_button ).grid( ) Button( self, text = "Read", command = frame.read_button ).grid() class Frame_2(LabelFrame): def __init__(self,master): LabelFrame.__init__(self,master) self.configure(text ="Frame2") self.grid() self.sub_frame = [] def add_button(self): new_frame = Frame_2_1(self) # new_frame.grid() new_frame.populate() self.sub_frame.append(new_frame) # print self.sub_frame def read_button(self): print "#"*10 for sub_frame in self.sub_frame : print "-"*30 print "band:"+ sub_frame.band.get() print "channel:" + sub_frame.channel.get() class Frame_2_1(LabelFrame): def __init__(self,tkmaster): LabelFrame.__init__(self,tkmaster) self.configure(text ="DEFAULT") self.grid() def populate(self): self.band = StringVar() self.band.set("900") option = OptionMenu(self, self.band,"900","1800","1900" ).grid() self.channel = StringVar() self.channel.set("CS 1") option = OptionMenu(self,self.channel,"CS 1","CS 2","CS 3","CS 4").grid( ) global temp temp= temp+1 Button(self,text = "Remove"+ str(temp),command= self.delete_frame).grid() def delete_frame(self): self.destroy() root = Tk() temp=-1 # Create frame 1 frame_1 = Frame_1(root) # Create frame 2 frame_2 = Frame_2(root) frame_1.control_buttons(frame_2) root.mainloop() -------------------------------------------------------------------------- -- http://mail.python.org/mailman/listinfo/python-list