hello,

I have faced a problem that is almost as same as the problem below:


((((If I try to define a timer in an ogl.BitmapShape, like this:

class T6963_device (ogl.BitmapShape):
def __init__(self):
ogl.BitmapShapeinit__ (self)
self.t1 = wx.Timer (self)

I get this error

Traceback (most recent call last):
File "D:\data_to_test\smtest2.py", line 516, in ?
LCD_init ( frame )
File "D:\data_to_test\T6963c.py", line 337, in LCD_init
LCD = T6963_device()
File "D:\data_to_test\T6963c.py", line 107, in __init__
self.t1 = wx.Timer (self)
File "P:\Python\Lib\site-packages\wx-2.8-msw-ansi\wx\_misc.py", line
1279, in __init__
_misc_.Timer_swiginit(self,_misc_.new_Timer(*args, **kwargs))
TypeError: in method 'new_Timer', expected argument 1 of type
'wxEvtHandler *'

If I add the same timer definition to my main form, like this

class My_MainForm(wx.Frame):
def __init__(self):
wx.Frameinit__( self, None, -1, 'JAL Functional Simulator' ,
pos=(0,0), size=(640,480))

# Finally show the mainform
self.Show()

self.t1 = wx.Timer (self)
self.Bind(wx.EVT_TIMER, Timer)
self.t1.Start ( 1000 )

def Timer (self, event):
print 'aap'

everything works perfect.

Why can't I define a timer in an ogl.BitmapShape ?
In which (derived) objects can I define a Timer ?)))))

I think the reason is that ((((Because ogl.BitmapShape is not a
subclass of wx.EvtHandler))))

But how can I set it as a subclass of wx.evthandler?

thank you very much

Andy

Can't you just start the timer outside of that class. IE

ID_TIMER1 = wx.NewId()
class T6963_device (ogl.BitmapShape):
    def __init__(self):
        ogl.BitmapShapeinit__ (self)
        MainWindow.t1 = wx.Timer (MainWindow, id=ID_TIMER1)
        MainWindow.t1.Bind(wx.EVT_TIMER, MainWindow.aFunction, id = ID_TIMER1)
        MainWindow.t1.Start(1000)
# where MainWindow is your app's Main Window
This article has been dead for over six months. Start a new discussion instead.