how to enable this 'hello world' script ? [xbmc-live]
#1
hi, i created this file:
Code:
xbmc@XBMCLive:~$ cat /live/image/dotXBMC/scripts/schneidz/schneidz.py
import xbmc, xbmcgui

class MyClass(xbmcgui.Window):
    print "hello world"

mydisplay = MyClass()
mydisplay.doModal()
del mydisplay
but i am unable to select it in the xbmc menus. i tried looking in programs -> get more..., and video add-ons -> enable add-ons.

nothing seems to work. can someone please direct me in the right direction as to how to run this program in xbmc ?

thanks,
Reply
#2
turn it into an addon.

basically this means add an addon.xml file
and put it in it's own folder in the addons directory.
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
^ thanks a lot ronie.

i now have a zip file that looks like:
Code:
schneidz2.zip
schneidz2/addon.xml    
schneidz2/changelog.txt
schneidz2/default.py  
schneidz2/default.tbn  
schneidz2/fanart.jpg  
schneidz2/icon.png    
[schneidz@hyper schneidz2]$ cat addon.xml
<?xml version="1.0" encoding="UTF-8"?>
<addon id="plugin.video.schneidz2.com" version="0.1.0" name="schneidz2" provider-name="schneidz">
    <requires>
        <import addon="xbmc.python" version="1.0"/>
    </requires>
    <extension point="xbmc.python.script" library="default.py" />
    <extension point="xbmc.addon.metadata">
        <summary>schneidz - sum</summary>
        <description>schneidz - desc</description>
        <platform>all</platform>
    </extension>
</addon>
[schneidz@hyper schneidz2]$ cat default.py
import xbmc, xbmcgui

class MyClass(xbmcgui.Window):
    print "hello world"

mydisplay = MyClass()
mydisplay.doModal()
del mydisplay
so i installed the add-on from the zip file and it is listed in the programs section. but when i select it with the remote it just shows a blank screen.

how can i get it to display the words 'hello world' on the screen ?


edit:
i see this:
Code:
xbmc@XBMCLive:~$ tail  .xbmc/temp/xbmc.log
21:05:50 T:26487664 M:1657049088   ERROR: CFileCurl::CReadState::Open, didn't get any data from stream.
21:05:55 T:26487664 M:1657016320 WARNING: FillBuffer: curl failed with code 28
21:05:55 T:26487664 M:1657016320   ERROR: CFileCurl::CReadState::Open, didn't get any data from stream.
21:05:57 T:2933394288 M:1656508416  NOTICE: -->Python Interpreter Initialized<--
21:05:57 T:2933394288 M:1656508416  NOTICE: [color=Red]hello world[/color]
21:06:17 T:3023928176 M:1662349312 WARNING: CreateLoader - Unsupported protocol(addons) in addons://more/executable.tbn
21:09:06 T:26487664 M:1658073088 WARNING: FillBuffer: curl failed with code 28
21:09:06 T:26487664 M:1658073088   ERROR: CFileCurl::CReadState::Open, didn't get any data from stream.
21:13:03 T:26487664 M:1658232832 WARNING: FillBuffer: curl failed with code 28
21:13:03 T:26487664 M:1658232832   ERROR: CFileCurl::CReadState::Open, didn't get any data from stream.
still working on printing to the screen...
Reply
#4
Quote:still working on printing to the screen...
You need to create a window. Check one of the working add-ons
Reply
#5
OP, check this wiki page for examples on some basic on-screen gui elements

http://wiki.xbmc.org/index.php?title=HOW...s_for_XBMC
Reply
#6
Try this:

Code:
# -*- coding: utf-8 -*-


import xbmc, xbmcgui, xbmcaddon, xbmcvfs


class MyClass(xbmcgui.Window):
    def __init__(self):
        self.myLabel = xbmcgui.ControlLabel(100, 120, 200, 200, "", "font13", "0xFFFF00FF")
    self.addControl(self.myLabel)
    self.myLabel.setLabel("Hello World!")

mydisplay = MyClass()
mydisplay.doModal()
del mydisplay

I am just learning too and figured this out just now. Note the special function "__init__ which, when included in a class, always runs when the class is called. The first line of this function tells python to create a ControlLabel (which is included in the xbmcgui library) with certain dimensions, font size and color. As far as I can tell, the second line adds this control to the window (basically telling it to draw the control on the window). And the third updates the "label" (i.e. the text) of this control to read "Hello World!"

Hope this helps. Good luck with your coding.
Reply
#7
Just to add my miniscule knowledge to Chadder1's I believe when you use the 'print' command that's just going to tell it to report the phrase 'hello world' in the log file but not on screen. While I'm learning python I use this a lot to check the correct things are being stored in my variables and functions, but to print things on screen in XBMC you need to use the correct interface commands that will be recognised by the xbmc and xbmcgui libraries, as Chadder1 does with the addControl and setLabel commands above. Others will correct me I'm sure if this is wrong. Good luck.
Reply
#8
All good stuff, really helpful for me as a student.

But a 2-year old thread?
Reply
#9
lol - didn't notce that!!
Reply
#10
Meh, it's good for people searching in the future
Reply
#11
And yet 4 replies in the last 2 days to my post.... I admit I didn't notice the date until after I posted but considering that this thread is one of the top google results for "xbmc python hello world" I figured that posting a working program is probably more helpful than "check one of the working add-ons."
Reply

Logout Mark Read Team Forum Stats Members Help
how to enable this 'hello world' script ? [xbmc-live]0