Here are a few examples which you would like to look at when you start learning about the TK widgets. These are the list of examples which will guide you in your learning. The examples here were written by someone learning basic widget approaches by looking at the Pmw megawidgets examples given in the tar file in the. documents section This page is still being expanded, so check back for more examples.
Tkinter, provides python applications with an easy to use program user interface. Tkinter supports a collection of widgets that support most application needs,it comprises of a number of components,is a low level interface to the Tk libraries and is linked into python. the following are the basic Tkinter widgets.
The first example of the Tkinter widget is the 'Toplevel' widget. The Toplevel widget provides a separate container for other widgets ,such as a frame.
for detailed description of the widget see Toplevel
the snapshot of the widget is shown here
The next basic widget is the frame widget.A frame is a container widget. The frame can have a border and a background, and is used to group other widgets when creating an application or dialog layout.
Frame
the snapshot of the widget is
This is a simple Tk example to create a button. ButtonTk
the snapshot of the window is
Entryfield This example illustrates the entry widget along with the button widgets.
The snapshot of the window is
The above examples are individual representations of Tk widgets. The last example entryfield uses buttons and entry widget. let us now see an example which uses a frame, button and entry widget. when we write large programs, it is usually a good idea to wrap the code up in one or more classes. for detailed documentation see SampleTkexample
the snapshot of the window is
The next example will show you how to access files. Tkinter has a functions askopenfilename, LoadFileDialog which aid in this. In this example i used askopenfilename.
filebrowser
the snapshot of the window is
This is an example to create menubar using Tkinter widgets Menu and Menubutton.
Menubar the snapshot is
Textarea This is an example of scrolled text area.
the snapshot of the window is
In this example i used the filebrowser, menubar and textarea to design an interface. the user can use the menubar options to open a file,whenever he clicks on open option in the file menubutton the filebrowser opens. Interface
the snap shots of the window are
Pmw , are composite mega widgets written entirely in Python using Tkinter widgets as base classes.
The following is a simple example to create a button. Creating a simple BUTTON This image is the snapshot of the window produced by the above example.
The next example illustrates the use of ButtonBox widget.The ButtonBox widget provides a convinient way to implement a number of buttons and is usually used to provide a command area within an application. BUTTONBOX The snapshot of the window produced by the above example is shown below:
This example shows how to add functionality to the buttons created, it is also possible to define a default button, the button which is executed when a return key is pressed. Adding functionality to the buttons
Scrolled list box: This example shows how to create a scrolled list box. Scrolledlistbox The snapshot of the window produced by the example is shown below
This example is to create a scrolled text box. we can also import and export files into and out of text box.
Scrolledtextbox The snapshot of the window is shown below
This is an example of selectiondialog widget which allows a user to select an item from the scrolled list in response to a question. it shows a compact way of creating a button to launch the dialog.
selectiondialog The snapshots of the window is shown below
The following is an example of a simple menubar widget for containing menus.it uses methods to add menu buttons and menus to the menu bar and for adding menu items to the menus.A button can be created to launch the menubar similar to the one in the above example.
menubar The snapshots of the window is shown below
This is an example of an advanced menubar , it is an extension of the above example where menus and menuitems are added, here we also use balloon widget and messagebar widget to display text for the menu buttons and menu items. this balloon has an associated messagebar where the help text will be displayed.
advancedmenubar The snapshot of the window is shown below: