简体   繁体   中英

Python 3.5 code - classes not correct defined

I have a simple code problem and do not know what I do wrong. The import part is OK, when I get as an error message is that, I guess I make a mistake with the classes.

status_listener = SessionStatusListener()
TypeError: interface takes exactly one argument

So the code is:

import clr

clr.AddReference ("fxcore2")
from fxcore2 import O2GTransport, IO2GSessionStatus

class SessionStatusListener(IO2GSessionStatus):

    def __init__(self):
        IO2GSessionStatus.__init__(self)
        self.connected = False

    def onLoginFailed(self, error):
        print ("*** LOGIN FAILED: %s" % error)

    def onSessionStatusChanged(self, status):
        print ("NEW STATUS: %s" % status)
        if status == O2GSessionStatusCode.Connected:
            self.connected = True

The main Application starts here

if __name__ == "__main__":

    session = O2GTransport.createSession()
    status_listener = SessionStatusListener()

Any advice is appreciated.

Pass an argument to SessionStatusListener, like it's telling you to. I would imagine that you need to change the __init__ body to something like

super().__init__(self) 

instead of

IO2GSessionStatus.__init__(self)

I believe it is saying that

status_listener = SessionStatusListener()

Needs one argument, like this:

status_listener = SessionStatusListener(1)

I'm not sure exactly what types of data it's expecting, but you need to pass in an argument.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM