[Tutor] Killing Buttons! (in Tk)

andy surany mongo57a@comcast.net
Tue Oct 29 00:04:01 2002


Well, after 6 hours of research and trying different things, I'm able to
answer my own question. This may not mean much to you experienced folks
on the list, but for us beginners, the following might prove useful.

I was using the Tk button function directly, as such:

    Button(self, text='aaa', command=self.x).pack(side=LEFT)

which was correct - but incorrect. (I remember that someone on the list
warned of this type of packing).

I needed to split the command and make an assignment:

    self.Button_1 = Button(self, text='aaa', command=self.x)
    self.Button_1.pack(side=LEFT)

Now I could delete the button:

    self.Button_1.destroy()

HTH
  -----Original Message-----
  From: andy surany <mongo57a@comcast.net>
  To: tutor@python.org <tutor@python.org>
  Date: Monday, October 28, 2002 11:59 AM
  Subject: [Tutor] Killing Buttons! (in Tk)


  Now that I have buttons created - and working, how do I get rid of
them? In the application, the buttons change based on the function. Do I
just destroy the widget? If so, how? Or do I have to disable and hide
the buttons? Anyone have an example??

  Thanks.