Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6013 > unrolled thread
| Started by | Don <donabc@comcast.net> |
|---|---|
| First post | 2011-10-29 11:27 +0000 |
| Last post | 2011-10-30 09:31 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
PopupMenu Problems Don <donabc@comcast.net> - 2011-10-29 11:27 +0000
Re: PopupMenu Problems A Retey <awnl@gmx-topmail.de> - 2011-10-30 09:21 +0000
Re: PopupMenu Problems Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-10-30 09:31 +0000
| From | Don <donabc@comcast.net> |
|---|---|
| Date | 2011-10-29 11:27 +0000 |
| Subject | PopupMenu Problems |
| Message-ID | <j8gnvh$5ig$1@smc.vnet.net> |
Below is the code for a simple PopupMenu
The purpose is to present the user with a PopupMenu that
gives two options: "Linear" or "NonLinear".
There are two problems with this code:
(1) The word "Linear" (the default) is suppose to show up in
the window next to the right of the word " Function:".
Right now, it's just left as a blank. It was thought
that setting the inital value of the variable "fnc1" to Linear
would solve that problem.
(2) After the user makes a choice by clicking on the down arrow and
clicking on an option (Linear or NonLinear) the
code should then "fall through" and Print "999" to show
it is positioned to determine which option the user chose by
executing the following Which function, but this never happens.
The act of choosing an option by the user should result in executing the Which function and subsequent functions.
How can this code be modified to fix those two problems?
Thank you in advance.
Don
Remove[master$FE];
master$FE[] := Module[{},
Interpretation[{fnc1 = Linear},
backgrndClr = ColorData["Aquamarine", 0.15];
Panel[Grid[
{
{Style["PopupMenu", 36, Bold], SpanFromLeft
},
{
Style["Function:", Bold, 22],
PopupMenu[Dynamic[fnc1], {"Linear",
"NonLinear"}, AutoAction -> True
] ,
SpanFromLeft
}
},
ItemStyle -> Directive[FontSize -> 26, Bold],
Spacings -> {2, 2},
Dividers -> {None, {2 ->
Directive[Black, AbsoluteThickness[Large]]}}
], ImageSize -> {300, 250}, Background -> backgrndClr],
Print[" Begin Which Function - 999 "];
fnc1String = ToString[fnc1];
Which[
fnc1String == "Linear",
linear$FE[],
fnc1String == "NonLinear",
nonLinear$FE[]
];(* End Which *)
Print["777"];
](* Interpretation *)
(* Print["888"];*)
](* End Module master$FE *)
[toc] | [next] | [standalone]
| From | A Retey <awnl@gmx-topmail.de> |
|---|---|
| Date | 2011-10-30 09:21 +0000 |
| Message-ID | <j8j4u6$etj$1@smc.vnet.net> |
| In reply to | #6013 |
Am 29.10.2011 13:27, schrieb Don:
> Below is the code for a simple PopupMenu
>
> The purpose is to present the user with a PopupMenu that
> gives two options: "Linear" or "NonLinear".
>
> There are two problems with this code:
>
> (1) The word "Linear" (the default) is suppose to show up in
> the window next to the right of the word " Function:".
> Right now, it's just left as a blank. It was thought
> that setting the inital value of the variable "fnc1" to Linear
> would solve that problem.
>
> (2) After the user makes a choice by clicking on the down arrow and
> clicking on an option (Linear or NonLinear) the
> code should then "fall through" and Print "999" to show
> it is positioned to determine which option the user chose by
> executing the following Which function, but this never happens.
> The act of choosing an option by the user should result in executing the Which function and subsequent functions.
>
> How can this code be modified to fix those two problems?
> Thank you in advance.
>
Honestly I'm not sure what exactly you try to achieve, your description
is quite different from what one could guess from the code...
here is a minimal solution which does what you seem to describe:
linear$FE[] := Print["run linear FE"]
nonLinear$FE[] := Print["run nonlinear FE"]
master$FE[] := DynamicModule[{fnc1 = "Linear"},
ActionMenu[
Dynamic[fnc1], {
"Linear" :> linear$FE[],
"NonLinear" :> nonLinear$FE[]
}
]
]
I think you should have a look at the various possibilities to construct
a gui that mathematica provides and choose the one most appropriate for
your task. Then I would always start with concentrating on the
functionality and only when that is done start with the exact
formatting. If the above is what you want you can start adding features,
e.g. the AutoAction -> True option, or more important the Method ->
"Queued" which is a good idea if your real (non)linear$FE take some time
to evaluate. Only after that I'd start to care about formatting details...
hth,
albert
[toc] | [prev] | [next] | [standalone]
| From | Armand Tamzarian <mike.honeychurch@gmail.com> |
|---|---|
| Date | 2011-10-30 09:31 +0000 |
| Message-ID | <j8j5hb$f8g$1@smc.vnet.net> |
| In reply to | #6013 |
On Oct 29, 10:27 pm, Don <don...@comcast.net> wrote:
> Below is the code for a simple PopupMenu
>
> The purpose is to present the user with a PopupMenu that
> gives two options: "Linear" or "NonLinear".
>
> There are two problems with this code:
>
> (1) The word "Linear" (the default) is suppose to show up in
> the window next to the right of the word " Function:".
> Right now, it's just left as a blank. It was thought
> that setting the inital value of the variable "fnc1" to Linear
> would solve that problem.
>
> (2) After the user makes a choice by clicking on the down arrow and
> clicking on an option (Linear or NonLinear) the
> code should then "fall through" and Print "999" to show
> it is positioned to determine which option the user chose by
> executing the following Which function, but this never happens.
> The act of choosing an option by the user should result in executin=
g the Which function and subsequent functions.
>
> How can this code be modified to fix those two problems?
> Thank you in advance.
>
> Don
>
> Remove[master$FE];
> master$FE[] := Module[{},
> Interpretation[{fnc1 = Linear},
>
> backgrndClr = ColorData["Aquamarine", 0.15];
> Panel[Grid[
> {
> {Style["PopupMenu", 36, Bold], SpanFromLeft
> },
>
> {
> Style["Function:", Bold, 22],
> PopupMenu[Dynamic[fnc1], {"Linear",
> "NonLinear"}, AutoAction -> True
> ] ,
> SpanFromLeft
> }
> },
>
> ItemStyle -> Directive[FontSize -> 26, Bold],
> Spacings -> {2, 2},
> Dividers -> {None, {2 ->
> Directive[Black, AbsoluteThickness[Large]]}}
> ], ImageSize -> {300, 250}, Background -> backgrndClr],
>
> Print[" Begin Which Function - 999 "];
>
> fnc1String = ToString[fnc1];
>
> Which[
> fnc1String == "Linear",
> linear$FE[],
>
> fnc1String == "NonLinear",
> nonLinear$FE[]
>
> ];(* End Which *)
>
> Print["777"];
> ](* Interpretation *)
> (* Print["888"];*)
> ](* End Module master$FE *)
This seems to do want you require (assuming I have understood your
post):
Remove[master$FE];
master$FE[] :=
DynamicModule[{fnc1 = "Linear", backgrndClr = ColorData["Aquamarine",
0.15]},
Column[{
Panel[
Grid[{{Style["PopupMenu", 36, Bold],
SpanFromLeft}, {Style["Function:", Bold, 22],
PopupMenu[Dynamic[fnc1], {"Linear", "NonLinear"},
AutoAction -> True], SpanFromLeft}},
ItemStyle -> Directive[FontSize -> 26, Bold],
Spacings -> {2, 2},
Dividers -> {None, {2 ->
Directive[Black, AbsoluteThickness[Large]]}}],
ImageSize -> {300, 250}, Background -> backgrndClr],
Dynamic[
Print[" Begin Which Function - 999 "];
Which[fnc1 == "Linear", linear$FE[], fnc1 == "NonLinear",
nonLinear$FE[]];(*End Which*)Print["777"];
Spacer[0],
TrackedSymbols :> {fnc1}]
}]
]
master$FE[]
Mike
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web