0

Possible Duplicate:
In Tkinter is there any way to make a widget not visible?

I have a label looks like:

Lab = Label(text = "Update ID")
Lab.pack(side = LEFT)

I want this label invisible but would like to make it visible when particular button is clicked.

I have a button looks like:

Button1 = Button(buttons, text = "Update Item", command = self.Update_item)
          Button6.pack(side = LEFT, padx = 5, pady = 3)

I want the label invisible but would like to make it visible when 'Button1' is clicked.

Any feedbacks would be appreciated.

Community
  • 1
  • 1
JuM
  • 447
  • 1
  • 7
  • 10
  • You have not even specified which gui library you are using. Are you familiar with gui programming in general? Obviously you have to bind an event to the button. What's exactly your problem? – Achim Oct 08 '12 at 09:31
  • @Achim: be careful about what you say -- binding to an event isn't obvious nor necessary in this case -- see the answers. – Bryan Oakley Oct 08 '12 at 10:45

1 Answers1

0

There are a couple ways to accomplish this. For one, you can use the lift and lower attributes to change the stacking order. For example, if the label is a child of a frame and y ou lower it, it will go "behind" the frame and thus become invisible. T

A second option is to completely remove the label from the display. You can use grid_remove if you are using the grid geometry manager. The nice thing about this method is that grid remembers where the widget was, so to restore it you can call widget.grid() and all of the previous options (sticky, row, column, etc) will be used.

There is also pack_forget() and grid_forget(), but they have the disadvantage of truly forgetting about the widget. It is removed from the display and the information about where it was placed is forgotten. This means you must re-apply all of the proper options to get the widget to appear in the same place.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685