tkinter standard library in python
In python there is the tkinter standard library that is an official interface for the TK GUI tool kit. This library can then be used as a way to create graphical front ends for python projects. The library works by providing a number of widgets that can be used to create various components in a window such as buttons, menus, a canvas, and text. With these widgets it is possible to make a basic yet functional graphical user interface for a python project.
At the time of this writing I do not yet have much experience working with tkinter, and I also only have about a month of experience so far with python as a whole. So for now this will be just a few basic examples of the standard library. In time if I do start creating and maintaining some real projects with python this will likely be how I will want to create a GUI for the project.
1 - Some very basic tkinter getting started examples
So I need to start somewhere when it comes to using tkinter and python, so In this section I will be going over just a few very basic getting started types examples of tkinter. The basic process is to of course import the tkinter library, and then create a root parent with the main Tk class. Off of the main root parent I can then use the min size method to set a small starting size for the window. Then it is just a matter of creating at least one widget to attach to the root parent, and then done call the main loop method of the root parent. So this will be just a few examples of that basic process to create very simple getting started examples that just make use of one widget.
1.1 - Basic Hello world example
First thing is first, I just want to start with a very basic hello world style example of this library. That is just a simple hello world example of the tkinter library where I am just displaying the text hello world in a window. For this there is the Label widget which would be a good starting example of using widgets to create an interface.
1.2 - A basic count example
Another idea of a basic example would be to create an example where I have a button, and each time I click the button a value goes up by one.
2 - Inspect the tkinter library
The tkinter library is a little complex, there are a great number of widgets to work with, as well as a whole bunch of additional methods in the root name space of the module itself. There are a number of decent resources online to read up more on all the little features of the libraray, but another options is to just start inspecting the module itself.
The process of inspecting a module can involve the use of the inspect library to just take a look at what is going on with tkinter, or standard library, or well written library in general actualy. There are methods in the inspect library than can be used to filter members iof a library by class, and function, as well as just taking a look at everything. Also many of the functions and classes have what are called doc strings, or on other worlds documnatiaion strings that should explain what each function and class does.
2.1 - inspect all the memebers of the tkinter module
A good starting point might be to take a look at everything first.
2.2 - inspect just the tkinter.Tk class
A major part of tkinter seems to be the main Tk Class, so It might be a good idea to take a closes look at that one. In addition to passing and instance of the class as something to get all members of I can also used the inspect.members method as a second argument for the inspect.getmembers methods to just get the methods of a Tk Class instance.
3 - The canvas widget
3.1 - A basic Arc example
For starters how about just doing an arc in a canvas widget, to do so there is a create_arc method that can be used off of an instance of the main tk.Canvas class. So the basic process is to just create a canvas widget first, when doing so I can set things like the background color, and the size of the canvas. Once I have a canvas widget I can then draw to it with one of many draw methods such as create_arc.
4 - The text widget
One idea that I have in mind for a real python project is to make a half way decent text editor. That is the strange thing about text editors, I can never seem to find one that has all the features that I want. If I do take the time to make my own text editor, and do so with python, that I will want to use the text widget of this library for the text area. Making a real text editor will take some time, but a basic example of the text widget should not eat up to much time.
5 - Conclusion
This is if for now when it comes to tkinter, I will need to get some more time to work on a project or two with python where I will want a GUI for the project in order to come up with some better examples. When doing so this is the library that I am going to want to use for sure as it seems decent enough for such a task.
Some ideas for real projects involve the creation of some kind of utility program that will help me with creating and editing some kind of content. There is starting out with a basic text editor maybe, but it would be nice to get into some other kind of tool.