basic widgets are common widgets available in almost all tk applications. the list of available basic widgets is given below −
| sr.no. | widgets & description |
|---|---|
| 1 |
label
widget for displaying single line of text. |
| 2 |
button
widget that is clickable and triggers an action. |
| 3 |
entry
widget used to accept a single line of text as input. |
| 4 |
message
widget for displaying multiple lines of text. |
| 5 |
text
widget for displaying and optionally edit multiple lines of text. |
| 6 |
toplevel
widget used to create a frame that is a new top level window. |
a simple tk example is shown below using basic widgets −
#!/usr/bin/wish grid [label .mylabel -text "label widget" -textvariable labeltext] grid [text .mytext -width 20 -height 5] .mytext insert 1.0 "text\nwidget\n" grid [entry .myentry -text "entry widget"] grid [message .mymessage -background red -foreground white -text "message\nwidget"] grid [button .mybutton1 -text "button" -command "set labeltext clicked"]
when we run the above program, we will get the following output −