【问题标题】:how to show/hide links according to Switch in NetLogo如何根据 NetLogo 中的 Switch 显示/隐藏链接
【发布时间】:2015-04-17 02:16:58
【问题描述】:

我想根据 UI 中 Switch 的值显示/隐藏各种链接。我知道当相应的过程嵌入到 setup 或 go 过程中时如何显示/隐藏链接,但我想知道是否可以分离我的可见链接过程以便在我想要的时候调用它,即使 go 按钮不是按下:

to visible-links
    ifelse show-diffusions? ;; this is my Switch element
    [ask diffusions [set hidden? false]]
    [ask diffusions [set hidden? true]]
end

我是否应该简单地添加一个永久可用的新按钮并使用它来让用户调用可见链接过程?这会有点难看,但如果这是我唯一的方法。

【问题讨论】:

    标签: netlogo


    【解决方案1】:

    添加另一个“永久”按钮将是一种矫枉过正。还有另一种解决方案,但它会改变您的用户界面。

    我想你有一个名为show-diffusions? 的开关控件,它自动成为NetLogo 中的一个全局变量。代替那个开关控件,创建一个全局变量show-diffusions? 和一个按钮 Show-hide-switchShow-hide-switch 过程可以打开和关闭扩散可见性并渲染链接。

    globals [
      show-diffusions?  
    ]
    
    to setup
      set show-diffusions? true
    end
    
    to visible-links
      ask diffusions [ set hidden? not show-diffusions? ]
    end
    
    ; this is called by a button Show-hide-switch
    to Show-hide-switch
      set show-diffusions? (not show-diffusions?)
      visible-links
      ; or call display if necessary
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-27
      • 1970-01-01
      • 2017-05-01
      • 1970-01-01
      • 2014-08-02
      • 2012-03-22
      • 2012-06-20
      • 1970-01-01
      相关资源
      最近更新 更多