tareksander / termux-gui-python-bindings

A Python library to interact with the Termux:GUI plugin
https://tareksander.github.io/termux-gui-python-bindings/index.html
Mozilla Public License 2.0
99 stars 7 forks source link

Checkbox view.checked does not return the state of the checkbox #5

Closed compilebunny closed 9 months ago

compilebunny commented 10 months ago
thescreen = tg.Activity(connection,canceloutside=False)
layout = tg.LinearLayout(thescreen, horizdivide)

testcheckbox = tg.Checkbox(thescreen,"speak",layout,False)

testbutton = tg.Button(thescreen, "configuration", layout)
testbutton.setlinearlayoutparams(0)
testbutton.setheight(tg.View.WRAP_CONTENT)

for eventmanager in connection.events():

    if eventmanager.type == tg.Event.click and eventmanager.value["id"] == testbutton:
        print (f"test checkbox state: {testcheckbox.checked}")

testcheckbox.checked does not change according to whether the checkbox is checked or not. In the example above, it always returns false.

tareksander commented 9 months ago

You have to call handleevent() on the checkbox with every event so it can filter out its checked events.