Re: Dynamic GUI problems
- To: mathgroup at smc.vnet.net
- Subject: [mg89471] Re: Dynamic GUI problems
- From: m.r at inbox.ru
- Date: Tue, 10 Jun 2008 03:42:27 -0400 (EDT)
- References: <g2dbji$9ks$1@smc.vnet.net> <g2ij26$roa$1@smc.vnet.net>
On Jun 9, 1:36 am, m... at inbox.ru wrote:
> On Jun 7, 1:58 am, zac <replicator... at gmail.com> wrote:
>
>
>
> > Dear Group,
>
> > building a GUI is highly non-intuitive for me, although I almost felt
> > I understand the behaviour of dynamic interactivity.
>
> > I. Problem - Master swich does not control semi-independent sub-
> > switches
> > This is the classic "set all/none switch" situation, with allowing the
> > sub-switches to be set by the user individually. Switching the
> > checkbox works, but hitting the buttons won't update checkboxes.
>
> > master = False;
> > def = {False, True};
>
> > {Button["All", master = All], Button["None", master = None]}
> > {Dynamic[master], Dynamic[sub1], Dynamic[sub2]}
> > {sub1, sub2} =
> > Table[DynamicModule[{i = i},
> > Switch[master, All, True, None, False, _, def[[i]]]], {i, 2}];
> > {Checkbox[Dynamic[sub1]], Checkbox[Dynamic[sub2]]}
>
> > II. Problem - Checkbox in label of TabView does not work
>
> > TabView[{
> > Checkbox[Dynamic[x]] -> Dynamic[x],
> > "..." -> ""
> > }]
>
> > Any ideas how to solve them?
>
> > Istvan Zachar
>
> You can define the button control functions to reset all the switches;
> at least I don't see how it can be done simpler:
>
> {Button["All", sub1 = sub2 = True],
> Button["None", sub1 = sub2 = False]}
> Checkbox /@ {Dynamic@ sub1, Dynamic@ sub2}
>
> I think what happens with the checkbox inside the tab is that a mouse
> click is intercepted by the tab and there's no way to pass it down to
> the checkbox. You can have the checkbox argument update in sync with
> the TabView control though:
>
> TabView[{Checkbox[Dynamic[x == 1]] -> 1,
> Checkbox[Dynamic[x == 2]] -> 2}, Dynamic[x]]
>
> Maxim Rytin
> m... at inbox.ru
My suggestion probably doesn't count as having the Checkbox 'work', so
you may need to add a custom tracking function to the TabView control:
y = {False, False};
TabView[{Checkbox[Dynamic@ y[[1]]] -> {1, Dynamic@ y},
Checkbox[Dynamic@ y[[2]]] -> {2, Dynamic@ y}},
Dynamic[x, (If[x == #, y[[#]] = !y[[#]]]; x = #)&]]
The first click selects the tab, the subsequent clicks on the same tab
toggle the checkbox.
Maxim Rytin
m.r at inbox.ru