Creating a widget
The basic method for creating a widget is the same regardless of the widget being created. The differences are in the properties of the widget and if any action can be assigned to it. In the following chapters, we will investigate specific widgets and their properties in depth, but before we reach this point, I would like to introduce you to the button widget and some basic features.
How to do it…
In the following example, we will create a button widget with some basic properties and a single action. Enter the following commands:
1 % button .b text "Exit" command exit 2 % pack .b
At this point, your window should look like the following:
How it works…
The first line instructs the wish shell to create a button named b
, which is a child of the parent window identified by the '.' character. This button will have a text label containing the word Exit
and it will execute the exit
command when clicked. Now click on the button that you have created. You will see that you have exited...