Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: DynamicModule Wormholes

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99396] Re: [mg99371] DynamicModule Wormholes
  • From: John Fultz <jfultz at wolfram.com>
  • Date: Tue, 5 May 2009 05:38:46 -0400 (EDT)
  • Reply-to: jfultz at wolfram.com

There is no documented way to get the associated integer, and the integer value 
is only valid per session and for as long as DynamicModule exists.  I.e., even 
closing and re-opening the notebook, or cutting and pasting the cell with the 
DynamicModule would change it.

I can think of two ways to get this information.  One is to create a temporary 
wormhole using InheritScope (say, to a newly created notebook with 
Visible->False), read it down (e.g. with NotebookGet) and pull the number from 
there.  The second is to use the completely undocumented and experimental (which 
means we reserve the right to change it in the future!) function shown here...

DynamicModule[{a}, 
 Dynamic[FE`Evaluate[FEPrivate`ParentDynamicModule[]]]]

But all of this begs the question...why couldn't you have just used InheritScope 
in the first place?  It is documented, fully supported, does not depend upon
implementational details which might change, and so will continue to be 
supported in future versions of Mathematica.

I can't think of an instance where you couldn't use InheritScope.  The most
complex case I can conceive of is where you want to spawn a new wormholed 
DynamicModule from outside the existing DynamicModule...but in that case, you 
can use a Dynamic trigger to just cause that DynamicModule to which you want to 
connect to do the work for you.  E.g., something like...


Column[{
  DynamicModule[{a = 5},
   Dynamic[
    If[trigger === True, 
     DynamicModule[{}, CreatePalette[Button["+", a++]]];
     trigger = False];
    a], Initialization -> (trigger = False)],
  Button["create palette", trigger = True]
  }]


Sincerely,
 
John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.



On Mon, 4 May 2009 05:59:56 -0400 (EDT), Michael wrote:
> Can anybody give me some hints on how to create a DynamicModule wormhole?
>
> The documentation gets me interested, then ends by saying:
> "By using DynamicModuleParent explicitly, it is possible to link up
> arbitrary existing DynamicModules, but doing so is tricky, and beyond
> the scope of this document."
>
> Apparently it is beyond the scope of actually doing at all, because I
> haven't been able to find anything else about it anywhere!  I would
> think even if it was tricky, the trickiness could be encapsulated
> somehow?
>
> I did a bit of experimenting (basically by opening the palette example
> and examining the notebook) and found that DynamicModuleParent[]
> appears to expect an integer argument, perhaps a handle of some kind?
> However when I tried to replicate the wormhole using the same value
> for the working wormhole I did not have success.
>
> --Michael





  • Prev by Date: Re: atoi equivalents?
  • Next by Date: Re: Diffusion Model using NDSolve - Advice needed
  • Previous by thread: DynamicModule Wormholes
  • Next by thread: Re: Save to RTF crashes Mathematica on 32 and 64 bit