String question and label navigation...
#1
hi all... im trying to make a yahoo finance stock script for xbmc since it looks like that hasnt been done yet and have a stupid question.

Quote:stocks = 'amd,msft' #a global string

.....
stocks = stocks + ',ibm' #concatenate to string

where the second line occurs somewhere in a classes method. im getting errors doing the concatenation and am not sure whats up. i thought that since the first variable was global maybe it was a const type or something but a member variable had the same behavior.

does it have something to do with circular referencing maybe? or maybe strings can just never be changed? i have years of experience in java c and s/390 assembly but am a python ultra newb Smile

second xbmc question:
do labels and buttons behave the same? i mean can you have labels be put into navigation lists and be highlighted and fire oncontrol events? i can't figure out how to... im trying to put the stock results into a table and am going to do it with just a bunch of labels and do the layout manually.... i could have done it with a list if there were color formatting (for the red/green numbers) and tabbing for the aligned columns but you gotta work with what you got :-)... id like to be able to select an individual label so i can pop up a graph or something but am not having success adding it to the navigation struction.

a workaround i thought of if i can't use nav is to add an invisible control or something and let it grab focus and redraw the labels with one highlighted and keep track of which it is manually. changing focus manually back to a real control in the onaction block. if you can follow that idea you see how messy it is and why i want to avoid it. any suggestions will be welcom


id like to get this thing out the door soon and will upload it to the server when i'm done with it... thx all.

-ast
Reply
#2
first, sounds like a very cool script! i'm anxious to see it.

a possible solution to your string concatenation problem would be to add the line "global stocks" before you assign the variable. this lets python know you're adding text to a global variable, not creating a temporary class variable of the same name (which is possible).

labels, as far as i know, cannot be used as actionable controls. they simply exist for decoration (well, for output, of course). your suggestion of adding invisible buttons over the labels could work, although it would be just as easy to create buttons instead of labels, and just give them empty textures (so that they show up as flat labels). that should work, but i might not be understanding exactly what you're trying to do. and i made not have said it clearly. if you're interested, ask and i'll try to clarify.

alexpoet
For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
Reply
#3
good idea with the global thing ill try that.



well the hack that i was thinking about was to have an invisible button added to the navigation graph as a dead end... with no up down neighbors

use window -> getfocus to detect when this control is hit and then capture the up and down actions in onaction and increment the index of my highlighted label accordingly... i guess youll see how it turns out...

now i wish there was an standard way for scripts to store data..
Reply
#4
that is actually a very clever hack. i see better what you were meaning, now (and it's cleverer than what i'd had in mind).

there's no standard way for storing data, but i've just developed a convenience class that i use to keep mine standard, called config.py. you create a config instance on the script, then add variables to the config and on close it saves them all to a .dat file. it uses the cpickle functionality to write them out, so you can save complex python variables and even class instances. it's a very convenient utility. i haven't entirely finished fleshing it out, so i haven't made it fully available, but if you'd like to try it email me (script_requests at cox.net) and i'll send you the script.

i could certainly use some feedback on it, before i offer it up to the public.
For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
Reply
#5
hmmm on experimentation you can't navigate to an invisible button but you can put a button offscreen :-)

lol the silly hack just got quite a bit sillier :-) but i am pretty sure it should work now and is looking good so far... fun stuff.

ill next update when i have something more compelling.
Reply

Logout Mark Read Team Forum Stats Members Help
String question and label navigation...0