Addon with home screen widgets

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
tria Offline
Senior Member
Posts: 108
Joined: Jan 2012
Reputation: 0
Post: #1
Hello,

The weather addon have nice widgets showing the different weather for different days, and when chosen it show detailed information about the weather in a separate addon screen.
Can I implement my own addon that I can add to the main menu, and when over, it show several widgets like what the weather addon is doing. Of course I am not going to reinvent the wheel, I will build a different addon.

I don't expect a full code of course, just pointers in the right directions (Wiki/API...etc)

Thank you.

Edit:
I know this might require modification to the skin, but I don't mind this as I am not intending to do a production addon, rather than a one for personal need.
(This post was last modified: 2012-02-16 11:06 by tria.)
find quote
el_Paraguayo Offline
Donor
Posts: 630
Joined: Feb 2011
Reputation: 14
Location: London, UK
Post: #2
The way I've done this is by getting my script to set various skin strings and then modding my skin to display them appropriately:

e.g.
[Image: 2lidbnl.png]
[Image: 2n7iff5.png]

Is that what you meant?

MythSuspendAlarm: Suspend and wake for next MythTV recording.
BBC Live Football Scores: Football scores notifications.
Random Movie Script: Play random movies from library.
find quote
tria Offline
Senior Member
Posts: 108
Joined: Jan 2012
Reputation: 0
Post: #3
Yes, and your idea for London Underground times is somehow close to my idea (mine is about time/schedule that I want to update/display daily). Also, I wish I had your addon when I was studying in London Smile

What I am planning to do is query a website, and parse the data, then present them in a widget for one of the menu items (like what you did).

Do you mind sharing the code? Or maybe give me some pointers. I am mainly curious about how to display widgets with a given addon menu item (XML and such) and how to pass data to them to be displayed (like how to make the script run on startup and periodically pull the data and update them on the home screen). You will do me a big favor for any directions.

Thanks.

Edit:
btw, nice addon idea.
You could also add a map for the underground for aid (especially if you are planning to go to a new destination)
(This post was last modified: 2012-02-16 16:55 by tria.)
find quote
el_Paraguayo Offline
Donor
Posts: 630
Joined: Feb 2011
Reputation: 14
Location: London, UK
Post: #4
Very happy to share my code - Give me a chance and I'll stick the addon code onto Github so you can have a look.

By the way, I don't use WindowXML for my widgets - I modified my skin files directly. I'll upload my mods so you can see those too.

