Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reading TickOptionBox not working from change event function #422

Closed
pg-doceapower opened this Issue Mar 20, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@pg-doceapower
Copy link

pg-doceapower commented Mar 20, 2018

from the example below I can access the content of a tickOptionBox from the main thread but not in a function that is called on event

def tickOptionBox_has_changed(widgetFullName):
    print("DEBUG: widgetFullName=" + str(widgetFullName))
    try:
        optionBoxContent=app.getOptionBox(widgetFullName)
        print("DEBUG:optionBox content=" + str(optionBoxContent))
    except:
        print("DEBUG: ??? expected dictionary with option name and associated status http://appjar.info/pythonWidgets/#optionbox")
    
app = gui()
# feedback objects
myTitle="test"
options=["val1", "val2", "val3"]
optionsTicked=[False, False, False]
ent=app.addTickOptionBox(myTitle, options, row=1, column=1, colspan=1 )
app.setOptionBoxSticky(myTitle, "both")
for idx in range(len(optionsTicked)):
    print("idx=" + str(idx))
    app.setOptionBox(myTitle, options[idx], value=False, callFunction=False, override=True)#optionsTicked[idx]
#ent.customFieldWhoAmI = guiObjName
app.setOptionBoxSubmitFunction(myTitle, tickOptionBox_has_changed)
optionBoxContent=app.getOptionBox(myTitle)
print("DEBUG:optionBox content from main=" + str(optionBoxContent))

Console output

idx=0
idx=1
idx=2
DEBUG:optionBox content from main={'val3': False, 'val2': False, 'val1': False}
DEBUG:optionBox content from submit event=
DEBUG: widgetFullName=val2
DEBUG: ??? expected dictionary with option nama and assotiated status http://appjar.info/pythonWidgets/#optionbox

what would be the workaround?

@jarvisteach

This comment has been minimized.

Copy link
Owner

jarvisteach commented Mar 20, 2018

Interesting - this works fine on a regular option box, but not on a tick option box.

It looks like the tick option box is returning the item you ticked, rather than the name of the option box.

A workaround would be to use myTitle instead of widgetFullName - to get the values.
If there are multiple option boxes, link each one to a different change function, so you know where the change originated.

@jarvisteach jarvisteach added the bug label Mar 20, 2018

@jarvisteach jarvisteach added this to the 1.0 milestone Mar 20, 2018

@pg-doceapower

This comment has been minimized.

Copy link
Author

pg-doceapower commented Mar 20, 2018

jarvisteach added a commit that referenced this issue Mar 24, 2018

jarvisteach added a commit that referenced this issue Mar 24, 2018

Updated changeFunction on tickOptionBox #422
Previously ticking a tickOptionBox called changeFunction, passing the
item that was ticked.

It now passes the name of the optionBox.
@jarvisteach

This comment has been minimized.

Copy link
Owner

jarvisteach commented Mar 24, 2018

I've made a change, so this now returns the name of the optionBox, rather than the option being ticked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.