Tkinter

place() Method in Tkinter Python 3

In this tutorial, we are going to see how to use place() Method in Tkinter Python 3. This geometry method arranges widgets by putting them in a particular position in the parent widget.
 

Syntax:
widget.place(options)

 

 
Here is the list of options:

  • anchor: The exact location of the widget to which the other options refer: can be N, E, S, W, NE, NW, SE or SW, default is NW (the upper left corner of the widget)
  • bordermode: Specify INSIDE (default vlue) to show that other options relate to the inside of the parent (ignoring the parent’s border); OUTSIDE instead.
  • height, width: Specify height and width in pixels.
  • relheight, relwidth: Specify height and width as a floating number between 0.0 and 1.0.
  • relx, rely: Specify horizontal and vertical offset as a floating number between 0.0 and 1.0.
  • x, y: Specify horizontal and vertical offset in pixels.

 

Example: place() Method in Tkinter Python 3
from tkinter import *

gui = Tk()

l1 = Label(gui, text = "Firstname")
l1.place(x = 10, y = 10)
e1 = Entry(gui, bd = 5)
e1.place(x = 70, y = 10)

l2 = Label(gui, text = "Lastname")
l2.place(x = 10, y = 50)
e2 = Entry(gui, bd = 5)
e2.place(x = 70, y = 50)

btn = Button(gui, text = "Click here!")
btn.place(x = 100, y = 100)
gui.geometry("210x150+10+10")
gui.mainloop()

 

 
Output:

 

mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *