MathGroup Archive 2009

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

Search the Archive

Re: OpenerView, multiple sub cells and Notebook1Write...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104229] Re: OpenerView, multiple sub cells and Notebook1Write...
  • From: Albert Retey <awnl at gmx-topmail.de>
  • Date: Sat, 24 Oct 2009 02:40:43 -0400 (EDT)
  • References: <hbr51k$rca$1@smc.vnet.net>

Hi,

> My ultimate goal here is an interactive report that will be played with
> Player Pro (and potentially webMathematica in the future). From a document
> design perspective, I was thinking about having my sections split using the
> OpenerView widget with content embedded under the (layered) opener widgets.

> I'm having two problems and I'm not sure if they are bugs, lack of
> capability or lack of understanding on my part.
> 
> 1 - In a normal notebook, I'm attempting to create an OpenerView with
> multiple-cells as the second argument.
> 
> I'm able to generate sample multi-cell content WITHOUT OpenerView using the
> following:
> 
> NotebookWrite[InputNotebook[], CellGroupData[
>   {
>    Cell["test", "Subtitle"],
>    ToBoxes@ListPlot[Table[i, {i, 1, 5}]]
>    }
>   ]
>  ]
> 
> 
> However, when I try to embed this WITH OpenerView, the "header" gets printed
> but the CellGroupData comes out as uninterpreted text:
> 
> 
> OpenerView[{"header", CellGroupData[
>    {
>     Cell["test", "Subtitle"],
>     ToBoxes@ListPlot[Table[i, {i, 1, 5}]]
>     }
>    ]}]
> 
>
> Q: How can multi-cell output be  embedded in OpenerView and properly
> interpreted?

Have you good reasons to not use the usual way to structure a document
(notebook)? If you want the Opener to open the sections, you can make
Mathematica show one with the option ShowGroupOpener, e.g.:

NotebookWrite[InputNotebook[], CellGroupData[{
   Cell["test", "Subtitle", ShowGroupOpener -> True],
   ToBoxes@ListPlot[Table[i, {i, 1, 5}]]
   }]]

If for whatever reason you really want to embed complete Cells within an
Opener, maybe the use of DocumentNotebook is one of the simplest
options, e.g.:

NotebookWrite[InputNotebook[],
 ToBoxes[OpenerView[{
    "header",
    DocumentNotebook[{
      TextCell["test", "Subtitle"],
      ExpressionCell[ListPlot[Table[i, {i, 1, 5}]]]
      }]
    },
   True
   ]]
 ]

> 2 - When OpenerView is sent to a document via NotebookWrite, the header
> portion acts different than in a normal notebook.
> 
> 
> OpenerView[{"Text Label", a + b + c}]
> 
> 
> This generates an opener with 'a+b+c' as the content and 'Text Label' (no
> printed quotes) as the header.
> 
> 
> NotebookWrite[InputNotebook[], ToBoxes@OpenerView[{"Text Label", a + b +
> c}]]
> 
> 
> This generates an opener with 'a+b+c' as the content and "Text Label" (WITH
> printed quotes) as the header.
> 
> 
> I looks like when using NotebookWrite, the Cell that embeds all of this is
> set to "Input" instead of "Output" (from show expression)

Well this seems to be the default, if you want something else, you can
explicitly wrap the corresponding Cell around your expression (I just
have seen that you have figured that one out yourself):

NotebookWrite[InputNotebook[],
 Cell[BoxData[ToBoxes@OpenerView[{"Text Label", a + b + c}, True]],
  "Output"]]

alternatively you can use Style to change the appearance of the header
independently of the style definition of the Cell-Style, e.g.:

NotebookWrite[InputNotebook[], ToBoxes@OpenerView[{
    Style["Text Label", ShowStringCharacters -> False], a + b + c},
   True]]


hth,

albert


  • Prev by Date: Re: which values of m satisfies the inequality
  • Next by Date: Re: FromAdjacencyMatrix / FromAdjacencyLists - broken?
  • Previous by thread: OpenerView, multiple sub cells and Notebook1Write...
  • Next by thread: Re: OpenerView, multiple sub cells and Notebook1Write...