[Date Index]
[Thread Index]
[Author Index]
Re: Test for dialog existence
*To*: mathgroup at smc.vnet.net
*Subject*: [mg112731] Re: Test for dialog existence
*From*: Albert Retey <awnl at gmx-topmail.de>
*Date*: Tue, 28 Sep 2010 06:50:36 -0400 (EDT)
*References*: <i7seje$pl6$1@smc.vnet.net>
Hi,
> Hi. Can anyone suggest how to test for the existence of a dialog?
>
> In the example below a dialog is created containing a plot which can
> be modified. However it seems to be difficult to test whether the
> dialog has been closed.
>
> This creates the dialog:
>
> BeginPackage["TestExample`TestDialog`"];
> CreateTestDialog::usage = "CreateTestDialog[] creates a test dialog";
> Begin["`Private`"];
> CreateTestDialog[] :=
> Module[{}, n = 4;
> CreateDialog[
> plot = Dynamic[
> ParametricPlot[{Sin[t], Sin[n t]}, {t, 0, 2 Pi}, Ticks -> None,
> ImageSize -> 100]]]];
> End[];
> EndPackage[];
>
> CreateTestDialog[];
>
>
> And the plot can be modified by various means:
>
> TestExample`TestDialog`Private`n = 8;
>
> TestExample`TestDialog`Private`n = 2;
>
>
> But how can I tell if the dialog has been closed? The dynamic plot
> object still shows as existing afterwards:
>
> NameQ["TestExample`TestDialog`Private`plot"]
Here is one possibility, instead of the WindowTitle you could also use a
certain value in the TaggingRules where you could "hide" the additional
information which would identify the dialog, but it would mean some
extra bits of code:
BeginPackage["TestExample`TestDialog`"];
CreateTestDialog::usage="CreateTestDialog[] creates a test dialog";
Begin["`Private`"];
CreateTestDialog[]:=Module[{},n=4;
CreateDialog[plot=Dynamic[ParametricPlot[{Sin[t],Sin[n t]},{t,0,2
Pi},Ticks->None,ImageSize->100]],WindowTitle->"TestDialog"]
];
End[];
EndPackage[];
CreateTestDialog[];
(*this will check whether there is an open dialog: *)
Length[Select[Notebooks[],CurrentValue[#,WindowTitle]==="TestDialog"&]]>0
on the other hand, I have a feeling that you might implement something
too complicated for what you really want to achieve. Maybe you would get
some useful tips if you try to give us a bigger picture of what you are
trying to do...
hth,
albert
Prev by Date:
**Re: Manipulating Solution List from NDSolve**
Next by Date:
**Re: How to make a contour lines on a Plot3D surface?**
Previous by thread:
**Test for dialog existence**
Next by thread:
**Re: Test for dialog existence**
| |