![]() |
|
#1
|
|||
|
|||
Your createButton function should return the button object and you should save the object in a global variable with the name you want. For example:
Code:
def createButton(self, position, pictureOff, pictureOn, name, szene): self.Position = position self.PictureOff = pictureOff self.PictureOn = pictureOn self.Name = name self.Szene = szene name = viz.add(viz.BUTTON, scene=szene) name.translate(position[0],position[1]) name.uppicture(pictureOff) name.downpicture(pictureOn) name.setScale(12,3.6) return name button1 = createButton([0.25,0.8],'button01Off.jpg', 'button01On.jpg', 'button1', 2) |
#2
|
|||
|
|||
Hi,
thanks for your answer. But this does not work. ![]() For example: I've got this class: Code:
import viz class Button(object): def createButton(self, position, name): name = viz.add(viz.BUTTON) name.translate(position[0], position[1]) return name and this start.py Code:
import viz import button viz.go() button = button.Button() button.createButton([0.2,0.5], 'testbutton') def onButton(obj,state): if obj == button.testbutton: print 'test' viz.callback(viz.BUTTON_EVENT,onButton) In my example, the button got the name 'testbutton'. But then, I've got the error message: 'Button' object has no attribute 'testbutton' What is wrong?? ![]() ![]() |
#3
|
|||
|
|||
You need to assign the return value of the createButton function to a variable:
Code:
import viz import button viz.go() btn = button.Button() testbutton = btn.createButton([0.2,0.5], 'testbutton') def onButton(obj,state): if obj == testbutton: print 'test' viz.callback(viz.BUTTON_EVENT,onButton) |
#4
|
|||
|
|||
Yes it works!
Thank you very much.... |
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
multiple objects | durf | Vizard | 1 | 04-10-2009 01:42 PM |
Lightwave objects rotation problem | hosier | Vizard | 6 | 02-13-2009 12:04 PM |
simply overlapping objects | chris | Vizard | 3 | 04-28-2008 12:39 PM |
Could not find plugin to load objects... | halley | Vizard | 1 | 05-30-2006 11:01 AM |
putting objects on the screen | jargon | Vizard | 7 | 05-24-2005 11:31 AM |