How to get an element to stick to the bottom-right corner in Tkinter?


Tkinter has many inbuilt features, functions, and methods that we can use to construct the GUI of an application. It is necessary to know how we can set the position of a particular widget in the application so that it becomes responsive in nature.

Tkinter also provides geometry managers through which we can set the position of elements and widgets. The Place geometry manager is used for configuring the position of complex widgets.

Example

Let us suppose that we want our widget position to the bottom-right of the application window, then we can use place geometry manager with anchor property.

# Import the required libraries
from tkinter import *
from tkinter import ttk

# Create an instance of tkinter frame or window
win=Tk()

# Set the size of the window
win.geometry("700x350")

# Add buttons in the frame
button1=ttk.Button(win, text="Button-1")
button1.place(rely=1.0, relx=1.0, x=0, y=0, anchor=SE)

win.mainloop()

Output

Running the above code will place the widget at the bottom-right of the window.

Updated on: 05-Aug-2021

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements