You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having trouble getting the current cell color after I highlight it. I am trying to get cell options and ChatGPT is doing guesswork: highlighted_cells = self.sheet.get_cell_options("highlight", "table")
I know I'm using the module incorrectly due to the error, but if you could improve the error state to warn me that I've given get_cell_options a bad key, that would be helpful--in other words, please add bounds checking (such as an else case or wherever is appropriate to raise a KeyError that explains the issue) in:
Instead of allowing "UnboundLocalError: local variable 'target' referenced before assignment" maybe add an exception that leads me to the correct usage, such as:
else:
raiseKeyError("{} is not a valid canvas name.".format(repr(canvas)))
Regarding my actual problem of getting cell bg color, explain if that is possible or whether that would be a feature request. I am setting it via sheet.highlight_cells(row=row, column=column, bg='lightgreen')
The text was updated successfully, but these errors were encountered:
I agree about better argument checking, unfortunately there are probably many functions in Sheet() with the same issue at the moment. I will probably go over this at some point and see where i can improve things.
I will probably also improve the docs and remove the info on the older functions which are there for backwards compatibility but maybe I'm not so happy with.
To get cell properties/options, if you're using a version of tksheet >= 7.2.19 you can use these functions:
Thank you. Yes, highlight = my_sheet.MT.cell_options[(row, column)].get("highlight") if (row, column) in my_sheet.MT.cell_options else None works and if set, gets a Highlight (namedtuple apparently) with a bg attribute that is the color I set.
Uh oh!
There was an error while loading. Please reload this page.
I'm having trouble getting the current cell color after I highlight it. I am trying to get cell options and ChatGPT is doing guesswork:
highlighted_cells = self.sheet.get_cell_options("highlight", "table")
I know I'm using the module incorrectly due to the error, but if you could improve the error state to warn me that I've given get_cell_options a bad key, that would be helpful--in other words, please add bounds checking (such as an else case or wherever is appropriate to raise a KeyError that explains the issue) in:
Instead of allowing "UnboundLocalError: local variable 'target' referenced before assignment" maybe add an exception that leads me to the correct usage, such as:
Regarding my actual problem of getting cell bg color, explain if that is possible or whether that would be a feature request. I am setting it via
sheet.highlight_cells(row=row, column=column, bg='lightgreen')
The text was updated successfully, but these errors were encountered: