I'm fairly new to Mathematica and currently making a simple GUI.
I'd like to work with dropdown menus and I'd like to dynamically change the possibilites of those menus depending on what's selected in the previous menu.
Using a ton of If-functions seemed impractical to me and so I ended up using the Piecewise-function instead (which might be stupid as well).
(*Dynamische Eingabefeld-Abhängigkeiten*)
Dynamic[Piecewise[{{forminput={"Viereck","Kreis"},method=="2D"},{forminput={"Quader", "Zyllinder"},method=="3D"}}]]
Dynamic[Piecewise[{
{diminput=Column[{"Länge: "InputField[Dynamic[l],Number], "Breite: "InputField[Dynamic[b],Number]}], form=="Viereck"},
{diminput=Column[{"Radius: "InputField[Dynamic[r],Number]}], form=="Kreis"},
{diminput=Column[{"Länge: "InputField[Dynamic[l],Number], "Breite: "InputField[Dynamic[b],Number], "Höhe: "InputField[Dynamic[h],Number]}], form=="Quader"},
{diminput=Column[{"Radius: "InputField[Dynamic[r],Number], "Höhe: "InputField[Dynamic[h],Number]}], form=="Zyllinder"}
}]]
(*GUI Input-Oberfläche*)
Panel[
Grid[{
{Style["2D oder 3D mesh?", Bold]},
{PopupMenu[Dynamic[method],{"2D","3D"}]},
{Style["Geometrische Form:", Bold], Style["Dimensionen [mm] :", Bold]},
{Dynamic[PopupMenu[Dynamic[form],forminput]], Dynamic[diminput]}
}]]
The code works as intended, however I cannot put a ";" behind the Piecewise-Functions. Once I do that it stops working. At the same time, having the evaluation of those functions permanently shown kinda ruins the look.
My questions would be:
1) is there a smarter way to hoave dependent drop down menus?
2) is there a way to surpress the output of the Piecewise-Functions without having them to stop working?