Let’s make the introductions 🙂 Tkinter is a package that allows a programmer to build a GUI interface, which then can be opened on a computer screen by a user. There are many different types of GUI apps, but examples include a calculator or a text editor that opens when you click it.
Tkinter would be the most commonly used GUI package in Python, due to its simplicity, but PySimpleGUI, PYQt or PySide are other alternatives. Ensure you research these before using to make sure they suitable for your needs.
Why use Tkinter?
Relatively simple and easy to learn, upskilling is quick.
A great introduction to the concepts and ideas for building GUI apps, you will get a good grounding in the techniques and approaches needed.
Very well documented, so a programmer should be able to find the answer to anything specific they need to understand.
Now we are introduced, let’s see how to utilise it:
Install Python as usual, and make sure that Tkinter is working and you have the correct version. Note that import tkinter is for version 3.x, before that use import Tkinter
Please note that you will see in places when using Python code, that capitalization is important. This will sometimes puzzle you as to why some of your code does not work, usually, the interpreter should flag it for you.
While it is correct to put a capital at the start of a line, the programming language will ignore written English convention. An example is as follows:
list = ['a','b','c']
NameError: name 'Print' is not defined
list = ['a','b','c']
gives ['a', 'b', 'c']
When saving your python script DO NOT call it tkinter.py as I did, the import statement will not work. Call it something like tkinter_test.py, see red arrow below.
At the start of the video below the code will look like this. the first six lines are the creation of the Tkinter screen its size and any buttons that will appear on it.
Note that all code should appear betwee line two and line six, so that the screen output works and looks correctly.
Added to this code in the following video:
Button – which will open our YouTube channel
A clickable link – Which will bring you to our Home Page
Privacy & Cookies Policy
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.