In this TKinter Tutorial we want to learn how to create TKinter Window, tkinter is a GUI Development library for Python Programming Language, using TKinter you can create nice and beautiful GUI (Graphical User Interface) applications, it is a built in library and you don’t need to install tkinter.
Now let’s create our first basic window in TKinter.
1 2 3 4 5 6 7 8 9 10 11 12 |
import tkinter as tk win = tk.Tk() win.title("TKinter First Window") win.minsize(500,400) win.wm_iconbitmap("myicon.ico") win.mainloop() |
So in the above code first we have imported our TKinter library, and we want to give the name of tk for the tkinter.
If you want to give title for your TKinter window than you can use this code.
1 |
win.title("TKinter First Window") |
This is used for giving a minimum size for the TKinter Window.
1 |
win.minsize(500,400) |
When you are going to develop a GUI Application than you need to give an icon for the window, you can use this code for giving icon, make sure that you have added an icon to your working directory.
1 |
win.wm_iconbitmap("myicon.ico") |
And finally this is our window loop.
1 |
win.mainloop() |
Run the complete code and this will be the result.