I’m trying to change the cursor based on the user roles. ie: if they can poke it, show a hand.
For the cursor property, I have:
runScript('app.util.showHand')
[code]def showHand(default=0):
import app
if app.globals.ok_to_operate():
return int(12) # cursor code for hand
return int(default)
[/code]
Instead of setting the cursor I get:
ClassCastException: Cannot coerce value '<function showHand at 0x8>' into type: int
Edit: ver 7.5.6
Edit 2: just created a int property and tried to bind the above to that and got the same result. So it’s not the cursor property that’s the problem.
Try:
runScript('app.util.showHand()')
That won’t do what I want.
Unless I bind it to mouse enter and mouse leave events which I guess I can do as a work around.
Why can’t I just return the cursor code as a number as per the example in the docs:
[code]def getTempAt(zipCode):
import system
import re #Regular Expression library
response = system.net.httpGet(“http://xml.weather.yahoo.com/forecastrss?p=” + str(zipCode))
NOTE - if you’ve never seen regular expressions before, don’t worry, they look
confusing even to people who use them frequently.
pattern = re.compile(’.?<yweather:condition (.?)/>’, re.DOTALL)
match = pattern.match(response)
if match:
subText = match.group(1)
temp = re.compile(’.?temp="(.?)"’).match(subText).group(1)
return int(temp)
else:
system.gui.errorBox(“Yahoo weather service changed”)
return -1
[/code]
[code]And then you could use this expression to bind a property value to the weather:
runScript(“app.weather.getTempAt(‘95818’)”, 15000)
… This would bind a property to the temperature in sunny Sacramento, CA, and would refresh itself every 15 seconds.
[/code]
You can return the cursor code as a number if you add the parenthesis so that you’re actually calling the function instead of referring to the function object itself…