【发布时间】:2011-12-19 01:21:05
【问题描述】:
这是我想做的一个例子:在 Manipulate 本身的控制区域中做所有显示:
Manipulate[
p = Framed@
Plot[Sin[x],{x, -y, y},ImageSize->300,Background-> White, ImagePadding -> 20];
{},
Grid[{
{Control[{{y, N@Pi/2, "y"}, -Pi, Pi, Appearance -> "Labeled"}]},
{Dynamic@p}
}],
ControlPlacement -> Left,
Alignment -> Center,
ImageMargins -> 1,
FrameMargins -> 1,
ContentSize -> {0}
]
问题是M自动添加了滚动条:
帮助说
If ContentSize specifies a content area that does not completely fit
the contents, then unless specified otherwise with AppearanceElements,
functions like Manipulate display a resize area, as well as scrollbars
when necessary.
问题是,如何使用 AppearanceElements 来移除这个滚动条?
(有时我希望 M 帮助在解释某事时不要那么简短)。
在上面,注意上面写着:unless specified otherwise with AppearanceElements,
但我无法找出这意味着什么。 '否则'是什么
应该是什么意思?
我得到的最接近的是在上面添加AppearanceElements -> ""。所以新
版本现在变成了
Manipulate[
p = Framed@
Plot[Sin[x], {x, -y, y}, ImageSize -> 300, Background -> White,
ImagePadding -> 20];
{},
Grid[{
{Control[{{y, N@Pi/2, "y"}, -Pi, Pi, Appearance -> "Labeled"}]},
{Dynamic@p}
}],
ControlPlacement -> Left,
Alignment -> Center,
ImageMargins -> 1,
FrameMargins -> 1,
ContentSize -> {0},
AppearanceElements -> "" (*added this *)
]
但请注意,右侧的尺寸仍然不太正确,应该更紧, 我也失去了曾经在那里的“+”。我必须保留它。
所以,我认为我需要的只是找到'+'的元素名称是什么,所以我可以使用
正确的AppearanceElements -> "correctNameHere",我希望这个
会做正确的事。 (我尝试了“关闭”,但没有成功,我也丢失了“+”)
我只是找不到那个“+”元素名称是什么。有谁知道吗?
这里是找到更多信息的地方:
http://reference.wolfram.com/mathematica/ref/Manipulator.html
http://reference.wolfram.com/mathematica/ref/ContentSize.html
所以,问题是:如何完全去除显示的滚动条效果 上,但同时保留右上角的“+”。
谢谢
更新 2
感谢以下答案,这是结果的屏幕截图。
Manipulate[
p = Framed@
Plot[Sin[x], {x, -y, y}, ImageSize -> 300, Background -> White,
ImagePadding -> 20];
{}, Grid[{{Control[{{y, N@Pi/2, "y"}, -Pi, Pi,
Appearance -> "Labeled"}]}, {Dynamic@p}}],
AppearanceElements -> "BookmarksButton", ControlPlacement -> Left,
Alignment -> Center, ImageMargins -> 1, FrameMargins -> 1,
ContentSize -> {0}, Alignment -> Center]
我很高兴。显示在顶角的小白线似乎 成为这个的副作用。我猜我得活下去。
【问题讨论】:
-
您选择不在
Manipulate的控制窗口内显示绘图有什么原因吗? -
@yoda,是的,非常好的理由。例如,现在能够将控件放置在对象本身旁边,使 UI 更易于使用。考虑一个简单的例子:一个情节,人们希望能够改变一些选项。现在,使用 Manipulate 设计方式,控件都在一侧,而情节转到另一侧。如果能够将对象及其控制变量“放在一起”,放在一个组中会更好。能够将对象本身放在控制区域中,这让我能够做到这一点。这在更复杂的 UI 中变得更加重要。
-
1.您所做的似乎导致 AppearanceElements 选项损坏。 AppearanceElements->None 通常会给你你想要的东西和玩具例子,它的内容区域有内容。 2. 这是另一种情况,您必须使用 Manipulate,因此您必须折磨它以使其屈服而不是使用 DynamicModule? 3.“+”元素称为“ManipulateMenu”。
-
@MikeHoneychurch,感谢您的回答。是的,恐怕我必须使用 Manipulate,因为它是一个演示 CDF。本来想直接使用 Dynamics,但不允许用于演示网站。似乎“ManipulateMenu”和“BookmarksButton”都有效。但是我仍然在右上角看到一条小白线,我在上面的更新中放了一个屏幕截图。我在 Windows 7 上使用 V 8.04。再次感谢 Kguler 的帮助。 AppearanceElements 的帮助并不好,应该做得更好和自给自足。
-
查看下方删除了白色小区域的其他修改。