MythSuspendAlarm: Suspend and wake for next MythTV recording.
BBC Live Football Scores: Football scores notifications.
Random Movie Script: Play random movies from library.
find quote
el_Paraguayo Offline
Donor
Posts: 630
Joined: Feb 2011
Reputation: 14
Location: London, UK
Post: #5
As for periodically updating the data, you probably want to get your addon to run the AlarmClock function (http://wiki.xbmc.org/index.php?title=Lis..._functions).

MythSuspendAlarm: Suspend and wake for next MythTV recording.
BBC Live Football Scores: Football scores notifications.
Random Movie Script: Play random movies from library.
find quote
el_Paraguayo Offline
Donor
Posts: 630
Joined: Feb 2011
Reputation: 14
Location: London, UK
Post: #6
Code is here: https://github.com/elParaguayo/Development-area

MythSuspendAlarm: Suspend and wake for next MythTV recording.
BBC Live Football Scores: Football scores notifications.
Random Movie Script: Play random movies from library.
find quote
k_zeon Online
Senior Member
Posts: 226
Joined: Aug 2011
Reputation: 0
Post: #7
out of curiosity, where do you put the skin xml files.
Also do you just add each xml file and that gets automatically added to the current skin.
I am interested in adding features to Standard Confluence skin
ie Recently watched movie or TV show

But not sure where to start. I have seen a script that gets Recently watched movie or TV show but the skin needs to be modded to show the info etc

tks
find quote
tria Offline
Senior Member
Posts: 108
Joined: Jan 2012
Reputation: 0
Post: #8
el Paraguayo, how did you become so great? Smile
Thank you so much for sharing it.

But I have some questions
1. Do I need to include the xml files in a given file (like includes.xml or home.xml)
2. How to know the container and the control IDs (to check for visibility) especially when I have a different skin, or different arrangment
3. Do your script run at start up automatically, or you have to run it first to make the overlays show the data
4. Finally, imagine I called the update function (the one you scrap data with) using a timer function (the one you suggested). Will every call update the overlays without any problem?

btw, it is a sin not to release this addon. It should be in the official repository. Smile
find quote
el_Paraguayo Offline
Donor
Posts: 630
Joined: Feb 2011
Reputation: 14
Location: London, UK
Post: #9
What I should probably explain is that these scripts were built in mind to suit me alone Wink so I modded the skin to suit my needs!

k_zeon Wrote:out of curiosity, where do you put the skin xml files.
Also do you just add each xml file and that gets automatically added to the current skin.

The skin files were put inside the 720p folder in my skin folder (I useCirrus Extended v2).

The script does not automatically add these files - and it can't because if someone uses a different skin it wouldn't work.

I made the xml files purely to fit my version of Cirrus.

tria Wrote:el Paraguayo, how did you become so great? Smile
Thank you so much for sharing it.

But I have some questions
1. Do I need to include the xml files in a given file (like includes.xml or home.xml)
2. How to know the container and the control IDs (to check for visibility) especially when I have a different skin, or different arrangment
3. Do your script run at start up automatically, or you have to run it first to make the overlays show the data
4. Finally, imagine I called the update function (the one you scrap data with) using a timer function (the one you suggested). Will every call update the overlays without any problem?

btw, it is a sin not to release this addon. It should be in the official repository. Smile

Easy on the praise tria! I knew nothing about skinning or writing scripts when I started with xbmc. Everything I learnt, I learnt from asking questions on the forum (it's a very helpful community) or looking at how other people's scripts work.

My scripts are messy. I'm not a coder, so there are bound to be mistakes, unhandled errors etc. The really impressive scripts are those that work for everyone straight away.


Anyway, more information on how to display those widgets.

I put the widget itself in a separate include file as it's just neater and easier for me to make changes.

Once I've made the file you need to make sure the skin is aware of it.

In Includes.xml I added these lines:
PHP Code:
<include file="IncludesTubeStatus.xml" /> 
<include 
file="IncludesTrainTimes.xml" /> 

Then, I get the homescreen to include the widgets:

Home.xml:
PHP Code:
<include>tubestatus</include>
<include>
traintimes</include> 

Lastly I add the items to my main menu:
PHP Code:
<control type="wraplist" id="9000">
...

<
item id="41">
  <
label>Tube Status</label>
  <
onclick>RunScript(script.tubestatus)</onclick>
  <
icon>tubestatus/tube.jpg</icon>
</
item>

<
item id="42">
  <
label>Train Times</label>
  <
onclick>RunScript(script.traintimesskin=True)</onclick>
  <
icon>traintimes/trainstation.jpg</icon>
</
item


Now, you remember that the widgets had this line:
PHP Code:
<visible>Container(9000).HasFocus(41) + Skin.HasSetting(tubestatus.IsFetched)</visible

You should see that the container(9000) is the id of the main menu (above) and the HasFocus(41) is the id of my Tube Status within the menu. So that condition is only true when that menu item is showing.

The second condition "Skin.HasSetting(tubestatus.IsFetched)" is set by the script if it successfully updates.

I don't run the scripts at start up - you'll notice they're triggered by on <onclick> command on the menu item.

If you do the timer function then yes, the skin will update automatically (I use that on my football scores one)

Hope that's enough to get you going but keep asking questions if not.


As for getting these in the official repo - the scripts are likely to be too buggy and too specific for wide use.

MythSuspendAlarm: Suspend and wake for next MythTV recording.
BBC Live Football Scores: Football scores notifications.
Random Movie Script: Play random movies from library.
find quote
el_Paraguayo Offline
Donor
Posts: 630
Joined: Feb 2011
Reputation: 14
Location: London, UK
Post: #10
k_zeon Wrote:I am interested in adding features to Standard Confluence skin
ie Recently watched movie or TV show

But not sure where to start. I have seen a script that gets Recently watched movie or TV show but the skin needs to be modded to show the info etc

tks

I'm not familiar with the script, but your best bet may be to ask in the Confluence thread.

Let me know which script it is and I might be able to give you some pointers in the right direction.

MythSuspendAlarm: Suspend and wake for next MythTV recording.
BBC Live Football Scores: Football scores notifications.
Random Movie Script: Play random movies from library.
find quote
tria Offline
Senior Member
Posts: 108
Joined: Jan 2012
Reputation: 0
Post: #11
el_Paraguayo Wrote:Hope that's enough to get you going but keep asking questions if not.
No that is not enough to get me going. This has cleared everything I needed to know! Smile

As for your script being buggy or messy, I took a quick look at your code (and I am not a python programmer myself), and took a quick look at other addons code (official ones included), and have long experience programming and completing other people work. Trust me your code is easy to read, and clean. Usually those who claim they have something great are the one that I find their code ugly and buggy. But I understand what you are saying, as I share the same feeling about whatever I write even if someone complemented me. I had to say all this, as you deserve complement for helping and sharing.

The only thing that I would suggest for the train addon, is as usual, make it generic, so anyone can write a scrapper, and give your addon "from"/"to"/"time"/"status"...etc. This will make the script general for anyone interested in extending it (and the scrapper idea is easy).

Many thanks.
find quote
el_Paraguayo Offline
Donor
Posts: 630
Joined: Feb 2011
Reputation: 14
Location: London, UK
Post: #12
tria Wrote:The only thing that I would suggest for the train addon, is as usual, make it generic, so anyone can write a scrapper, and give your addon "from"/"to"/"time"/"status"...etc. This will make the script general for anyone interested in extending it (and the scrapper idea is easy).

I will be addding the from/to bits to the train times, unfortunately I haven't had time to do it yet. The stations are just hardcoded in the script for testing purposes.

Good luck with your script, let me know if you have any questions.

MythSuspendAlarm: Suspend and wake for next MythTV recording.
BBC Live Football Scores: Football scores notifications.
Random Movie Script: Play random movies from library.
find quote
tria Offline
Senior Member
Posts: 108
Joined: Jan 2012
Reputation: 0
Post: #13
Just to let you know that I successfully wrote my own script based on your helpful directions. I am here to thank you again, you don't know how much this meant to me. Thanks.
find quote
el_Paraguayo Offline
Donor
Posts: 630
Joined: Feb 2011
Reputation: 14
Location: London, UK
Post: #14
No problem at all! Glad you managed to achieve what you wanted.

You should post screenshots of what you've done, chances are someone else might be interested in what you've done.

MythSuspendAlarm: Suspend and wake for next MythTV recording.
BBC Live Football Scores: Football scores notifications.
Random Movie Script: Play random movies from library.
find quote
tria Offline
Senior Member
Posts: 108
Joined: Jan 2012
Reputation: 0
Post: #15
I will release it in the end for sure, I just didn't do much so far. I just made sure I was able to present something as a widget under one of the menu items, thanks to you, but I am still working on the data to be shown (processing). Also, I will have to do the settings, skinning, and the addon screens itself. Then I will release it, and submit it.

Do you know if I can make the skin tags for positioning (posx, posy) changeable through the script? I am planing on changing the label control x position based on the processed data (for visual perception purposes). If you don't know then no problem (I should probably ask about it in another thread).

As for people finding it worthy, yes there will be people who will use it. But I am sure that you won't be one of them (due to background, not personality/interest) Smile

Edit: I will make sure to give you credit when I release it
(This post was last modified: 2012-02-19 20:07 by tria.)
find quote
Post Reply