Python - SPLessons

Python Tkinter Programming

Home > Lesson > Chapter 17
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Python Tkinter Programming

Python Tkinter Programming

shape Description

Before going to this chapter user need to know about Graphical User Interface. The GUI , is a sort of UI that permits clients to collaborate with electronic gadgets through graphical symbols and visual markers, for example, optional documentation, rather than content based UIs, wrote summon names or content route. GUIs were acquainted in response with the apparent soak expectation to absorb information of order line interfaces (CLIs), which oblige orders to be written on a PC console. The actions in a GUI are usually performed through direct manipulation of the graphical elements.[4] Beyond computers, GUIs are used in many handheld mobile devices such as MP3 players, portable media players, gaming devices, smartphones and smaller household, office and industrial controls. The term GUI tends not to be applied to other lower-display resolution types of interfaces, such as video games , or not including flat screens.

Tkinter Programming

shape Description

Tkinter is a Python authoritative to the Tk GUI toolbox. Tkinter was composed by Fredrik Lundh. Tkinter is incorporated with the standard Microsoft Windows and Mac OS X introduce of Python. The name Tkinter originates from Tk interface. It is the standard Python interface to the Tk GUI toolkit,and is Python's accepted standard GUI. Likewise with most other cutting edge Tk ties, Tkinter is actualized as a Python wrapper around an entire Tcl mediator implanted in the Python translator. Tkinter calls are converted into Tcl summons which are encouraged to this implanted mediator, along these lines making it conceivable to blend Python and Tcl in a solitary application. The following is an example. [c] import Tkinter top = Tkinter.Tk() # Code to add widgets will go here... top.mainloop()[/c] Python 2.7, Python 3.1 join the "themed Tk" usefulness of Tk 8.5 . This permits Tk gadgets to be effortlessly themed to resemble the local desktop environment in which the application is running, along these lines tending to a long-standing feedback of Tk. Now compile the code result will be as follows.

Tkinter Widgets

shape Description

The following are the various list of widgets. The following is an example for the button widget. [c]import Tkinter import tkMessageBox top = Tkinter.Tk() def helloCallBack(): tkMessageBox.showinfo( "Hello Python", "Hello World") B = Tkinter.Button(top, text ="Splessons", command = helloCallBack) B.pack() top.mainloop()[/c] Now compile the code result will be as follows.

Summary

shape Key Points

  • The invoke() is the method to call the button callback.
  • The developer can add multiple buttons on the window.
  • The slider widget will be provided by the scale operator.