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

MathGroup Archive 2009

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

Search the Archive

Re: Problem using a dialog and dynamic

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97840] Re: Problem using a dialog and dynamic
  • From: ragfield <ragfield at gmail.com>
  • Date: Mon, 23 Mar 2009 04:04:32 -0500 (EST)
  • References: <gq54sh$7s5$1@smc.vnet.net>

On Mar 22, 5:45 am, "Paul Ellsmore" <paul.ellsm... at nanion.co.uk>
wrote:
> Hi,
>
> The following code should show a button
>
> and a text field. When I click the button, i should get
>
> a system dialog allowing me to select a folder, and the
>
> folder's file and pathname should then be displayed in
>
> the text field.
>
> Hi,
>
> The following code should show a button and a text field. When I click th=
e
> button, i should get a system dialog allowing me to select a folder, and =
the
> folder's file and pathname should then be displayed in the text field.
>
> Panel[Grid[{{Button["Select/Change Project
> Directory",sourcedir=SystemDialogInput["Directory","C:\\"]]},{Column[{"=
Curr e
> nt Project Directory:",InputField[Dynamic[sourcedir],String]}]}}]]
>
> Unfortunately, the performance is erratic!
>
> If I click the button, then select a folder of the C drive, say C:\first,
> and click "open", the textfield display C:\first as expected. But if I th=
en
> click the button again, and select, say, folder off the C:\first\second a=
nd
> click "open", the textfield does not change, nor does it for any subseque=
nt
> clicks. However, if I select the desktop, it works as expected, and if I
> select the C: drive again it also works.
>
> To summarise, if i want to change the folder selection, I have to select =
the
> C: drive once, then click again and select the subfolder I want, and if I
> want to change the subfolder, I have to select the c: drive again, before=
 I
> can select the new subfolder.
>
> Is this a bug, or am I doing something stupid? I am using V7 on Windows
> Vista Home Premium.


Check out the
"Possible Issues" section of the documentation page for Button.  You
need to use Method->
"Queued" if your button function doesn't return immediately.  By
default (Method->
"Preemptive") the Mathematica front end blocks/waits for the button
function to finish.  Your button function is asking the front end to
do something but the front end won't do anything until the function
returns... but the function won't return until the front end does
something.  You can see the problem here.

If your button function displays UI, or in general if it doesn't
return very fast, use Method->"Queued".

-Rob


  • Prev by Date: Re: How do I DistributeDefinitions inside a function?
  • Next by Date: Re: Problem using a dialog and dynamic
  • Previous by thread: Problem using a dialog and dynamic
  • Next by thread: Re: Problem using a dialog and dynamic