Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #3186

Re: Listbox type progress display?

From Albert Retey <awnl@gmx-topmail.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Listbox type progress display?
Date 2011-06-19 11:27 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <itkmfr$po9$1@smc.vnet.net> (permalink)
References <isd0vg$1pt$1@smc.vnet.net> <201106051103.HAA12141@smc.vnet.net> <itj67d$k3q$1@smc.vnet.net>

Show all headers | View raw


Hi,
>
> I appreciate the idea.  Works great with text.  I am having problems
> writing a Grid[] object to the other notebook.  The functions I am
> using are based on your example:
>
> (* One time setup *)
> nbControl=CreateWindow[DocumentNotebook[{CellGroup[{TextCell["CalibrationControl
> Execution:   "<>  DateString[],"Section"]}]}]];
> SelectionMove[nbControl,After,Notebook];
>
> (* functions to add lines and sections *)
> notebookAddLine[x_]:=(NotebookWrite[nbControl,Cell[x,"Text"],All];
> SelectionMove[nbControl,After,Notebook];)
> notebookAddSection[x_]:=(NotebookWrite[nbControl,Cell[x,"Section"],All];
>
>SelectionMove[nbControl,After,Notebook];)
>
> If I create a local object: mList = {{1, 2}, {3, 4}}; mItem =
> Grid[mList, Frame ->  All]
>
> I get the grid box as one would imagine.  I have tried every
> variation of NotebookWrite[] I can see, but am unable to write
> non-text to external notebook.
>
> I.e. NotebookWrite[nbControl, mItem, All] Console Message: An unknown
> box name (Grid) was sent as the BoxForm for the expression. Check the
> format rules for the expression.

NotebookWrite is a relatively low level function, it has been there even 
before version 6, which means before all the dynamic stuff to create 
graphical user interface. Thus it expects either a string or boxes for 
2d content. It is fortunately almost trivial to create these boxes, so 
this should work (and it will work with everything: Graphics, 
Graphics3D, Manipulate ...):

NotebookWrite[nbControl,ToBoxes[mItem], All]

> I found another command (as I wrote this) that is very interesting
> and works. Paste[nbControl, mList]
>
> Even images work Paste[nbControl,Rasterize[mItem]]
>
> I'm sure you likely know about this.  Just thought I'd offer it in
> case anyone didn't.

in fact I've never seen Paste, presumably because I knew ToBoxes and 
never had the need for it. Paste basically seems to be the high level 
version of NotebookWrite. Good to know, it will make some code more 
compact and clean. It would be interesting to know whether it really is 
equivalent to NotebookWrite[#1,ToBoxes[#2]]& ...

cheers,

albert

Back to comp.soft-sys.math.mathematica | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Listbox type progress display? "McHale, Paul" <Paul.McHale@excelitas.com> - 2011-06-04 10:21 +0000
  Re: Listbox type progress display? Albert Retey <awnl@gmx-topmail.de> - 2011-06-05 11:03 +0000
  Re: Listbox type progress display? "McHale, Paul" <Paul.McHale@excelitas.com> - 2011-06-18 21:44 +0000
    Re: Listbox type progress display? Albert Retey <awnl@gmx-topmail.de> - 2011-06-19 11:27 +0000

csiph-web