Gre7g Luterman wrote:
If I try to move an ogl shape by program code,
I get (at least for me) completely strange effects.
I derive a new class
self.shape = ogl.CircleShape(self.Size[0])
self.shape.SetX(30)
This hives no errors
Now if I put the SetX in another method of that new
class
self.shape.SetX ( 100)
If this code is within the derived object, then it
should be:
self.SetX(100)
Gre7g
thanks Greg,
it was some stupid mistake 
But I'm not there yet,
I can move the shape by calling SetX and redraw the shape,
but how do I get rid of the shape at the old position ?
Then I have another weird problem,
which might have nothing to do with ogl but but general Python knowledge
(I hope I give enough information)
I have a class tDevice (my "base" class), consisting of an ogl shape and some other properties
# ***********************************************************************
class tDevice:
# extra initialization that can be overridden by descendants
def init (self): pass
def __init__ (self, Name = 'NoName', Color = (220,220,220),
Pos = [-1,-1], Size = [-1,-1], Timer_On = False, TimerValue = 200):
# make the container available for descendants
from JALsPy_main import Container
self.my_Container = Container
self.my_nr = Container.diagram.GetCount()
# *********************************
# here the extra initalisation
# *********************************
self.init()
# *********************************
# add the shape to the canvas container
Container.MyAddShape( self.shape, self.Pos[0], self.Pos[1],
wx.Pen(wx.BLUE, 1), self.Color_Off, self.Name)
# ***********************************************************************
Then I have descendant classes from the above base class,
which set's the actual shape and draw the shape
(and a lot of other things left out of here)
# ***********************************************************************
class tLED (tDevice):
# ************************************
# __init__ of ancestor, will call init
# ************************************
def init (self):
# create the visual shape
self.shape = ogl.CircleShape(self.Size[0])
self.shape.SetX(30)
# ************************************
# called by internal timer or program
# ************************************
def execute (self):
dc = wx.ClientDC ( self.my_Container )
self.my_Container.PrepareDC ( dc )
self.shape.SetBrush ( self.Color_Off )
self.my_Container.Redraw ( dc )
# ***********************************************************************
Now I can create an instance: and print it
global LED
LED = tLED ( 'A3', wx.CYAN )
print LED
which give me te correct answer I guess
<device_LED.tLED instance at 0x01C37198>
now I can also move the shape
LED.shape.SetX(LED.shape.GetX()+20)
dc = wx.ClientDC ( LED.my_Container )
LED.my_Container.PrepareDC ( dc )
LED.shape.SetBrush ( LED.Color_Off )
LED.my_Container.Redraw ( dc )
and get the new shape drawn perfectly
Now I want to store the reference into a list, and then when troubles start
Devices =
print LED
gives me, so still ok
<device_LED.tLED instance at 0x01C37198>
Now add it to a list
Devices.append(LED)
print LED
print Devices
gives
<device_LED.tLED instance at 0x01C37198>
[<device_LED.tLED instance at 0x01C37198>]
so it still looks perfect
... but when I move the shape now I get an error
print LED
LED.shape.SetX(LED.shape.GetX()+20)
TypeError: 'float' object is not callable
The print statement before the position change is still
<device_LED.tLED instance at 0x01C37198>
so it looks OK.
What does adding the object to a list change ??
any clue would be very much appreciated.
thanks,
Stef Mientki
···
--- Stef Mientki <s.mientki@ru.nl> wrote: