UI Tips and Tricks

44 views
Skip to first unread message

Tom Miranda

unread,
Aug 12, 2011, 6:20:46 PM8/12/11
to sagetv-b...@googlegroups.com
I thought I'd start this topic so we can share tips and tricks we have learned about writing XML for the UI.  I'll kick things off.

You can execute custom python methods using many of the normal action tags without using <xxx lang="python">.  For example, if you have a method defined in a .py file, or if it's defined in the <onload> tag you can just use:

<onclick>doMyMethod()</onclick>

Also found out that variables defined in any python code in the window become global to the window.  So if you can easily setup variables in the <onload> tag, or any other tag for that matter, and then use the variables anywhere in the window.

Last, I've found it very useful to define methods in the <onload> tag so they can be used later on in the window.  For example, in the EPG I've defined methods;

def scrollUp():
def scrollDown():
def moveRight():
def moveLeft():

and then I invoke these methods from the <onXXX> tags using the first trick I outlined.

Maybe you all knew this already, but maybe not.

Post your tips and tricks here, and ask UI related questions here.

Tom Miranda

unread,
Aug 12, 2011, 9:11:14 PM8/12/11
to sagetv-b...@googlegroups.com
One correction on the above, when using you own method in an action tag you do need to specify lang="python".

<onclick lang="python">doMyMethod()</onclick>

David Hamann

unread,
Aug 13, 2011, 10:41:34 AM8/13/11
to sagetv-b...@googlegroups.com
Not only are they global to the window, but I think they're global to descendant windows that are opened through ActivateWindow().

in recordings.xml you've defined reloadEpisodes()  and you call it in recordings_options_show_archived.xml

David Hamann

unread,
Aug 13, 2011, 10:43:50 AM8/13/11
to sagetv-b...@googlegroups.com
I found this useful, although everybody probably already knows about it.  You can manipulate the labels programmatically.

#Set the button labels for watched/don't like/archived
watched = item.GetProperty('IsWatched')
if watched:
thisWindow.GetButton(505), "Clear Watched")
else:
setLabel(thisWindow.GetButton(505), "Set Watched")

David Hamann

unread,
Aug 13, 2011, 10:46:53 AM8/13/11
to sagetv-b...@googlegroups.com
def setLabel(button, message):
button.SetLabel(message)

sorry for mailbombing, I wish you could edit this after posting...

Michael Reid

unread,
Aug 13, 2011, 12:51:25 PM8/13/11
to sagetv-b...@googlegroups.com
Is it possible to activate another window and pass parameters in the activatewindow call?  or... can i reference the varialbes setup in my main screen from the child spawned window?

Tom Miranda

unread,
Aug 13, 2011, 1:19:38 PM8/13/11
to sagetv-b...@googlegroups.com
Mike,

What I've been doing is using window properties to pass simple data.  You can access anything in other windows from python using various combinations of the  GetWindow().Control().ListItem() syntax.

On Sat, Aug 13, 2011 at 12:51 PM, Michael Reid <mrei...@gmail.com> wrote:
Is it possible to activate another window and pass parameters in the activatewindow call?  or... can i reference the varialbes setup in my main screen from the child spawned window?

--
You received this message because you are subscribed to the Google Groups "SageTV for Boxee (Development)" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sagetv-boxee-dev/-/rg_KW3330PcJ.

To post to this group, send email to sagetv-b...@googlegroups.com.
To unsubscribe from this group, send email to sagetv-boxee-d...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sagetv-boxee-dev?hl=en.

Tom Miranda

unread,
Aug 15, 2011, 7:08:11 PM8/15/11
to sagetv-b...@googlegroups.com
To easily access your windows and controls without having to use the ID.  In the <onload> tag put:

window = mc.GetWindow(14XXX)
myList = window.GetList(YYY)

Then anywhere in the code you can do things like:

myList.SetItems(...)

Tom Miranda

unread,
Aug 15, 2011, 7:21:35 PM8/15/11
to sagetv-b...@googlegroups.com
It's probably not a bad idea to post what you've found can't be done.

I know that there is currently no way to capture keystrokes in the UI other than the normal actions and in controls that accept keyboard input.

See here: http://jira.boxee.tv/browse/BOXEE-10098

Michael Reid

unread,
Aug 19, 2011, 10:39:42 PM8/19/11
to sagetv-b...@googlegroups.com
Passing an array of items from one window to another

I found this buried in the boxee/xbmc threads.  At Tom's request I am posting here for all to use!  If you need to pass information from one window to another you can use a parameter array and stuff anything you want into it.  It quite simple to do and the code looks as follows:

//Calling Window
params = mc.Parameters()
params['FavoriteID'] = FavID
mc.GetApp().ActivateWindow(14031, params)

//code in window 14031 in my case to retrieve parms
params = mc.GetApp().GetLaunchedWindowParameters()
mc.LogDebug("SageBoxee: Favorite ID = " + params['FavoriteID'])


the above code can be modified to use standard array syntax rather than an associated array if you want.  For example
params[0] = variable1
params[1] = variable2
.
.
params[n] = variablen

I have not tested passing complex objects such as ListItems, but i don't see why you couldn't do so.  Something along the lines of:
params[0] = mc.GetWindow(x).GetList(y)

I can't find the original link for reference, but now that i know what to search for here is what i found on the boxee dev forum...for everyone reference

~Mike

David Hamann

unread,
Aug 19, 2011, 11:37:02 PM8/19/11
to sagetv-b...@googlegroups.com
This is awesome... and I really love the way there's no mention of it in the documentation :(

Michael Reid

unread,
Aug 19, 2011, 11:45:00 PM8/19/11
to sagetv-b...@googlegroups.com
Yeah it kinda honks me off too. I wasted many an hour trying to get yours and Toms suggestions to work without luck...oh well, at least we know about it now.

Tom Miranda

unread,
Aug 21, 2011, 7:46:20 AM8/21/11
to sagetv-b...@googlegroups.com
Good info on global vars and persistent data.

http://forums.boxee.tv/showthread.php?t=14177
Reply all
Reply to author
Forward
0 new messages