The Mathematica Journal
Download This Issue
Feature Articles
Graphics Gallery
Tricks of the Trade
In and Out
The Mathematica Programmer
New Products
New Publications
News Bulletins
Editor's Pick
Write Us
About the Journal
Staff and Contributors
Back Issues

Buttons with Graphics

Dale Horton

A new feature for Mathematica 4 is the ability to put any Cell expression on the face of a button. This means that anything you can create in a cell (such as graphics) can appear on your buttons.



To put this graph on the button, you first need to know how to generate the Cell expression for the graph. This is done with the DisplayString command.


This string is placed inside a Cell expression. The first argument of Cell indicates that the cell is PostScript GraphicsData. The second argument is the cell style Graphics. Additional arguments are Cell options.


This cell is embedded in another cell which creates the button. The first argument is the ButtonBox. The first argument of the ButtonBox is the graphics cell. The rest are options of the button. The second argument, again, is the cell style of the button cell. Additional arguments are any options of the button cell, including the action of the button (e.g., myfunction).


Now that we have all the parts, we can write the cell to the front end with DisplayForm, NotebookWrite, or CellPrint.


We then can apply this function to any graphics. (DisplayFunction->Identity suppresses the normally generated graphics.)


The same can be done by using the DisplayFunction option when generating graphics.


Clicking on either of the above buttons will create a new notebook with an animated moebius strip.

Converted by Mathematica      October 8, 1999

[Next Page]