Purpose
-
This Chapter introduces creating objects interactively in Tk canvas widget.
You will need
-
At this point it is assumed that the reader has read through the previous chapters. Scripts for creating pulldown menus, scrollbars etc. are made use of
in this section but are described in detail in Chapter 3.
Dish to Serve Up
-
Create a simple drawing editor.
Recipe
-
The script for this example (draw.tcl) is in the Cookbook's code directory, under ch5 subdirectory. You can place all the script for this example in a single Tcl/Tk script file.
Remember to set the path to our wish binary properly.
-
create a window with a top menubar, a panel for some buttons and a scrollable canvas.
-
add some buttons and an entry widget for string input in the panel; put bitmapped images rather than text labels for the buttons.
-
create bindings in canvas for mouse clicks and motion so that drawing primitives could be drawn in it.
- Acknowledgement
-
The bitmaps used are under the subdirectory bitmaps under ~cookbook/code/ch5. The bitmaps are part of the public domain xfig program.