#1
|
|||
|
|||
Modifying Vizinfo to Support Re-parenting Tip
Flexible graphical user interfaces (GUIs) components often have a common parent node for global positioning and scale. Vizard's vizinfo module does not allow setting of vizinfo menus' parent, so one cannot incorporate them into GUI components. The following article describes how to fix the issue by adding a setParent method to a subclass of vizinfo's Info class.
http://vizworkshop.com/articles/vizinfo_reparenting.html Here is the module that adds a setParent method to the Info class: Code:
import viz import vizinfo def add(text, textsize=1.0, **kw): return ParentableVizInfo(text, textsize, **kw) class ParentableVizInfo(vizinfo.Info): def __init__(self, text, textsize, parent=viz.SCREEN, scene=viz.MainScene, **kw): vizinfo.Info.__init__(self, text, textsize, **kw) self.setParent(newParent=parent, newScene=scene) if parent != viz.SCREEN: #remove initial offset so info in in center of parent node, not [.95, .95, 0] self.translate([0,0,0]) def setParent(self, newParent=viz.SCREEN, newScene=viz.MainScene): self._group.parent(newParent, newScene) if __name__ == '__main__': viz.go() SIM_SCENE = viz.Scene2 viz.scene(SIM_SCENE) node = viz.addGroup(parent=viz.SCREEN, pos=[.5, .5, 0], scene=SIM_SCENE) add('test asdafasdf', parent=node, scene=SIM_SCENE)
__________________
Paul Elliott WorldViz LLC |
|
|