AttributeError: 'NoneType' object has no attribute 'setPixmap'

  • Hello everyone,


    I have a problem displaying the image through this method:
    self[widget_name].instance.setPixmap(ptr)


    I got the error:
    { D } AttributeError: 'NoneType' object has no attribute 'setPixmap'


    Everything works outside of my main (very long) plugin code within the Screen class. However, it does not work in my main plug-in code - I always get the error. I know what this error message is about, but I can not imagine what it means in the context of Enigma. I've tried a lot of things.


    It looks like the plugin code does not recognize the "widget screen instance" and reports that there is no .setPixmap method for this "instance". What's interesting is that, beyond the basic plugin, the same code for displaying the image works pefectly. I was trying to make a simple short plugin especially just to open the picture and it worked.


    Does anyone know what to do with Enigma could be bad ?


    Thanks.



    In the past, the short plug-in working code + the debug-log error:

    Code
    04:15:19.6979 { D }     self["content_pic"].instance.setPixmap(ptr.__deref__())         #  .instance.setPixmap(ptr)        #  .instance.setPixmap(ptr.__deref__())
    04:15:19.6984 { D } AttributeError: 'NoneType' object has no attribute 'setPixmap'


    Separate extracted code to display an image that works as a standalone:


  • Hello, thanks for reply.


    Yup... I tried it too. I then got the same error, just that the object was no longer 'NoneType', but then it was the 'Pixmap' object, because at the beginning of the class is the declaration: self['content_pic'] = Pixmap(). In addition, Pixmap vs. Pixmap.instance is obviously a different class call. Or no ?


    What's strange is that everything worked a month ago. Then I made a lot of changes and I can not find the cause of not working :).


    The problem is somewhere in the functioning of the Enigma principle. The self-contained code as a separate plug-in just works well. However, the large plug-in code does not work. However, the class code is the same as I mentioned below in both cases (even in a small plug-in but also in a large plug-in). Something is missing there, I think ^^. Or, on the contrary, something can not be there. I do not intend to add a large plugin because it has an inappropriate publishing license.


    Someone has lost the self['content_pic'] object, but I do not know where or how it can happen. As if ['content_pic'] suddenly ceased to exist in the created Screen class.


    Sorry. I also forgot to mention that the "big" plug-in also does not work this row:
    size = self['content_pic'].instance.size()
    So instead of this, I use the max. size values from the enigma:
    from enigma import getDesktop
    sizemaxVert = getDesktop(0).size().height()
    sizemaxHoriz = getDesktop(0).size().width()


    Simply, the instance does not exist. I do not know why. I do not know when and where she could lose.

    9 Mal editiert, zuletzt von faraon6 ()

  • OK, problem solved. It was my fault.


    The self["content_pic"] = Pixmap() object was probably not initialized when I wanted to use it because I removed many "declarations" from __init__. The "declaration" has speeded up in my new class initialization. The previous __init__ code took much longer, so the self["content_pic"] = Pixmap() had a lot of time to activate.


    I used the built-in function to start the functions until the Screen layer (Class) is fully started:

    Python
    class HelloWorldScreen(Screen):
        def __init__(self, session):
            Screen.__init__(self, session)
            self.session = session
            ...        
            ...
            ...
            self.onLayoutFinish.append(self.startProcedure)


    Since then everything has worked smoothly.


    SvenH thank you for your help. I also thank others for reading. :smiling_face: