From: Hannes Kessler on 23 Jan 2010 07:36 Hello, I have a rather complex dynamic notebook GUI with several TabView, Button, InputField and other objects that does not save reliably a variable "jobs" between Mathematica sessions. The basic structure of the GUI is a follows: DynamicModule[{jobs = {}, ...}, ..., TabView[{..., "Edit jobs" -> Dynamic[jobDefinitionPanel [jobs_, ...]], ...}], Initialization :> AbortProtect[ Needs["context1`"]; Needs["context2`"]; ...]] where jobDefinitionPanel has the attribute HoldAll and contains a button for adding an object Job["name"->...,"item 1"->..., "item 2"- >..., ...] to the list of jobs jobDefinitionPanel[jobs_, ...] := DynamicModule[{..}, ...; Column[{ Dynamic[Length[jobs]], ..., Button["Add job", jobs = Append[jobs, makeJob[ ...]], Method -> "Queued"] }]]; makeJob[ ...] returns _Job objects of the form given above: makeJob[name_String, item1_, item2_, ...] := Job["name" -> name, "item 1" -> item1, "item 2" -> item2, ...] In a given Mathematica session everything works fine: After adding several job objects, Dynamic[Length[jobs]] shows the correct length of the jobs list. Exporting the list with CellPrint[Cell[BoxData[ToBoxes [jobs]]]] from the GUI to its notebook shows the jobs list {__Jobs} with all _Job elements. But saving, closing and reopening the notebook always gives a shorter jobs list, sometimes it is even empty. The _Job objects are rather large due to one item which is a 15x15 matrix of elements None or FA[...]. The problem does not occur if I do not add this item to Job-objects. It looks as if a size limitation exists for saving dynamic objects in the notebook cell containing the dynamic expressions. Does anybody have an idea what the reason might be and how to fix this problem? My current workaround is to additionally save the jobs list to a file jobs.m Button["Add job", jobs = savedJobs =..; Save["jobs.m", savedJobs], Method -> "Queued"] and to load this file during initialization DynamicModule[{jobs = {}, ...}, ..., Initialization :> AbortProtect[ Needs["context1`"]; Needs["context2`"]; Get["jobs.m"]; jobs = savedJobs; ...]] Thanks in advance and best regards, Hannes Kessler
|
Pages: 1 Prev: The formula of Abraham Moivre Next: problem with inverse laplace transform |