python - Frames not disappearing when using grid_forget() - Tkinter -


i using radio buttons switch between frames in tkinter, using grid_forget(), advised in 1 of other questions, related switching between frames, but, reason, old frames not disappear.

here extracts code:

def zedpanel(self):     global toolbarz     self.toolbarz = frame(m1,bd=20, relief='flat', width=400)                                                                 self.toolbarz.grid()     self.toolbarz.place(x=1, y=850, anchor=w)  def zcgapanel(self):     global toolbarzcga     self.toolbarzcga = frame(m1,bd=20, relief='flat', width=400)     self.toolbarzcga.grid()     self.toolbarzcga.place(x=1, y=850, anchor=w)    def zdrapanel(self):     global toolbarzdra            self.toolbarzdra = frame(m1,bd=20, relief='flat', width=400)     self.toolbarzdra.grid()     self.toolbarzdra.place(x=1, y=872, anchor=w) 

the 3 functions above call frames buttons. function use switch between them is:

 def selected(self):     global toolbarzdra     global toolbarzcga     global toolbarz     global radiovar      if radiovar.get()==1:         self.toolbarzcga.grid_forget()         self.toolbarzdra.grid_forget()         self.zedpanel()      elif radiovar.get()==2:         self.toolbarz.grid_forget()         self.toolbarzdra.grid_forget()         self.zcgapanel()       else:         self.toolbarzcga.grid_forget()         self.toolbarz.grid_forget()         self.zdrapanel() 

what trying eliminate other 2 frames when button third 1 clicked.

the error

attributeerror: example instance has no attribute 'toolbarzcga'

where example name of class.

what doing wrong?

i think declare toolbars global earlier, not attributes of example-object. self.toolbarzcga should toolbarzcga, global variables not linked current object.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -