Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: ButtonBox, styles, GraphicsGenerator.nb

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25026] Re: ButtonBox, styles, GraphicsGenerator.nb
  • From: "P.J. Hinton" <paulh at wolfram.com>
  • Date: Fri, 1 Sep 2000 21:57:32 -0400 (EDT)
  • Organization: Wolfram Research, Inc.
  • References: <8hfgjn$i54@smc.vnet.net> <8onegm$ojj@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On 1 Sep 2000, Peter Dickof wrote:

> In the GraphicsGenerator notebook available on MathSource, an example
> is given of  button which generates a plot in a standalone notebook
> window. The notebook then says
> 
> "Earlier in this notebook, we took some pains in separating
> task-specific material from things that might be reusable.  Gathering
> the set of reusable ButtonBox objects together, we can place them in a
> StyleData cell in a style sheet so that you can speed the creation of
> similar buttons.  Here is an example of what a cell style might look
> like
> 
> Cell[StyleData["PutGraphicInWindow"], StyleMenuListing -> None, 
>     ButtonStyleMenuListing -> Automatic, 
>     ButtonBoxOptions -> {ButtonEvaluator -> "Automatic", 
>         ButtonFunction :> (NotebookPut[
>                 Notebook[{Cell[GraphicsData["PostScript",
> DisplayString[#2]], 
>                       ShowCellBracket -> False]}, WindowSize -> {300,
> 250},  
>                   WindowElements -> {}, WindowTitle -> "Graphics"]] &
> ), 
>         Active -> True}] // CellPrint
> 
> 
> The sample notebook never actually resuses thuis, and I can't figure
> it out. 
> 
> I copied this to a notebook which I put in the /
> ../configuration/FrontEnds/StyleSheets directory. It still does not
> appear in the Input/Create Button or Input/Edit button menu. Isn't it
> supposed to?

Did you make sure that your working notebook was configured to use the
style sheet that contains the "PutGraphicInWindow" style prototype?  The
front end's Edit -> Create Button menu lists only those button styles
which are found in the notebook's current style sheet.  It does not search
other style sheet notebooks.

> Also I try to include it directly in a notebook and then use it in
> command
> 
>    ButtonBox[ToExpression["Plot3D[Sin[x] Cos[y],{x,0,2Pi}, {y,0,2Pi}, 
> 		DisplayFunction->Identity],
> 	ButtonStyle->PutGraphicInWindow]
> 
> and nothing happens
>
> What am I doing wrong?

You have complicated the problem here in three ways:

1) You have specified the button's contents to be something that will
evaluate to something else.  You should use an inert label instead.

2) Your ToExpression[] is not completely terminated.  You need to close
off the string argument and supply a closing square bracket.

3) The value of ButtonStyle should be a string, not a symbol.

Here is how you might reformulate your button structure.

    ButtonBox[
      "Plot3D[Sin[x] Cos[y],{x,0,2Pi}, {y,0,2Pi}]",
      ButtonEvaluator->Automatic,
      ButtonData:>ToExpression[ 
        "Plot3D[Sin[x] Cos[y],{x,0,2Pi}, {y,0,2Pi}, DisplayFunction -> \
Identity]"],
      Active->True,
      ButtonStyle->"PutGraphicInWindow"
    ]

-- 
P.J. Hinton
User Interface Programmer                         paulh at wolfram.com
Wolfram Research, Inc.
Disclaimer: Opinions expressed herein are those of the author alone.



  • Prev by Date: Re: functions, packages, and contexts
  • Next by Date: Re: More troubles coming from indexed variables
  • Previous by thread: ButtonBox, styles, GraphicsGenerator.nb
  • Next by thread: Re: Re: opening files