MathGroup Archive 1998

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

Search the Archive

Re: first usage of a button

  • To: mathgroup at
  • Subject: [mg13713] Re: first usage of a button
  • From: "P.J. Hinton" <paulh>
  • Date: Wed, 19 Aug 1998 01:38:07 -0400
  • Organization: "Wolfram Research, Inc."
  • References: <6r0v5n$>
  • Sender: owner-wri-mathgroup at

On 14 Aug 1998, jmthomas wrote:

> In order to standardize the use of notebooks for non-specialist people,
> I have built the following button, that sets the working directory to
> the notebook directory. (Other versions can also read a initialization
> file).
> Cell[BoxData[
>     FormBox[
>       ButtonBox["SetWorkingDirectory",
> tonFunction:>SetDirectory[ 
>             DirectoryName[ 
>               Module[ {pathName}, 
>                 ToFileName[ 
>                   ReplaceAll[ "FileName", 
>                     NotebookInformation[ 
>                       ButtonNotebook[ ]]]]]]],
>         ButtonEvaluator->Automatic,
>         Active->True,
>         ButtonStyle->None,
>         ButtonNote->"init"], Null]], "Input"]
> The button works fine but in one case: when Mathematica has just been
> started (with an autoloaded kernel) and the notebook just been opened,
> I get a message (from the FrontEnd): "Evaluation Nonstandard Form:
> Warning: You are giving input which is not InputForm or StandardForm,
> etc. " and people can choose between "Cancel" and "Evaluate" Choosing
> "Evaluate" performs a correct task, but for first-time users my
> notebook does not look like a "click and go" notebook! The message also
> suggests to use "convert", which leads to a disaster, ruining the
> button itself.
> What can I do to have a clean button?

Is there a reason that you chose to embed the ButtonBox in a FormBox
with Null format type?  I suspect that this is what's flagging the
front end warning message dialog box.  If you want to get a nice
textual appearance, you can use a StyleBox.

    StyleBox["Set Working Directory", FontFamily -> "Times", 
              Module[ {pathName}, 
                  ReplaceAll[ "FileName", 
                      ButtonNotebook[ ]]]]]]],
        ButtonNote->"init"]// DisplayForm

You may want to add some sort of protection against the possibility that
NotebookInformation[] does not return a "FileName" replacement rule
(e.g. if the notebook is untitled).  You could induce some mysterious
beeps if a user clicks on this button in a newly-created notebook.

P.J. Hinton
Mathematica Programming Group           paulh at Wolfram
Research, Inc.        
Disclaimer: Opinions expressed herein are those of the author alone.

  • Prev by Date: Re: Problems with packages
  • Next by Date: Re: Label Display in 2-D Plots?
  • Previous by thread: first usage of a button
  • Next by thread: Running 3.0 remotely