- First, click in the upper right hand square of the frame grid. The frame
bars should turn red. Go to the edit menu and select delete (Your delete key
may also work, depending on how you have set up your environment). The
internal frames should go away, and we should have one big empty frame. We
need 5 vertical areas, so we will create them.
- Move your cursor over the top or bottom edge of the frame. That edge should
turn red. Click your button to create a new area. Repeat until you have
five horizontal areas (three for scales, one for the entry frame and one
for the canvas).
- On the left side of the screen you will see a list of widgets. Go to the scale
widget, and click and drag it to the top frame. A scale should appear in
the top frame. Now we must edit the scale's attributes. You can do this
by double clicking on the scale in the frame. Click Dismiss when you are
done.
- Scroll through all the options available. There are a few we are interested
in modifying. To modify a command click in the entry and modify the field.
Pressing return will make the changes. There are also graphical ways of
changing the common attributes of a widget. For the scale we want to set these
fields
command: newColor
item_name: redscale
label: Red
length: 7c
orient: h
to: 255
- Now we want to create 2 other scales for Green and Red. You can either
repeat the process again, or you can click on the red scale so its frame
is highlighted red, go to the edit menu, and select copy. Then click the
empty frame you want to copy the widget into so it is highlighted red, and
go to the edit menu and select paste. You will still have to modify the
widget, but not as much (only the item_name, and label).
- Next we will throw a canvas into the bottom frame. Just click and drag it
there. Double click on it to edit it's options
height: 1.5c
item_name: colorwin
width: 7c
- Now we need to put a frame in for the entry boxes. Unfortunately this is
one area where SpecTcl has some bugs. When you insert a frame you can't
really resize it to make it smaller. Well you can, but it's not visible on
the screen so we will just ignore it. Insert the frame by dragging the frame
into the last remaining area. Double click on it to bring up it's options
height: 1.5c
item_name: entryframe
width: 7c
- Next create 4 vertical frame areas, much like we did with the horizontal ones
of the top level frame.
- Then drag an entry widget into the left most frame.
Edit the options for the entry and set these fields
item_name: redentry
textvariable: redvar
width: 7
- Now either create or copy similar entries for green and blue and modify their
item_name, textvariable, and width. Be warned, if you copy, be sure to get
the inner frame highlighted, or else it will copy the entry over the frame!
- Now get a button widget and drag it into the right most frame of the entry
frame. Double click to set its options
command: setColor
item_name: setbutton
text: Set
- Once you are done with that, you've created the layout of your application.
Finally we have to write the Tcl code for the callbacks. Select the Edit
menu and click on edit code. A window will pop up for you to write the Tcl
code for your callbacks. Because of the way Spec handles the geometry the
the same code from before will not work. It's just a slight modification.
The entry widgets are not children of the entryframe.
proc newColor value {
set color [format #%02x%02x%02x [.redscale get] [.greenscale get] [.bluescale get]]
.colorwin config -background $color
}
proc setColor {} {
.redscale set [.redentry get]
.greenscale set [.greenentry get]
.bluescale set [.blueentry get]
}
- After that, you can go to the Command menu item and select Build and test
and it will spawn your application for you. You can test it as before. Once
you are satisfied, you can select the File menu, and save, then quit.
This creates two files in your directory
untitled.ui
untitled.ui.tcl
The *.ui file is for SpecTcl, the *.tcl file is your application. To use it
Just create a file called 'testapp' with this in it
source untitled.ui.tcl
untitled_ui .
- Afterwards just issue
blt_wish -f testapp
Augh...enough! This is making my head spin...I want to quit, but not before
I see where I can get more