Re: Listbox type progress display?
- To: mathgroup at smc.vnet.net
- Subject: [mg119732] Re: Listbox type progress display?
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Sun, 19 Jun 2011 07:27:39 -0400 (EDT)
- References: <isd0vg$1pt$1@smc.vnet.net> <201106051103.HAA12141@smc.vnet.net> <itj67d$k3q$1@smc.vnet.net>
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
- References:
- Re: Listbox type progress display?
- From: Albert Retey <awnl@gmx-topmail.de>
- Re: Listbox type progress display?