WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 12-16-2008, 05:34 PM
Gladsomebeast Gladsomebeast is offline
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
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.

Here is the module that adds a setParent method to the Info class:

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]
	def setParent(self, newParent=viz.SCREEN, newScene=viz.MainScene):
		self._group.parent(newParent, newScene)
if __name__ == '__main__':
	SIM_SCENE = viz.Scene2
	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
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 12:24 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC