Hello dear readers! welcome back to another section of our tutorial on Python. In this tutorial post, we are going to be discussing about the Python Tkinter place() Method.
Python Tkinter place() geometry manager oraganizes the widgets by placing them in a specific position in the parent widget.
Python Tkinter place() geometry manager oraganizes the widgets by placing them in a specific position in the parent widget.
Syntax
The following below is the syntax for this method -
widget.place( place_options )
Options
Below is the list of possible options -
- anchor - This is the exact spot of the widget that other options refer to: may be N, E, S, W, NE, NW, SE, or SW, compass directions which indicates the corners and sides of the widget; default is NW (the upper left corner of the widget).
- bordermode - INSIDE (the default) to indicate that other options refer to the parent's inside (and ignoring the parent's border); else OUTSIDE.
- height, weight - Height and width in pixels.
- relheight, relwidth - The height and width as a float between 0.0 and 1.0, as a fraction of the height and width of the parent widget.
- relx, rely - Horizontal and the vertical offset as a float between 0.0 and 1.0 as a fraction of the height and width of the parent widget.
- x, y - Horizontal and vertical offset in pixels.
RECOMMENDED: Python Tkinter pack() Geometry Widget
Example
Try the following example below -
from Tkinter import * import tkMessageBox import Tkinter top = Tkinter.Tk() def helloCallBack(): tkMessageBox.showinfo( "Hello Python", "Hello World") B = Tkinter.Button(top, text ="Hello", command = helloCallBack) B.pack() B.place(bordermode=OUTSIDE, height=100, width=100) top.mainloop()
Output
When the above code is executed, it will produce the following result -
RECOMMENDED: Python Tkinter grid() Geometry Manager
Alright guys! This is where we are rounding up for this tutorial post. In our next tutorial, we are going to be discussing about the Python Extension Programming with C.
Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.
Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.