• 1(current)
  • 2
  • 3
  • 4
  • 5
  • 14
  • Next 
 
Thread Rating:
  • 5 Vote(s) - 4.2 Average
Your 1st Add-On: Hello World!
#1
Image

Description
Place holder for the official Kodi 'Hello World' Add-On

Tutorial
HOW-TO:HelloWorld_addon (wiki)

Source
https://github.com/zag2me/script.hello.world

Code
PHP Code:
import xbmcaddon
import xbmcgui
 
addon       
xbmcaddon.Addon()
addonname   addon.getAddonInfo('name')
 
line1 "Hello World!"
line2 "We can write anything we want here"
line3 "Using Python"
 
xbmcgui.Dialog().ok(addonnameline1line2line3

You can find other guides for Audio and Video here

Your 2nd Add-On: Online Video!
Your 3rd Add-On: Online Audio!
Reply
#2
Feel free to ask any questions in this thread about starting to write Kodi Add-Ons Wink

Just make sure it relates to "Hello World" somehow.

Code examples welcome
Reply
#3
Nice one, zag i look forward to using this very much. subscribed.
Yeah, Me, Myself, and I, The Three Musketeers
Image
Reply
#4
Hi, hopefully I'm posting in the right forum. I want to create a simple script so when my daughter connects her camera to a usb cable connected to my raspberry pi, it syncs everything to the media/pictures directory and informs her with a popup that all is done and she can disconnect the cable. I can code the syncing part, but I have no idea how to create a simple popup/dialog that she can see (preferably in the center of the screen, like other popups).

I'm quite sure this isn't impossible Smile Can anyone give me a simple example?
Reply
#5
I think the first post in this thread gives a pretty good idea of how to do a popup.

The other thing you might need to know is that your addon should be a service so it runs all the time waiting for the camera to be plugged in.

Of course there may be other addons that do all this already, you can browse the official ones at addons.xbmc.org
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#6
Updated the 1st post with a simpler version without underscores.

Has anyone done anything cool with this example yet? Maybe some modifications to show programming techniques or XBMC GUI features?

I'd love to see what people can come up with.
Reply
#7
(2014-12-02, 12:37)zag Wrote: Updated the 1st post with a simpler version without underscores.

Has anyone done anything cool with this example yet? Maybe some modifications to show programming techniques or XBMC GUI features?

I'd love to see what people can come up with.

Zag thank-you for starting this thread. I would be thrilled to learn something about developing addons. I should let you know I am a 55 year old retired novice but very motivated. I have read some materials and competed some Python on-line tutorials.

I was easily able to edit the text in the .py file but later when I tried to add a 4th string it did not work and I get a script error. I can't see anything obvious in the .py or .xml file that that causes this.

Here is what I added to the .py file.
line1 = "Hello World!"
line2 = "We can write anything we want here"
line3 = "My first addon using python"
line4 = "With the help Zag"

xbmcgui.Dialog().ok(addonname, line1, line2, line3, line4)
_______________________
XBMC Coding Novice Learner
Reply
#8
(2014-12-12, 01:43)LandRover Wrote:
(2014-12-02, 12:37)zag Wrote: Updated the 1st post with a simpler version without underscores.

Has anyone done anything cool with this example yet? Maybe some modifications to show programming techniques or XBMC GUI features?

I'd love to see what people can come up with.

Zag thank-you for starting this thread. I would be thrilled to learn something about developing addons. I should let you know I am a 55 year old retired novice but very motivated. I have read some materials and competed some Python on-line tutorials.

I was easily able to edit the text in the .py file but later when I tried to add a 4th string it did not work and I get a script error. I can't see anything obvious in the .py or .xml file that that causes this.

Here is what I added to the .py file.
line1 = "Hello World!"
line2 = "We can write anything we want here"
line3 = "My first addon using python"
line4 = "With the help Zag"

xbmcgui.Dialog().ok(addonname, line1, line2, line3, line4)

the dialog only contains three lines, you cannot use more.
see http://mirrors.xbmc.org/docs/python-docs...#Dialog-ok
Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
Reply
#9
Thanks Phil, does that document detail all the "rules" I need to follow for each element of an addon?
_______________________
XBMC Coding Novice Learner
Reply
#10
I have update the change.log and update the .xml to indicate that I am adapting the file originally created by zag, My addon version is now 1.0.1 I also tried to change the icon to my own, I deleted the original icon and replaced it with my own but the old icon still appears (!?) Any idea what maybe be happening here?

I am assuming it would be wise to have a plan of ultimately what we would like our addon to do, I would like a simple looking addon that opens and presents the user with 3 options TV Episodes, Movies, and Live Streaming.

For a simple addon would the next step be to create those 3 options or do we need to add/load other functions first?
_______________________
XBMC Coding Novice Learner
Reply
#11
XBMC is probably storing the image in its image cache so it wont update immediatly.

You probably need to uninstall and re-install the add-on again
Reply
#12
Hi,
I have done a menu with 3 items.
example:
<a href="http://www.fotos-hochladen.net/view/unterordnerkods5ql8ebk1g.jpg" target="_blank"><img src="http://img5.fotos-hochladen.net/thumbnail/unterordnerkods5ql8ebk1g_thumb.jpg" border="0"></a>
<a href="http://www.fotos-hochladen.net/view/ueberordnerkodf8hitvznu9.jpg" target="_blank"><img src="http://img5.fotos-hochladen.net/thumbnail/ueberordnerkodf8hitvznu9_thumb.jpg" border="0"></a>


Now i want that on item starts for example the movie in this link:

http//files2.trailerseite.de/trailer/2014-2/der-hobbit-3-trailer-2-hd.flv
(or any other file)

how can i link this video with my menue item respectively open it by pushing the menu item

thanks
Reply
#13
Great idea to do a 'Hello world' example for Kodi - we've all started off with such things at some stage. It's a great way to being exploration of what's available. I thought for some time about the best way to express my admiration for creating such a thing, and decided it was probably to try to extend it - so, the next example we generally come across is accepting some input, and displaying this instead of the default Hello World text. So, an example which gets the user to input their name and display it:

PHP Code:
import xbmc
import xbmcaddon
import xbmcgui
 
addon       
xbmcaddon.Addon()
addonname   addon.getAddonInfo('name')

keyboard xbmc.Keyboard("""Type your name"False)
keyboard.doModal()
if 
keyboard.isConfirmed() and keyboard.getText() != "":
    
line1 "Hello World!"
    
line2 "Nice to meet you %s" %(keyboard.getText())
    
line3 "Welcome to Kodi!"

    
xbmcgui.Dialog().ok(addonnameline1line2line3

(Which also introduces the XBMC module, checking variables, and Python string formatting)

Edit: Edited to remove my own coding quirks from the example
Reply
#14
(2014-12-13, 01:19)Unfledged Wrote: Great idea to do a 'Hello world' example for Kodi - we've all started off with such things at some stage. It's a great way to being exploration of what's available. I thought for some time about the best way to express my admiration for creating such a thing, and decided it was probably to try to extend it - so, the next example we generally come across is accepting some input, and displaying this instead of the default Hello World text. So, an example which gets the user to input their name and display it:

Thanks Unfledged, I put your code in and it worked perfectly. Smile

Unfortunately I don't understand what netzgauner did in post 12 above. It doesn't look like Python to me.
_______________________
XBMC Coding Novice Learner
Reply
#15
No thats a link to a picture (screenshot)
Reply
  • 1(current)
  • 2
  • 3
  • 4
  • 5
  • 14
  • Next 
 
Thread Rating:
  • 5 Vote(s) - 4.2 Average



Logout Mark Read Team Forum Stats Members Help
Your 1st Add-On: Hello World!4.25