Eventhandling Error

Hey guys :slight_smile:,

I’ve got a little problem. I just searched on this board for some finished code snipplets handling key events.

I’ve found this(posted by pro-soft, so i think it should work):

import direct.directbase.DirectStart
from direct.showbase import DirectObject
from pandac.PandaModules import *


class World(DirectObject):
  def __init__(self):
    self.accept('escape', sys.exit)
    self.accept('a', self.move_)
    self.__load__()
 
  def __load__(self):
    self.model = loader.loadModel("models/environment")
    self.model.reparentTo(render)
    self.model.setScale(1,1,1)
    self.model.setPos(-8,42,0)
    self.ship = loader.loadModel("models/box")
    self.ship.reparentTo(render)
    self.ship.setscale(15,15,1)
    self.ship.setPos(0,0,0)
 
  def move_(self):
    self.ship.setPos(self.ship.getX() + 1,0,0)

World()
run() 

When I compile, there is said, that module.init() takes at most 2 arguments(3 given).
Am I dumb oder something like that? I just initialize a instance from DirectObject with def init(self), don’t I?

I know that’s not a board for learning python, but maybe you are willing to help me :slight_smile:.

Thanks,
jadephoenix1988

You have imported the module named DirectObject, not the class named DirectObject (the class is within the module). Change your import statement to:

from direct.showbase.DirectObject import DirectObject

David