- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何创建一个Button
,仅当某些全局FrontEnd设置的值为False
时才会显示,并且会随着的整行自毁列
按下后将此值设置为True
?
我需要这样的东西:
Column[{"Item 1", "Item 2",
Dynamic[If[
Last@Last@Options[$FrontEnd, "VersionedPreferences"] === False,
Button["Press me!",
SetOptions[$FrontEnd, "VersionedPreferences" -> True]],
Sequence @@ {}]]}]
但是使用此代码 Button
在按下后不会消失。有没有可能让它自毁?
基于 belisarius 想法的最终解决方案和 mikuszefski :
PreemptProtect[SetOptions[$FrontEnd, "VersionedPreferences" -> False];
b = True];
Dynamic[Column[
Join[{"Item 1", "Item 2"},
If[Last@Last@Options[$FrontEnd, "VersionedPreferences"] === False &&
b == True, {Button[
Pane[Style[
"This FrontEnd uses shared preferences file. Press this \
button to set FrontEnd to use versioned preferences file (all the \
FrontEnd settings will be reset to defaults).", Red], 300],
AbortProtect[
SetOptions[$FrontEnd, "VersionedPreferences" -> True];
b = False]]}, {}]], Alignment -> Center],
Initialization :>
If[! Last@Last@Options[$FrontEnd, "VersionedPreferences"], b = True,
b = False]]
重点是:
Dynamic
变量b
并将其与Options[$FrontEnd, "VersionedPreferences"]
,Column
构造使用 Dynamic
而不是使用列
内的动态
。最佳答案
也许
PreemptProtect[SetOptions[$FrontEnd, "VersionedPreferences" -> False]; b = True];
Column[{"Item 1", "Item 2", Dynamic[
If[Last@Last@Options[$FrontEnd, "VersionedPreferences"]===False && b == True,
Button["Here!", SetOptions[$FrontEnd, "VersionedPreferences"->True];b=False],
"Done"]]}]
编辑
回答您的评论。请尝试以下方法。用 Dynamic[ ]
包含 Column[ ]
可以调整它的大小:
PreemptProtect[SetOptions[$FrontEnd, "VersionedPreferences" -> False]; b = True];
Dynamic[
Column[{
"Item 1",
"Item 2",
If[Last@Last@Options[$FrontEnd, "VersionedPreferences"] === False && b == True,
Button["Press me!", SetOptions[$FrontEnd, "VersionedPreferences" -> True]; b=False],
Sequence @@ {}]}]]
关于wolfram-mathematica - 柱内自毁按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6387132/
自从学了C++之后,我时不时会用C++来联想一些其他编程语言(即Java)的一些特性。这可能是因为我根本没有 100% 信任它们(我认为 100% 信任任何东西都是愚蠢的),而关于 JFrame 的东
所以我找到了这段代码,它显然可以工作(因为它已经投入生产多年了): window[someMethod] = function (tmp) { callback({prop:"val"}, t
我正在寻找设计自毁 Cocoa 应用程序的方法。这个想法是在启动时检测应用程序是否正在进行逆向工程(这总是在多次尝试中完成)并在情况下删除/损坏它。当然,狂热的黑客可以重新下载并逆向设计破坏过程,但这
在学习 C++ 的过程中,我偶然发现了文章 Writing Copy Constructors and Assignment Operators它提出了一种机制来避免复制构造函数和赋值运算符之间的代码
所以我有这个 fiddle here它在右下角添加一个 div 以在用户添加元素时通知用户(单击事件 item1..item5 div)。此 div 在几秒钟后自毁 (div.remove())。 $
我是一名优秀的程序员,十分优秀!