-
Notifications
You must be signed in to change notification settings - Fork 52
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
local variable 'target' referenced before assignment #268
Comments
Hello, I agree about better argument checking, unfortunately there are probably many functions in 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: https://github.com/ragardner/tksheet/wiki/Version-7#getting-cell-properties If you're using an older version then It might be better to just get the internal The {
(0, 0): {
"highlight": Highlight(
bg="light blue",
fg="black",
end=False,
)
}
} You could check if a cell is highlighted very quickly by doing e.g. (row, column) in my_sheet.MT.cell_options and "highlight" in my_sheet.MT.cell_options[(row, column)] Or you could iterate over the Other dicts that hold similar info: # all int keys
my_sheet.MT.row_options
my_sheet.MT.col_options
my_sheet.RI.cell_options
my_sheet.CH.cell_options Let me know if something isn't working with the above Kind regards |
Thank you. Yes, Version: 7.3.4 |
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: