ControlType
是 Manipulate 和相关函数的一个选项,指定应该显示的控件类型.
更多信息
- 可能的控件类型有 Animator、Checkbox、ColorSetter、ColorSlider、InputField、IntervalSlider、Manipulator、PopupMenu、RadioButton 或 RadioButtonBar、Setter 或SetterBar、Slider、Slider2D、Trigger 和 VerticalSlider. 也可使用 None.
- ControlType->None 指定不显式显示控件.
- ControlType->{type1, …} 指定第 i 个控件的类型应该是 typei.
- ControlType 选项可以为 Manipulate 中的每一个变量分别指定.
- 任意控件可以通过给出形如 {u,func} 的控件指定在 Manipulate 中设置.
范例
打开所有单元 关闭所有单元基本范例 (3)
缺省的 Manipulate 控件:
Manipulate[x, {x, 0, 1}]用 Slider2D 屏蔽:
Manipulate[x, {x, 0, 1, ControlType -> Slider2D}]缺省的 ControllerManipulate 控件:
ControllerManipulate[u, {u, 0, 1}]添加一个连接到同一变量的 Slider :
ControllerManipulate[u, {u, 0, 1, ControlType -> Slider}]Manipulate[y, {y, 1, 10, 1}, {x, Range[y]}, ControlType -> {Slider, PopupMenu}]范围 (10)
在默认情况下,Manipulate 选择一个 Manipulator 来控制指定的变量:
Manipulate[u, {u, 0, 1}]用 ControlType 指定要使用的控制类型,包括 None:
Manipulate[u, {u, 0, 1}, ControlType -> None]Manipulate[u, {u, 0, 1}, ControlType -> Slider]Manipulate[u, {u, 0, 1, ImageSize -> Small}, ControlType -> VerticalSlider, ControlPlacement -> Left]Manipulate[u, {u, {0, 0}, {1, 1}}, ControlType -> Slider2D, ControlPlacement -> Left]Manipulate[Graphics[{}, PlotRange -> 1, ImageSize -> Tiny], {u, {-1, -1}, {1, 1}}, ControlType -> Locator]RadioButton、Setter、Checkbox 或 PopupMenu:
Table[Manipulate[u, {u, {0, 1}}, ControlType -> c], {c, {RadioButton, Setter, Checkbox, PopupMenu}}]Table[Manipulate[u, {u, Blue}, ControlType -> c], {c, {ColorSetter, ColorSlider}}]Manipulate[u, {u, "xxx"}, ControlType -> InputField]为每一个 Manipulate 变量分别指定控件类型:
Manipulate[{u, v, w}, {u, 0, 1, Slider}, {v, Red, ColorSlider}, {w, "xxx", InputField}]ControlType 可以同个别变量控件的指定结合使用:
Manipulate[{u, v, w}, {u, {0, 1}}, {v, {0, 1}, Checkbox}, {w, {0, 1}}, ControlType -> Setter]采用 Automatic 设置时,选用一个适当的控制器:
Manipulate[{t, u, v, w, x, y, z}, {t}, {u, 0, 1}, {v, {0, 0}, {1, 1}}, {w, Red}, {x, {False, True}}, {y, Range[5]}, {z, Range[10]}, ControlType -> Automatic]相关指南
-
▪
- 交互操作的选项和样式 ▪
- 交互式操控
文本
Wolfram Research (2007),ControlType,Wolfram 语言函数,https://reference.wolfram.com/language/ref/ControlType.html.
CMS
Wolfram 语言. 2007. "ControlType." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/ControlType.html.
APA
Wolfram 语言. (2007). ControlType. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/ControlType.html 年
BibTeX
@misc{reference.wolfram_2026_controltype, author="Wolfram Research", title="{ControlType}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/ControlType.html}", note=[Accessed: 15-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_controltype, organization={Wolfram Research}, title={ControlType}, year={2007}, url={https://reference.wolfram.com/language/ref/ControlType.html}, note=[Accessed: 15-September-2026]}