geometry in python gui tkinter
geometry in python gui tkinter

Hey Guys! Today we will be learning the geometry code in tkinter (also called Python GUI)

Let’s begin….

Process of executing the python geometry code through tkinter

  1. Import tkinter
  2. Set a value for the interface
  3. Set a title(optional)
  4. Now, write the code of geometry

How to write geometry in Python GUI through Tkinter?

Import tkinter

import tkinter

Here, you have imported tkinter through this code…..

Set a value for the interface

win = tkinter.Tk()

Now, you need to set the value for the interface. Here the value for interface is win.

Why this process? This process is done to copy the properties in tkinter.

Set a title(optional)

win.title('TITLE')

What will this do? It will set the title of the interface.

TITLE is a title here

Write the code of geometry

Now, we are going to set geometry in python gui (tkinter)…..

win.geometry('300x100')

Here, win is the value for the interface.

People Also Visit: Adsense Issue Scanner

In English language, it says “Set the geometrical size of win to the width of 300 and height of 100.

Let’s analyze the whole code….

 import tkinter
 win = tkinter.Tk()
 win.title('TITLE')
 win.geometry('300x100')
 win.mainloop()

People Also Read: How to make simple browser for Android using WebView

Let’s translate the whole code in English…

  • import tkinter: Hey, Python! Import the inbuilt function of GUI (tkinter).
  • win = tkinter.Tk(): Now, set the value of interface in win
  • win.title('TITLE'): It’s an order, set the title of the interface into TITLE
  • win.geometry('300x100'): Right now, set the size to 300 of width and 100 of height.
  • win.mainloop(): Okay!!! Now, That’s it.
The result of the code - Interface
The result of the code – Interface

This is the whole process of geometry in python gui tkinter

WooW!! Comment your confusion……

Last modified: June 27, 2019

Author

Comments

Write a Reply or Comment

Your email address will not be published.