

In this example we are using geometry method to assig size to our window in Tkinter after that we are attaching button widget on it.īutton = Button(parent, text = 'Click me !!', bg='yellow', fg = 'blue', height = 5, width = 10) Lets us discuss the examples of Tkinter Window Size.


while creating the object we used no parameter constructor and call this methods.

Here is no constructor because these are itself a method which is called on the Tkinter object. This is very important to call otherwise we will not be able to see the window. This method is also called on the Tkinter object. The first parameter is width and the second we are assigning is height here.Īt last, we are calling mainloop () method, this method is used to initialize the window in Tkinter. Here we are calling this method on the Tkinter object because it can be access by its object only. minsize (): This method is also used to size our window.Here we are assigning 100×100 as the size of the window. Indirectly it takes height and width in a different format we can say. It only takes one parameter and this will be a string value separated by ‘x’ operator. geometry (): We can call this method by using Tkinter object ‘parent’.We will discuss this in detail see below On this parent object, we can call both this method. To import this module we use import keyword followed by the library name.Īfter this we will create Tkinter object this will be called a parent object here. First, we need to import the Tkinter module into our progam as we know this is used to create the GUI in python. In the above example, we are sizing our window by using both the mentioned methods. Now we will see one example to understand it better and how they actually work internally see below But in order to use both this methods, we need to import the Tkinter module into our program because we can call this by using Tkinter object only.īoth these methods takes height and width as a parameter directly or indirectly. How does Window Size work in Tkinter?Īs now we know that we can provide size to our window by using geometry method and midsize method in Tkinter. In this way we can use this in our program while creating window in Tkinter. Let’s see one practice syntax for better understanding see below Inside this method we are giving two parameters here named as width and height as follows. This is the another method we can use to size our window.
