Python - GUI - Tkinter


Tkinter is the standard GUI library for Python. Tk was developed as a GUI extension for the Tcl scripting language by John Ousterhout. The first release was in 1991. Both Tk and Tkinter are available on most Unix platforms, Windows and Macintosh systems. Tkinter provides a powerful object-oriented interface to the Tk GUI toolkit. Tkinter consists of a number of modules.The Tk interface is provided by a binary extension module named _tkinter. Creating a GUI application using Tkinter is fast and easy. Before we go into a simple example, lets take a quick look at the following:

Tkinter widgets:Tkinter provides various controls used in a GUI application. These controls are commonly called widgets;
  • menu
  • menubutton
  • button
  • checkbutton
  • progressbar
  • radiobutton
  • scale
  • canvas
  • combobox
  • label
  • labelframe
  • entry
  • frame
  • listbox
  • message
  • notebook
  • panedwindow
  • tk_optionMenu

  • Tkinter geometry managers:All Tkinter widgets have access to specific geometry management methods, which have the purpose of organizing widgets throughout the parent widget area;
  • pack - It packs widgets into a cavity.
  • place - It positions widgets at absolute locations.
  • grid - It arranges widgets in a grid.

  • Tkinter top-level windows:The Toplevel widget is displayed in a separate, top-level window;
  • tk_dialog - creates a modal dialog and waits for a response.
  • tk_getOpenFile - pops up a dialog box for the user to select a file to open.
  • tk_getSaveFile - pops up a dialog box for the user to select a file to save.
  • tk_chooseColor - pops up a dialog box for the user to select a color.
  • tk_chooseDirectory - pops up a dialog box for the user to select a directory.
  • tk_messageBox - pops up a message window and waits for a user response.
  • tk_popup - posts a popup menu.
  • toplevel - creates and manipulates toplevel widgets.


  • Try this simple example:

    import tkinter as tk
    master = tk.Tk()
    #your widgets goes here...
    master.mainloop()

    Final display:

    Comments

    Popular posts from this blog

    Azure SQL, Cloud Migration and Modernization

    Python - GUI - Tkinter(Bar & Pie Chart)

    Bringing Kubernetes to Windows Server apps(Google Cloud Platform)