jarvisteach / appJar

Simple Tkinter GUIs in Python
http://appJar.info
Other
613 stars 68 forks source link

Check box menu item behaviour on check/un-check #466

Closed chrisw-thomas closed 6 years ago

chrisw-thomas commented 6 years ago

I define a set of check-boxes and provide a function to be called as part of the set-up e.g.: win.addMenuCheckBox( top_level, facet_name, menuFunction)

All the check boxes are un-ticked.

When I click on a check box the menuFunction function is called. When I query the state of the check-box using state=win.getMenuCheckBox( top_level, facet_name) I get the value True.

When I click on the check-box again to un-check it I get no call to the function. Is this operating as designed?

I was hoping to get a call when the check-box is un-checked so that I can go do some things.

For example, one of my check boxes is labelled 'All' and when someone selects it I want to go select all the check-boxes. When they un-select it I want to go un-select all the check-boxes for them.

jarvisteach commented 6 years ago

Hi @chrisw-thomas - this definitely doesn't sound right!

The function should be called every time the state of the checkbox changes...

I've just tested it on my MAC, and it seems to work fine:

from appJar import gui 

def checker(men):
    print('a', app.getMenuCheckBox("Checkers", "a"))
    print('b', app.getMenuCheckBox("Checkers", "b"))
    print('c', app.getMenuCheckBox("Checkers", "c"))
    print('d', app.getMenuCheckBox("Checkers", "d"))

with gui() as app:
    app.label('hello world')
    app.addMenuCheckBox("Checkers", "a", checker)
    app.addMenuCheckBox("Checkers", "b", checker)
    app.addMenuCheckBox("Checkers", "c", checker)
    app.addMenuCheckBox("Checkers", "d", checker)

What platform, version of python, and version of appJar are you using?

chrisw-thomas commented 6 years ago

Your code works on my platform.

I tweaked it to put "c" and "d" on a sub-menu (like they are in my application) and it still worked so it's got to be a bug in my code.

Thanks again Richard for such a quick reply,

Chris