In this article, you will learn the most confusing concepts about Tkinter windows, widgets, and frames. You will also learn the difference between these components, that is necessary to build any GUI Application using Tkinter and Python.
Introduction to Tkinter Windows
Every Tkinter application must have a window, and this window is also called a root window. By using Tkinter you can create that root window by using TK() class. You can say that a Tkinter root window is a top-level window that contains all of the child windows or widgets that you are going to use in your application, such as (Frames, Widgets like button, label, Listbox, radio button, etc).
Tkinter window act as a container, where you will put all of your widgets (Frames, Button, Label, Listbox, RadioButton, etc).
Create Window or Root Window in Tkinter
Introduction to Tkinter Frames
In Tkinter, Frames are nothing but just a widget. You can use a Frame in your application as a container, which will contain all the other widgets like buttons, Listbox, radio buttons, etc. Unlike windows, you can create multiple frames in the same window. But in the case of Tkinter windows, you can not create a window inside a window. In Tkinter, each window performs separately. An instance of the frame can not exists without an instance of TK() mean window. And if you don't create an instance of TK, it will be created automatically for you.
Tkinter frames act as a container, which will contain all of the other widgets like button, label, Listbox, etc. Remember Tkinter frames cannot act as a standalone window. Frames make it easy to organize your widgets into logical spaces or groups.
Create Frames in Tkinter
Introduction to Tkinter Widgets
To make GUI (Graphical User Interface) in any application widgets are building blocks. You can create widgets with or without containers. There is some associated behavior attached with Tkinter Widgets. For example, a mouse or keyboard button is pressed. These associated behaviors generate events and these events or (GUI Responses) are called Callbacks. Because to handle these events they call a function.
0 Comments