Video, create a goi with Python. In this video, we will learn about TK inter library in Python and learn to use take inter widgets to create graphical user interface applications. Finally, we will learn to use the geometry managers available for TK inter. So what is a July graphical user interface is nothing but an application that helps you to interact with the computers visually. They are used to perform different tasks in desktops, laptops and other electronic devices. Python has a plethora of libraries and these four stands out mainly when it comes to G VI.
They are as follows kV Python Qt w x Python TK inter. Among all of these, TK inter is preferred by a lot of learners and developers just because of how simple and easy it is. I'm sure you will have the same opinion in a while as well. Take into is actually an inbuilt Python module used to create simple goi apps. It is the most commonly used module for Java apps in Python. You don't need to worry about the installation of the TK inter module as it comes with Python default.
Consider the following diagram it shows how an application actually executes in take into the start out when we first input the take into model followed by that we create the main window. It is in this window that we are performing operations and displaying visuals and basically everything. Later we add the widgets and lastly, we enter the main event loop. If you have noticed, there are two key words here that you might not know at this point. They are widgets. Main Event loop.
An event loop is basically telling the code to keep displaying the window until we manually close it. It runs in an infinite loop in the back end, check out the following HelloWorld Java code for better clarity. As you can see, we are importing the tick into package and defining a window. Lastly, we have a label. A label is nothing but what output needs to be shown on the window. In this case, as you can already see, it has hello world.
Now let's run this code in the ID. You can now see your first goi app. The next question we need to ask is What are widgets? widgets are something like elements in HTML. You will find different types of widgets to the different types of elements in take into let's see a brief introduction to all of these widgets in Take into check out this diagram for the list of the major used take inter widgets. Canvas.
Canvas is used to draw shapes in your Goi. button. Button widget is used to place the buttons in take into check button. Check button is used to create a check buttons in your application. entry. Entry widget is used to create input fields in the goi frame.
Frame as used as containers and take inter Label Label is used to create a single languages like text, images, etc. Menu menu is used to create menus in the G UI. Let us walk through all of these widgets individually for better understanding. As we don't have time to go through an example program for each of the widgets. I will be showing a code snippet and output of that side by side The syntax for each of the widgets are self explanatory. Please feel free to pause the videos on each widget to have a good look.
I have also provided the sample syntax in the resources section. One, label widget. To button widget. Three check button widget. For entry widget. Five, combo box widget.
Six. Radio Button widget. Seven. Scroll text widget, eight. message box widget and nine spin box widget. just creating a widget does not necessarily mean that it will appear on the screen.
To get the widget to appear, we need to tell the parent widget where to put it. To do that, we use one of take interest tree geometry managers. A geometry manager is some code that runs on the back end of taking. We simply choose which geometry manager we want to use and give it some parameters to work with. The three geometry manages our grid, pack and place. The Grid Manager places widgets in a table format, with rows and columns.
It will award overlapping widgets will resize rows and columns as necessary to fit the widgets. The package is often the easiest geometry manager to use, as it just puts widgets in a single row or column. It packs the widgets by putting them side by side or top Bottom. The place geometry manager offers the most control, but can be the most difficult to use. It allows you to specify the absolute or relative positions of the widgets in a window. As we have covered the basics of G UI development, we asked you to go through the resource to learn more and practice with different examples.
Goi creation is a vast topic, and it can't be covered in a single video. Now I will give you an activity upgrade your command line simple calculator you built earlier with Java capabilities. The final goi simple calculator application should look like this. If you are not able to successfully make this calculator, you can refer to the code I have provided in the resources section. Summary In this video, we have covered the following what does take into how to work with take into methods. Develop simple GIS, create a simple goi calculator section summary.
In this section, we have covered the following basics of Python programming, typecasting and loops in Python, conditional branching and functions in Python modules in Python, create a goi with Python. In the next section, we will start working with hardware interfacing in the Raspberry Pi four