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

[Proposal] Checkbox onvalue/offvalue #124

Open
skedus opened this issue Jul 1, 2022 · 2 comments
Open

[Proposal] Checkbox onvalue/offvalue #124

skedus opened this issue Jul 1, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@skedus
Copy link

skedus commented Jul 1, 2022

Hi Ragardner,
I try to move from v5.3.2 to v5.4.0 but with recent changes this is not working for checkbox anymore for my application.
In fact it is because I wanted to put some checkbox with some values which are not boolean True/False or 0/1
(I found a dirty way of doing it with v5.3.2 but that will be better to have a tksheet way of doing it)

I build a proposal with a definition of onvalue and offvalue (defined in cell_option) instead editing the cell value itself like:
self.cell_options[(r, c)]['checkbox'] = {'check_function': check_function,
'state': state,
'checked': checked,
'onvalue': onvalue,
'offvalue': offvalue,
'text': text}

I put my modifications to tksheet here to get your point of view on that:
https://github.com/skedus/tksheet/tree/try_checkbox

with an example of used
https://github.com/skedus/tksheet/blob/try_checkbox/examples/example_checkbox_01.py

Tell me if it can be a way of doing it ?

@ragardner
Copy link
Owner

Hello,

Would you like to display your on / off values in the table or just have them stored in the sheet data?

@skedus
Copy link
Author

skedus commented Jul 4, 2022

Hi,
The on / off value indicate what is the data value in a column sheet data representing true for the checkbox or which value represent false for the checkbox.
Then when clicking on the checkbox the data is set in the cell sheet data by those values.

Example for checkbox on column 1:
self.data_header = ["val1", "val2"]
self.data = [
["this_is_true", "AAA1"],
["", "BBBB1" ],
["this_is_false", "CCCCC1"],
]

    # the creation could be like that
    checked = True if  value == "this_is_true" else False
    self.sheet.create_checkbox(row, col, checked=checked, onvalue="this_is_true", offvalue="this_is_false", redraw=True)

Do I answer to your question ?

@ragardner ragardner added the enhancement New feature or request label May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants