Tcl/Tk Tutorial on Tk Mega Widgets

mega widgets include many complex widgets which is often required in some large scale tk applications. the list of available mega widgets are as shown below −

sr.no. widget & description
1 dialog

widget for displaying dialog boxes.

2 spinbox

widget that allows users to choose numbers.

3 combobox

widget that combines an entry with a list of choices available to the use.

4 notebook

tabbed widget that helps to switch between one of several pages, using an index tab.

5 progressbar

widget to provide visual feedback to the progress of a long operation like file upload.

6 treeview

widget to display and allow browsing through a hierarchy of items more in form of tree.

7 scrollbar

scrolling widgets without a text or canvas widgets.

8 scale

scale widget to choose a numeric value through sliders.

a simple tk example is shown below using some mega widgets.

#!/usr/bin/wish

ttk::treeview .tree -columns "creator year" -displaycolumns "year creator" 
.tree heading creator -text "creator" -anchor center
.tree heading year -text "year" -anchor center
pack .tree
.tree insert {} end -id languages -text "languages"
.tree insert languages end -text c -values [list "dennis ritchie" "1990"]
proc scaleme {mywidget scalevalue} {
   $mywidget configure -length $scalevalue
} 
pack [scale .s2  -from 100.0 -to 200.0 -length 100 -background yellow -borderwidth 5
   -font{helvetica -18 bold} -foreground red -width 40 -relief ridge -orien horizontal
   -variable a -command "scaleme .s2" ]
pack [ttk::progressbar .p1 -orient horizontal -length 200 -mode indeterminate -value 90]
pack [ttk::progressbar .p2 -orient horizontal -length 200 -mode determinate -variable a
   -maximum 75 -value 20]

when we run the above program, we will get the following output −

mega widget example