Script Modules and Property Bindings

I have a script that updates both the data and the columnAttributesData of a table, among other things. Because I’m setting multiple values with the same script, I can’t simply return a value but have to set it through the script itself.

As it is right now, I have to both link the location of the triggering property as well as type out the name of the window (property bindings don’t seem to be able to see the window’s name). I’d like to make the whole process a bit more efficient by having the calling property’s and the window’s names be automatically generated within the script.

Am I wasting my time trying to find a solution to my problem or is there something I’ve overlooked?

Essentially, what I want to get to is this:
Exception: Error executing expression binding on
Window.Root Container.Button.text
caused by ExpressionException: Error executing script for runScript() expression:app.testing.test()
caused by Traceback (most recent call last):
File “expression:runScript”, line 1, in
File “module:testing”, line 16, in test
ZeroDivisionError: integer division or modulo by zero
But I’m not sure how to get that data from within the script.

Do you remind posting your app.testing.test() script? Also, since you’re binding to a text property, you need to return a string from that script, is test() returning a string?

It was supposed to fail, the entirety of app.testing was:

def test(): 1/0

What I’m trying to get to with the actual script is the “Window.Root Container.Button.text” returned at the beginning of the exception. How can I get this path from within the script module?

Currently I’m relying on this secondary script to get the source, but I was hoping there is an easier way to find the location of the calling property, since the exception handler is able to do it. It would save me a lot of time by not having to retype the window name and the property’s source every time because I don’t have the option of quickly doing this through xml.

def Source(win,src,parent=0): import system srcLen = len(src) if parent < 0 or parent+1 > srcLen: parent = 0 try: attributeData = system.gui.getWindow(str(win)).rootContainer except: return for x in range(srcLen-parent): if x == srcLen-1: attributeData = getattr(attributeData,src[x]) else: attributeData = attributeData.getComponent(src[x]) return attributeData

There is currently no way to reference from a script which property called it. You will have to pass a parameter in the function call, or use your current solution.