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: [mg104209] Re: OpenerView, multiple sub cells and Notebook1Write...
  • From: David Reiss <dbreiss at gmail.com>
  • Date: Sat, 24 Oct 2009 02:36:51 -0400 (EDT)
  • References: <hbr51k$rca$1@smc.vnet.net>

Hi Jason,

I have a couple of general comments and then some specific ones.   I
don't think I answer all of your questions, but perhaps this will help
with part of your project.

One is that I think that it is best to program documents using the
higher level document programming language, things like TextCell,
ExpressoinCell, CellGroup, and so on rather than their lower level Box
langualge counterparts.  At times though, as you know, one has to go
back and forth between the two, and this is done using things like
ToBoxes, StripOnInput, and so on. to go from the document programming
language language to the Box langualg, and one also uses RawBoxes to
go in the other direction (i.e. doing things like DocumentNotebook
[{RawBoxes[Cell["this is text","Text"]]}]  to place a Cell expressoin
in a documenting language expression where a TextCell might go).  From
my experiments though it seems that the low level construct
CellGroupData is not handled well with RawBoxes.  So something like




OpenerView[{"header", RawBoxes[Cell[
    CellGroupData[
     {Cell["test", "Subtitle"],
      Cell[BoxData[ToBoxes[ListPlot[Table[i, {i, 1, 5}]]]],
"Graphics"]}]]]}]


generates an error message (and an ammusing one at that: "An error of
unspecified nature occurred.").

But with that said, I think that OpenerView is intended for showing
two complete objects, one hidden when the opener is closed.  So the
latter would need to be an expression that, on its own would be fully
displayed for example in the documenting language.  One approach would
be to use a Column as in


OpenerView[
{TextCell["header","Title"],
Column[{
TextCell["test","Subtitle"],
TextCell[ListPlot[Table[i,{i,1,5}]],"Graphics"]},
Alignment->Left]}
]

But a completely different approach--if you are wanting document level
cells rather than ones within a Column--would be not to use
OpenerView, but to use cells directly with the appropriate ones having
the option ShowGroupOpener->True as in this:

CreateWindow@DocumentNotebook[
CellGroup[
{TextCell["header","Title",ShowGroupOpener->True],
TextCell["test","Subtitle"],
TextCell[ListPlot[Table[i,{i,1,5}]],"Graphics"]},
1
]
]


I hope this helps.

Best,
David
http://scientificarts.com/worklife


P.S.  Sometimes, to remove explicit quotes in various outputs one
needs to use ShowStringCharacters->False, or to explicitly wrap things
in Text.


On Oct 22, 10:39 pm, Jason Ledbetter <jasonbr... at gmail.com> wrote:
> Folk,
> Sorry for yet-another-UI-programming question.... (Perhaps I should start
> trying to use wolfram's support for these types of things?)
>
> My ultimate goal here is an interactive report that will be played with
> Player Pro (and potentially webMathematica in the future). From a documen=
t
> design perspective, I was thinking about having my sections split using t=
he
> OpenerView widget with content embedded under the (layered) opener widget=
s.
>
> 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 t=
he
> 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 prin=
ted
> 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?
>
> 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" (WI=
TH
> printed quotes) as the header.
>
> I looks like when using NotebookWrite, the Cell that embeds all of this i=
s
> set to "Input" instead of "Output" (from show expression)
>
> Q: How can I get this to be an output cell?
>
> A: looks like I might have my answer for this
> one: NotebookWrite[InputNotebook[],
>
>  Cell[BoxData[ToBoxes@OpenerView[{"Text Label", a + b + c}]], "Output"]=
]
>
> Any other suggestions on how to approach this would be appreciated howeve=
r.
>
> TIA,
>
> -jbl



  • Prev by Date: Re: FromAdjacencyMatrix / FromAdjacencyLists - broken?
  • Next by Date: Re: Timer event
  • Previous by thread: Re: OpenerView, multiple sub cells and Notebook1Write...
  • Next by thread: FromAdjacencyMatrix / FromAdjacencyLists - broken? Workaround?