简体   繁体   中英

Moving/Hiding a button in vpython

How do I hide a button or simply move it off the screen in VPython? I have tried:

 del button
 button.visible = False
 button.pos.x = 500 # well off the screen

None of those seem to work.

I figured it out. Open Lib\site-packages\vis\controls.py(in your python folder). Find the button class. Insert this function at the bottom.

class button(ctrl):
...
  def _set_visible(self,value):
    self.box1.visible = value
    self.box2.visible = value
    self.box3.visible = value
    self.box4.visible = value
    self.button.visible = value
    self.label.visible = value
  def _get_visible(self):
    return self.box1.visible
  visible =property(_get_visible,_set_visible)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM