gpt4 book ai didi

checkbox - TogglerBar 可以用作 Mathematica 中的多个 CheckBox 吗?

转载 作者:行者123 更新时间:2023-12-02 21:56:45 31 4
gpt4 key购买 nike

是否可以使用 TogglerBar 而不是 2 个复选框来显示或不显示不同的形状。

TogglerBar 的每个按钮中都写有绿色和红色?

Manipulate[
Graphics[{If[thePink, {Pink, Disk[{5, 5}, 3]}],
If[theGreen, {Green, Disk[{15, 2}, 1]}]},
PlotRange -> {{0, 20}, {0, 10}}], {{thePink, True,
Style["Pink", Black, Bold, 12]}, {True, False}}, {{theGreen, True,
Style["Green", Black, Bold, 12]}, {True, False}}]

enter image description here

我尝试调整的实际 Manipulate 对象可以在那里找到:http://www.laeh500.com/LAEH/COG.html目的是用一个漂亮的 TogglerBar 替换 CheckBox。

最佳答案

像这样吗?

Manipulate[
Graphics[{
{White, Circle[{5, 5}, r]}, (* For Mma 7 compatibility*)
If[MemberQ[color, "Red"], {Pink, Disk[{5, 5}, r]}],
If[MemberQ[color, "Green"], {Green, Disk[{4, 2}, r]}]},
PlotRange -> {{0, 20}, {0, 10}}],
{{r, 1, "Radius"}, 1, 5, 1, ControlType -> Setter},
{{color, "Red", "Color"}, {"Red", "Green"}, ControlType -> TogglerBar},
LabelStyle -> Large]

enter image description here

编辑

回答您的评论,我认为您的笔记本可以从这样的模板中受益:

Manipulate[
Graphics[
{
{White, Circle[{5, 5}, r]},(* For Mma 7 compatibility*)
If[MemberQ[whatToDisplay, "Circle"], {Red, Circle [{5, 5}, r]}],
If[MemberQ[whatToDisplay, "Square"], {Blue, Rectangle[{5, 5}, {r, r}]}],
If[MemberQ[whatToDisplay, "Other"], {Black, Line [Tuples[{3, 4}, 2]]}],
},
PlotRange -> {{0, 20}, {0, 10}}
],
(* Controls follow *)
{{r, 1, Style["Radius", Black, Bold, 12]}, 1, 5, 1, ControlType -> Slider
, ControlPlacement-> Top
},
Control@{{whatToDisplay, True, Style["What", Black, Bold, 12]},
{"Circle", "Square", "Other"},
ControlType -> TogglerBar,
Appearance -> "Vertical",
ControlPlacement -> Left
}
]

enter image description here

关于checkbox - TogglerBar 可以用作 Mathematica 中的多个 CheckBox 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6299215/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com