Re: Front End Programming question

*To*: mathgroup at smc.vnet.net*Subject*: [mg54908] Re: Front End Programming question*From*: David Bailey <dave at Remove_Thisdbailey.co.uk>*Date*: Sun, 6 Mar 2005 00:55:58 -0500 (EST)*References*: <d09dm6$d7k$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

János wrote: > Hi, > > I am looking at John M. Novak presentation he did at the 1999 > Mathematica Developers's Conference, titled Front End Programming. > Based upon his notebook, I ask input questions the following way. > First I define two functions, askForInput and dialogForInput. > > askForInput[inputLabel_: > ""] := Module[{thenb, > result}, > thenb = dialogForInput[ > inputLabel]; > While[Options[thenb, > Visible] === > {Visible -> True}, > Do[Null, {250}]]; > NotebookFind[thenb, > "TheInput", All, > CellTags]; result = > NotebookRead[thenb]; > NotebookClose[thenb]; > MakeExpression[result[[1, > 1]]]] > > > dialogForInput[ > inputLabel_] := > NotebookPut[Notebook[ > {Cell[BoxData[StringJoin[ > inputLabel, " "]], > "Input", CellFrame -> > True, Evaluatable -> > False, > ShowCellTags -> True, > CellTags -> > "TheInput", > CellMargins -> > {{10, 10}, {4, 4}}, > Deletable -> False], > Cell[BoxData[ > ButtonBox["OK", > RuleDelayed[Butto\ > nFunction, > SetOptions[Butt\ > onNotebook[], > Rule[Visible, > False]]], > Rule[ButtonFrame, > "DialogBox"]] > ], "Input", > Editable -> False, > Active -> True, > TextAlignment -> > Center, > CellMargins -> > {{10, 10}, {20, > 2}}]}, > ShowCellBracket -> > False, WindowFrame -> > "MovableModalDialog", > WindowFloating -> False, > WindowSize -> {300, > 150}, > WindowFrameElements -> > {}, WindowElements -> > { > "VerticalScrollBar"}]]\ > ; > > > Then if I want to ask a question I call askForInput and grab the value > with the Nest: > > primerLength = ReleaseHold[ > askForInput[ > "Length of a Primer:"]]; > primerLength = Nest[Last, > primerLength, > Depth[primerLength] - 1]; > > If I want to ask another question I do the same thing with a different > question into another variable, like: > > averagePrimerDistance = > ReleaseHold[askForInput[ > "Average Primer \ > Distance:"]]; > averagePrimerDistance = > Nest[Last, > averagePrimerDistance, > Depth[ > averagePrimerDistance] \ > - 1]; > > Works great, - one question at a time. My question is, how can I > present multiple questions into one dialog and sort out the answers > after the values are typed in and the <OK> button is clicked. I tried > a number of different ways, - making inputLabel a List, creating a > table of Cells with different CellTags, getting the results back into > an array, played with GUIKit, etc... - but did not find the right one. > All failed at the NotebookFind[thenb, "TheInput", All, CellTags]; > command and its variants. Conceptually the question looks easy, but > the devil is - always - in the implementation :) > > Thanks ahead, > > János > > > ---------------------------------------------- > Trying to argue with a politician is like lifting up the head of a > corpse. > (S. Lem: His Master Voice) > Hello, I found GUIKit to be very comprehensive, but extremely hard to use! As a result I wrote a package (called the Super Widget Package) which is freely available at my site. This package uses GUIKit, but lets you build a typical GUI in an almost trivial way, and everything works in a 'traditional' Mathematica way - for example, you specify colours with RGBColor notation, not as Widget["class:java.awt.Color", InitialArguments -> {255,0,0}] From what you describe, it sounds ideal for what you want to do. Feel free to email me about it. David Bailey dbaileyconsultancy.co.uk