#1
|
|||
|
|||
vizinfo in multiple scenes
hi, im trying to use the vizinfo module but the boxes only seem to appear in scene 1.
how can I add an info box to a different scene (while in another one)? or how can I make a box appear after calling viz.scene(#>1) ? thanks |
#2
|
|||
|
|||
Hi,
Do you want the same box in different scenes? If so, try the following: Code:
info = vizinfo.add(....) #Duplicate the box onto scene 2 info._group.duplicate(2) Code:
info.group.duplicate(2) |
#3
|
|||
|
|||
how should i do it if I want to add multiple vizinfos into different scenes (at least 2 per scene).
also, is there a way I can check the version number of vizard so i can send an error message if the user tries to run a script in an older version? |
#4
|
|||
|
|||
Hi,
To add the vizinfo box to a different scene try the following: Code:
#Place info box in scene 2 info._group.parent(viz.WORLD,2) Code:
version = viz.version() |
#5
|
|||
|
|||
so i tried what you suggested, but it doesn't seem to work. i even made a little test script:
Code:
import viz import vizinfo viz.go() viz.clearcolor(.5,.5,.5) info = vizinfo.add('message') scene = 1 def onkeydown(key): global info, scene #The keyboard button 'key' is being pressed if key == ' ': scene += 1 viz.scene(scene) if key == 'd': info._group.duplicate(scene) if key == 'm': info._group.parent(viz.WORLD, scene) viz.callback(viz.KEYDOWN_EVENT,onkeydown) |
#6
|
|||
|
|||
My bad, it should be:
Code:
info._group.parent(viz.SCREEN, scene) |
#7
|
|||
|
|||
ok, so the parent trick works (maybe this should be added as a feature in future versions?). now i get an error when i try to scale vizinfo. what i have is this:
Code:
INFO_SIZE = [0.5,0.5] info = vizinfo.add('blah') info.scale(INFO_SIZE) Code:
Traceback (most recent call last): File "<string>", line 12, in ? File "context_recall_02.py", line 123, in ? infoBox.scale(INFO_SIZE) TypeError: scale() takes exactly 3 arguments (2 given) |
#8
|
|||
|
|||
The older version of vizinfo didn't support passing lists to the scale function. You will have to pass each value individually:
Code:
info.scale(INFO_SIZE[0],INFO_SIZE[1]) Code:
info.scale(*INFO_SIZE) |
#9
|
|||
|
|||
i have both 2.5 and the previous version (2.1?) installed. I was getting that error while using 2.5. Is it possible vizard was grabbing the vizinfo from the older version?
also, random python question. is there a python equivalent to: x = (isBoolean)? y:z i have a lot of checks, and i'm tired of repeating the 4 line if/else template |
#10
|
|||
|
|||
It might be possible. Startup 2.5 and check the value of the following in the interactive window:
Code:
viz._WIN_VIZ_PATH Python doesn't support the one line if/else. If you can guarentee that the value of the boolean will always be either 0 or 1 you could do the following: Code:
x = [z,y][isBoolean] Code:
def ifelse(boolean,trueVal,falseVal): if boolean: return trueVal return falseVal x = ifelse(isBoolean,y,z) |
Thread Tools | |
Display Modes | Rate This Thread |
|
|