![]() In Tkinter, there are two ways to register an event with a widget.įirst way is by using the bind() method and the second way is by using the command parameter in the widget constructor. Let's add the most commonly used widgets.Īn event should be registered with one or more GUI widgets in the application. The above code will create the following window:Īll Tkinter widget classes are inherited from the Widget class. The event loop will terminate as and when the close button on the title bar is clicked. We shall discuss event handling later in this tutorial. The application's functionality involves executing appropriate callback functions in response to a particular type of event. The event could be text entered in a text field, a selection made from the dropdown or radio button, single/double click actions of mouse, etc. The application is now constantly waiting for any event generated on the elements in it. The application object then enters an event listening loop by calling the mainloop() method. The geometry() method defines the width, height and coordinates of the top left corner of the frame as below (all values are in pixels): window.geometry("widthxheight+XPOS+YPOS") This will create a top-level window (root) having a frame with a title bar, control box with the minimize and close buttons, and a client area to hold other widgets. After importing, setup the application object by calling the Tk() function. The following code demonstrates the steps in creating a UI.įirst of all, import the TKinter module. GUI elements and their functionality are defined in the Tkinter module. This tutorial explains the use of Tkinter in developing GUI-based Python programs. WxPython is a Python wrapper around WxWidgets, another cross-platform graphics library. PyGTK is the module that ports Python to another popular GUI widget toolkit called GTK. PyQtis, the Python interface to Qt, is a very popular cross-platform GUI framework. This module is bundled with standard distributions of Python for all platforms. Tkinter is the Python port for Tcl-Tk GUI toolkit developed by Fredrik Lundh. ![]() ![]() Many of them have been ported to Python in the form of importable modules. These graphics libraries are generally written in C/C++. A graphics library is a software toolkit having a collection of classes that define a functionality of various GUI elements. Such applications are developed using one of various graphics libraries available. These applications can receive inputs through mouse clicks and can enable the user to choose from alternatives with the help of radio buttons, dropdown lists, and other GUI elements (or widgets). They have a more ergonomic graphical user interface (GUI) thanks to high speed processors and powerful graphics hardware. User interaction is not restricted to console-based I/O. Modern computer applications are user-friendly. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |