Search code examples
pythongraphicsvpython

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.


Solution

  • 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)