In this tutorial, we will learn how to create a tabbed widget with python GUI and Tkinter package.

The Tkinter module (“Tk interface”) is the standard Python interface to the Tk GUI toolkit. Both Tk and Tkinter are available on most Unix platforms, as well as on Windows systems. (Tk itself is not part of Python; it is maintained at ActiveState.) Tkinter package is shipped with Python as a standard package, so we don’t need to install anything to use it.

Creating Tabbed Widget With Python

Save this code and run the file you should see a tabular window as below on your screen.

Explanation

  • First, we are importing the Tkinter modules. Next, in the object window we are initializing the widget.
  • Then using the geometry('350x200') the method we have assigned a default value for the size of the widget. This line sets the window width to 350 pixels and the height to 200 pixels.
  • Later we have a tab control, the Notebook method manages collections of windows and displays one at a time, basically used for creating tabular widgets.
  • Below that, we have declared two tabs, and assigned some text and padding for styling.
  • In the end, we have window.mainloop() this function calls the endless loop of the window, so the window will wait for any user interaction till we close it.
Tabbed Widget With Python

The article was published on November 7, 2020 @ 9:44 AM

Leave a Comment