Skip to content
Advertisement

Is there a way to toggle/hide/show tkinter buttons

I am making blackjack in tkinter and instead of placing buttons over the existing buttons i want to toggle them when, say a new game.

Advertisement

Answer

There are many ways of doing this. One option (I think he simplest one) is to get your buttons in a frame that you can pack and unpack using pack and packing_forget. In this case you need another frame where your button frame is the only packed widget, so the buttons will appear in the same place when you pack them again. You can also resize the frame so things on it will become invisible when it becomes really small. Another option is to use a canvas where your buttons are canvas objects. You can them move or hide them as you want.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement