How to write python script example
#1
When I try the code bellow from the HOW TO example on the wiki it runs but a "working" message keeps showing until you hit esc/back.
Is there a way of not showing that?

Code:
import xbmc, xbmcgui

#get actioncodes from https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/Key.h
ACTION_PREVIOUS_MENU = 10
ACTION_SELECT_ITEM = 7
ACTION_PARENT_DIR = 9

class MyClass(xbmcgui.Window):
  def __init__(self):
    self.strActionInfo = xbmcgui.ControlLabel(100, 120, 200, 200, '', 'font13', '0xFFFF00FF')
    self.addControl(self.strActionInfo)
    self.strActionInfo.setLabel('Push BACK to quit, A to display text and B to erase it')

  def onAction(self, action):
    if action == ACTION_PREVIOUS_MENU:
      self.close()
    if action == ACTION_SELECT_ITEM:
      self.strAction = xbmcgui.ControlLabel(300, 200, 200, 200, '', 'font14', '0xFF00FF00')
      self.addControl(self.strAction)
      self.strAction.setLabel('Hello world')
    if action == ACTION_PARENT_DIR:
      self.removeControl(self.strAction)

mydisplay = MyClass()
mydisplay .doModal()
del mydisplay
Reply
#2
the code works fine here.
could you also paste your addon.xml?
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
(2015-05-14, 20:09)ronie Wrote: the code works fine here.
could you also paste your addon.xml?

I use the one from the hello world example Smile

Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.program.hello.world" name="Hello World" version="1.0.0" provider-name="zag">
    <requires>
        <import addon="xbmc.python" version="2.14.0"/>
    </requires>
    <extension point="xbmc.python.pluginsource" library="addon.py">
        <provides>executable</provides>
    </extension>
    <extension point="xbmc.addon.metadata">
        <platform>all</platform>
        <summary lang="en">Popup Hello World</summary>
        <description lang="en">Example Plugin to show hello world</description>
        <license>GNU General Public License, v2</license>
        <language></language>
        <forum>http://forum.kodi.tv/showthread.php?tid=209948</forum>
        <source>https://github.com/zag2me/plugin.program.hello.world</source>
        <email>[email protected]</email>
    </extension>
</addon>
Reply
#4
I got it!! Smile

Changed extension point from pluginsource to script.

Just out of curiosity, what does this change? And what is happening when it keeps the "working" message in the corner?


ps. thanks ronie for pointing me to the xml !
Reply
#5
the "working" is a result of trying to run a script as a plugin. :-)
plugins need to make an 'endofdirectory' call so kodi knows the list is complete.

plugins usually provide a listing of playable media to kodi.
plugins also use the views from the skin, they can't (and don't need to) provide their own skin window.

a script can be just about anything.
if they need to display something in kodi, they need to provide their own script window.

so based on what type of addon you're creating, pick either the 'xbmc.python.pluginsource' or 'xbmc.python.script' extension point.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#6
Thanks for all the info!!
But if I can bug you a little more Smile would looking into plugins be better if I wanted to make a list of the last unmatched episodes (like lazy tv) but also the episode before that? Would it be possible to populate a list with that from a plug-in?
Reply

Logout Mark Read Team Forum Stats Members Help
How to write python script example0