Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tkinter: Is it possible to change the stacking order of placed Frames?

Tags:

python

tkinter

I've been experimenting with Frames placed in the root window. As far as I can see, the stacking order is determined when the frames are created, the ones created first being below the ones created later. The order of .place does not seem to have any effect.

Is there some way of changing the stacking order?

like image 320
Eduardo Avatar asked Feb 29 '16 00:02

Eduardo


People also ask

How to stack frames In Tkinter?

Typically, a Tkinter application consists of multiple frames. And you often need to switch between frames to display the one that is relevant to the user’s choice. Tkinter allows you to stack frames on top of each other. To show a particular frame, you can simply raise one above the other in the stacking order. The top frame will be visible.

What is Tkinter and how does it work?

Typically, a Tkinter application consists of multiple frames. And you often need to switch between frames to display the one that is relevant to the user’s choice. Tkinter allows you to stack frames on top of each other.

How to stack frames on top of each other?

Tkinter allows you to stack frames on top of each other. To show a particular frame, you can simply raise one above the other in the stacking order. The top frame will be visible.

How to move to a different section of Tkinter GUI?

We need to move to a different section of the Tkinter GUI by clicking a Tkinter button and then could return to the main section after clicking the button in this new section. switch_frame (self, frame_class) method destroys the old frame and then replaces with the new frame frame_class.


1 Answers

You are probably looking for:

widget.lift()          # move to the top of the stack
widget.lift(another)   # move to just above another widget
widget.lower()         # move to the bottom of the stack
widget.lower(another)  # move to just below another widget

Explained here. (This is the best documentation I can find. If you read effbot, it reads like lift and lower only apply to windows, but in fact they also work with other widgets.)

like image 139
gil Avatar answered Oct 21 '22 04:10

gil