how to put taskMgr in class

hi, Im just a newbie one…

  
        from pandac.PandaModules import *
        import Task

        class Timer:  
.................................................
        #in Timer class
        def start(self, t, name):
        if (self.started):
            self.stop()
        self.callback = None
        self.finalT = t
        self.name = name
        self.startT = globalClock.getFrameTime()
        self.currT = 0.0
        #here is my focused function
        taskMgr.add(self.__timerTask, self.name + '-run')
       
        self.started = 1

the original source can do, but I cannot put taskMgr within my created class
can you give me some direction…ThX

Why can’t you put taskMgr in your class? Or why would you?
Could you give us some clearer information?

PS. This works fine for me:

        from pandac.PandaModules import *
        import Task

        class Timer: 
.................................................
        def __timerTask(task):
.................................................
          return task.cont 

        #in Timer class
        def start(self, t, name):
.................................................
        #here is my focused function
        taskMgr.add(self.__timerTask, self.name + '-run')
       
        self.started = 1

In the document told me that “taskMgr” is global method but
this is my question to ensure

import direct.directbase.DirectStart

I understand that, I need to import this statement above this line before use taskMgr and any other global functions right??
and if you have some suggestion…I appreciate youssssss^^
and above all, if you have some source of information except commercial panda3D (its good but, I just need more information from other sources to make me understand) thank you so much…!

Once you imported DirectStart, taskMgr is usable in all your modules. So you don’t need to import DirectStart more than once. It’s a builtin variable, and you should be able to access it over all your modules/classes/functions.