moreButtons extension to Tkinter

tnb2d@henson.cs.virginia.edu
Tue, 28 Jun 94 11:01:02 EDT

The docs in the latest Tkinter are a little vague about an
extension that has been made to the module. Now, if you want them,
there are two new Button types, the Stud button and the Tri button.
Here are two blurbs about these new buttons types:

triButton -
Simple triangular button built to be exactly like the arrows
at the ends of a scrollbar. The size and the direction of the
point can be specified as well as a command to execute upon
activation (just like a button except there is no text or
bitmap only a triangle).

studButton -
This is a "kitchen sink" button. While standard Tk buttons
may have EITHER a bitmap or text and this text may only be a
single line, a studButton may have both a bitmap and text.
The text may span multiple lines--word wrapping very much like
a message widget. Also, it may have a "tag" which is
displayed right justified within the button and vertically
aligned with the top of the text. This tag may either be a
text string (possibly in a font different from the text's
font) or a bitmap. Aside from the much more complicated image
on the top of a studButton, however, it functions exactly like
a normal button. When pressed, it sinks in with a pleasant 3D
appearance, etc.

There are simple Python wrappers for these built into the Tkinter.py
file, but you have to do a little work if you want to be able to use
them. First, you must get the c files from

ftp.isu.edu:pub/moreButtons

Now I don't go the Extensions route when it comes to building in
tkintermodule, I just slip it into my Modules directory and make the
appropriate entry into my Modules/Setup file. This just seems more
straight-forward, especially for me since I don't use any other
extensions. So once you have the moreButtons distribution just take
the studButton.c & triButton.c files and place them in your Modules
directory, along with tkintermodule.c and appinit.c from the latest
Tkinter distribution. All you have to do now is futz with the Setup
entry, mine looks like this:

# Comment the next line out if you don't want to define module "tkinter".
tkinter tkintermodule.o appinit.o studButton.o triButton.o -DWITH_APPINIT -DWITH_MOREBUTTONS -I$(TCL_DIR)/include -I$(TCL_DIR)/tk3.6 -L$(TCL_DIR)/lib -ltk -ltcl -lX11

Note that -DWITH_APPINIT makes sure tkintermodule uses the appinit
that will create the two new button commands, and -DWITH_MOREBUTTONS
makes sure that appinit does in fact create those commands. If you
build tkintermodule in using the Extensions method, hopefully between
this and the TKinter docs you can figure out the appropriate way to
get this working. Right now, as I said, the Python wrappers are
pretty primitive, but I hope to imporve them soon and pass the
improvements on to Steen so they can be included in future Tkinter
releases.
As you can see this was a fairly painless way to Extend Tk and
by doing so extend Tkinter. Hopefully this will encourage anyone else
out there who knows of cool Tk widgets to get them into Tkinter as
well. Happy interfacing,

-------> Tommy.

"Python, like capitalism and love, eventually co-opts all who
seek to change it <grin>." -- Tim Peters