PDA

View Full Version : Opening a new page and passing through values



boxMaster
January 17th, 2010, 09:46 AM
Hi there

I just have a few questions mostly about the topic title..

1) Im using the following line to open up a new page in my app that has the window id of 42222 but it doesnt seem to be working. Is there anything else I should be doing?
<onclick lang="python">RunApp(app://appname/42222)</onclick>

2) I have one page with a category list coming in from an RSS feed. When i click one of those categories I need to go to a new page but carry through a value of an element in the RSS feed, say <category_id> . How could I accomplish such a thing?

3) Say I have a group control with the id of 155. To hide it by clicking on a button what would i use? Currently when I run the script below I get a script failed message
<onclick lang="python"><![CDATA[
import mc
mc.GetControl(155).SetVisible(false)]]></onclick>
How could I also achieve a similar thing except change a label instead of the visibility

4) In the error log im constantly getting this error:
17:24:29 T:9444 M:277434368 ERROR: CGUIBaseContainer::CalculateLayout, either item or focused layout is missing from control = 0, parent = 9999 (control)
Its repeated like 100 times or so everytime I run the app. This happens even when everything is working fine. Does anybody know what it means?

5) Is there a way to refresh the app when testing? Instead of exiting the app, then going to shortcuts and opening it again..
_____________

I have been digging around in the documentation and some other apps but cant seem to find what I need and what I'm trying doesnt seem to be working.
Any help will be appreciated :) thanks

joshuajonah
January 17th, 2010, 11:48 AM
1) You are looking for ActivateWindow(<window id>, [<params>]). Runapp does just that, runs another app, you just want a new window.

2) For your two lists, you would get the info from the focused item when it's clicked on and store it in a python variable. Then show the second list of sub items and you should still have access to that var within events of the second list. If you are opening a new window, you can pass a params object to the ActivateWindow call.

3) "false" does not exist in Python. Boolean values are capfirst, You are looking for:
<onclick lang="python"><![CDATA[
import mc
mc.GetControl(155).SetVisible(False)
]]></onclick> Also, I always add a space at that last line so that might be an issue.

You could change that to a label change like this:
mc.GetLabel(155).SetLabel("Beefcake")
It's important to note that some items need to be accessed in a certain way to maintain the methods defined to their parent class. For example, above I used GetLabel() because using GetControl() would leave it without the SetLabel method defined in a the LabelControl class as a subclass of Control. This is a Boxee API thing and in my opinion, retarded.

4) Are you missing a focusedlayout tag or something from a list? It is required you know.

5) Python nerd answer: I've used a thread to quit an app and then launch it again, but because of that thread, the app never really quits totally. However as long as the thread is intended for this usage and kills itself in the course of garbage collection upon app startup it should work fine.

English answer: not really.

boxMaster
January 17th, 2010, 01:00 PM
1) You are looking for ActivateWindow(<window id>, [<params>]). Runapp does just that, runs another app, you just want a new window.

2) For your two lists, you would get the info from the focused item when it's clicked on and store it in a python variable. Then show the second list of sub items and you should still have access to that var within events of the second list. If you are opening a new window, you can pass a params object to the ActivateWindow call.

3) "false" does not exist in Python. Boolean values are capfirst, You are looking for:
<onclick lang="python"><![CDATA[
import mc
mc.GetControl(155).SetVisible(False)
]]></onclick> Also, I always add a space at that last line so that might be an issue.

You could change that to a label change like this:
mc.GetLabel(155).SetLabel("Beefcake")
It's important to note that some items need to be accessed in a certain way to maintain the methods defined to their parent class. For example, above I used GetLabel() because using GetControl() would leave it without the SetLabel method defined in a the LabelControl class as a subclass of Control. This is a Boxee API thing and in my opinion, retarded.

4) Are you missing a focusedlayout tag or something from a list? It is required you know.

5) Python nerd answer: I've used a thread to quit an app and then launch it again, but because of that thread, the app never really quits totally. However as long as the thread is intended for this usage and kills itself in the course of garbage collection upon app startup it should work fine.

English answer: not really.


Thanks for your reply Josh!
Regarding your Q1, could you please give me an example of how to pass params in ActivateWindow then how to retrieve them once in the other window? I couldnt find much info about how this is done

Is there a reference anywhere that you can refer me to that lists all the methods and ways to use them, such as GetLabel or GetControl, specific to using python in Boxee?

One last question, how can I add custom elements in my RSS feed that boxee can pick up. For example in my xml that I need to convert to an rss, I've got <homescore>23</homescore> and <awayscore>11</awayscore>. Is there a way to do this or will I need to use the existing boxee rss elements as placeholders my own custom elements?
Thanks :)

joshuajonah
January 17th, 2010, 01:44 PM
An example of ActivateWindow() with params:

<onclick lang="python"><![CDATA[
import mc

params = mc.Parameters()
params['address'] = 'Joe'
params['user'] = 'joe'
params['pass'] = 'hunter2'

mc.GetApp().ActivateWindow(14003, params)
]]></onclick>
Then in 14003:

<onload lang="python"><![CDATA[
import mc

params = mc.GetApp().GetLaunchedWindowParameters()

print '%s %s %s' % (params['address'], params['user'], params['pass'])
]]></onclick>

There is a ton of info in here on listitems, mc methods, etc: http://developer.boxee.tv/Python_API

As for the RSS, you should really try to meet the specification, but you can however access custom attributes of listitems that are populated in this way. Here's an example of a label inside a focusedlayout picking up custom data:

<control type="label">
<width>400</width>
<height>30</height>
<label>$INFO[ListItem.property(custom:homescore)]</label>
<font>font24</font>
<textcolor>white</textcolor>
</control>

This is hit or miss in my testing though :D

boxMaster
January 18th, 2010, 02:06 AM
An example of ActivateWindow() with params:

<onclick lang="python"><![CDATA[
import mc

params = mc.Parameters()
params['address'] = 'Joe'
params['user'] = 'joe'
params['pass'] = 'hunter2'

mc.GetApp().ActivateWindow(14003, params)
]]></onclick>
Then in 14003:

<onload lang="python"><![CDATA[
import mc

params = mc.GetApp().GetLaunchedWindowParameters()

print '%s %s %s' % (params['address'], params['user'], params['pass'])
]]></onclick>

There is a ton of info in here on listitems, mc methods, etc: http://developer.boxee.tv/Python_API

As for the RSS, you should really try to meet the specification, but you can however access custom attributes of listitems that are populated in this way. Here's an example of a label inside a focusedlayout picking up custom data:

<control type="label">
<width>400</width>
<height>30</height>
<label>$INFO[ListItem.property(custom:homescore)]</label>
<font>font24</font>
<textcolor>white</textcolor>
</control>

This is hit or miss in my testing though :D

Thanks Josh, it all worked perfectly :D