IconImage Depricated
#1
Hey all,

Sorry, I have a Python syntax question.  I am trying to wrap my head around the SetArt.

I have an addon with the following code:

        iconImage='DefaultAddSource.png'
        listItem = xbmcgui.ListItem(name, iconImage=iconImage, thumbnailImage=iconImage)

Understandably, it throws this error:

listItem = xbmcgui.ListItem(name, iconImage=iconImage, thumbnailImage=iconImage)
                                                   TypeError: 'iconImage' is an invalid keyword argument for this function

Can someone kindly let me know the correct syntax for those lines?

Thanks!!!
Ken
Reply
#2
https://alwinesch.github.io/group__pytho...f6bb55919c

Art is added separately:-
https://alwinesch.github.io/group__pytho...2d14a37394
Reply
#3
(2023-09-13, 19:23)kenmills Wrote: Sorry, I have a Python syntax question.  I am trying to wrap my head around the SetArt.

I have an addon with the following code:

        iconImage='DefaultAddSource.png'
        listItem = xbmcgui.ListItem(name, iconImage=iconImage, thumbnailImage=iconImage)

Understandably, it throws this error:

listItem = xbmcgui.ListItem(name, iconImage=iconImage, thumbnailImage=iconImage)
                                                   TypeError: 'iconImage' is an invalid keyword argument for this function

Can someone kindly let me know the correct syntax for those lines?

It sounds like you may be porting an addon from Kodi 18 to something newer so here's an example which also brings into play the setInfo call that will be deprecated sometime in the future.  Here's a thread on that topic.  You can see in the code snippet link I provided I am handling both Kodi 19 and higher.


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#4
python:
iconImage='DefaultAddSource.png'
listItem = xbmcgui.ListItem(name)
listitem.setArt({'icon': iconImage, 'thumb': iconImage})
Reply
#5
Awesome thanks all for your info, yes I am trying to port an older add-on; the dbmc one.

Cheers!
Ken
Reply
#6
OK @jepsizofye that code worked perfectly in the page I updated!  Thanks!!

 From what I read and understand, I then changed the following lines:

    def add_action(self, name, action):
        iconImage='DefaultAddSource.png'
        listItem = xbmcgui.ListItem(name, iconImage=iconImage, thumbnailImage=iconImage)

TO:

def add_action(self, name, action):
        iconImage='DefaultAddSource.png'
        listItem = xbmcgui.ListItem(name)
        listitem.setArt({'icon': iconImage, 'thumb': iconImage})


But then I get the following error:

listitem.setArt({'icon': iconImage, 'thumb': iconImage})
                                                   NameError: name 'listitem' is not defined


Am I missing something?  Isn't it exactly the same syntax and context?

Cheers,
Ken
Reply
#7
(2023-09-13, 20:46)kenmills Wrote: Am I missing something?  Isn't it exactly the same syntax and context?

indeed...

i made a typo, my listitem is with little 'i' and yours is uppercase

change i to I
Reply
#8
Awesome that was it, doh!  I should have caught that myself...  Too much time doing code today lol.

Thanks am million!
Reply
#9
@jepsizofye - do you mind if I DM you for a few other questions about this port?  You seem quite knowledgeable.  :-)

FOr example, now I am getting the following error on this line:

    sessionId = ADDON.getSetting('session_id')

error:
NameError: name 'ADDON' is not defined


Is this just another case sensitive one?  i.e. should the line be:  sessionId = addon.getSetting('session_id')  ?

Cheers,
Ken
Reply
#10
(2023-09-13, 21:15)kenmills Wrote: @jepsizofye - do you mind if I DM you for a few other questions about this port?  You seem quite knowledgeable.  :-)

FOr example, now I am getting the following error on this line:

    sessionId = ADDON.getSetting('session_id')

error:
NameError: name 'ADDON' is not defined


Is this just another case sensitive one?  i.e. should the line be:  sessionId = addon.getSetting('session_id')  ?

Look for a line like this and match the case for the addon variable on the left side of the = sign.

Code:
addon = xbmcaddon.Addon()

Thanks,

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#11
(2023-09-13, 21:17)jbinkley60 Wrote:
(2023-09-13, 21:15)kenmills Wrote: @jepsizofye - do you mind if I DM you for a few other questions about this port?  You seem quite knowledgeable.  :-)

FOr example, now I am getting the following error on this line:

    sessionId = ADDON.getSetting('session_id')

error:
NameError: name 'ADDON' is not defined


Is this just another case sensitive one?  i.e. should the line be:  sessionId = addon.getSetting('session_id')  ?

Look for a line like this and match the case for the addon variable on the left side of the = sign.

Code:
addon = xbmcaddon.Addon()


Thanks,

Jeff

Gotcha!  thx!
Reply
#12
OK so there is no line at all like that..  

I added this at the top of the file:

ADDON = xbmcaddon.Addon()


And it worked thanks!
Reply
#13
(2023-09-13, 21:26)kenmills Wrote: OK so there is no line at all like that..  

I added this at the top of the file:

ADDON = xbmcaddon.Addon()

This is the code that is causing the error:

def getAccessToken():
    access_token = None
    #Get the session_id (uuid). Create one if there is none yet.
   sessionId = ADDON.getSetting('session_id')

The error is:
access_token = None
  NameError: name 'ADDON' is not defined

Try setting ADDON to lowercase.  I've never used ADDON as an uppercase variable.  If this doesn't work you have some form of Python scope issue.  You can test that with:

 
Scope issue option:
sessionId = xbmcaddon.Addon().getSetting('session_id') 


Thanks,

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#14
(2023-09-13, 21:37)jbinkley60 Wrote:
(2023-09-13, 21:26)kenmills Wrote: OK so there is no line at all like that..  

I added this at the top of the file:

ADDON = xbmcaddon.Addon()

This is the code that is causing the error:

def getAccessToken():
    access_token = None
    #Get the session_id (uuid). Create one if there is none yet.
   sessionId = ADDON.getSetting('session_id')

The error is:
access_token = None
  NameError: name 'ADDON' is not defined

Try setting ADDON to lowercase.  I've never used ADDON as an uppercase variable.  If this doesn't work you have some form of Python scope issue.  You can test that with:

 
Scope issue option:
sessionId = xbmcaddon.Addon().getSetting('session_id') 


Thanks,

Jeff

Sorry Jeff, I edited my original reply.  I had  a typo and it worked after I fixed it :-)  Thanks again!!!
Reply
#15
(2023-09-13, 21:38)kenmills Wrote: Sorry Jeff, I edited my original reply.  I had  a typo and it worked after I fixed it :-)  Thanks again!!!

Glad you got it working.


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply

Logout Mark Read Team Forum Stats Members Help
IconImage Depricated0
This forum uses Lukasz Tkacz MyBB addons.