-
Notifications
You must be signed in to change notification settings - Fork 54
How to filter data and highlight discontinuous cells? #272
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
Comments
The second situation could be solved by highlighting cells one by one, but how can I solve the first problem? There is a simple example below:
How to get cells that column A is "1" (which result in A1 and A3) quickly? (If doing it through get the whole table and iterate them everytime, it seems too tedious.) Would you like to give some advice? @ragardner Thanks! |
Hello, I can't think of any way except iteration in this case, if I had to make this library again today I would probably choose a different data structure rather than a list of lists to save time iterating when there are a lot of empty cells. If your table doesn't change you could save the cell coordinates in a variable such as a from tksheet import Sheet
import tkinter as tk
import random
x = [1, 2]
class demo(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self.grid_columnconfigure(0, weight=1)
self.grid_rowconfigure(0, weight=1)
self.sheet = Sheet(
self,
data=[[random.choice(x) for _ in range(2)] for _ in range(10)],
)
self.sheet.enable_bindings()
self.sheet.popup_menu_add_command("Get cells", self.get_cells)
self.sheet.grid(row=0, column=0, sticky="nswe")
def get_cells(self):
# cell coordinates as a set
self.cells_as_set = {
(rn, 0) for rn, row in enumerate(self.sheet.data) if row[0] == 1
}
print(self.cells_as_set)
# cell coordinates as a generator
self.cells_as_generator = (
(rn, 0) for rn, row in enumerate(self.sheet.data) if row[0] == 1
)
app = demo()
app.mainloop() Let me know if this doesn't help your situation |
Recording cells coordinates is certainly feasible. I will use this method to meet the need currently. Thank you for your solution and I have to say that But I also wonder how dropdown box filter data? Is it do the similar iteration? |
Hello, is there any way to achieve those two effect?
span
). For example, after filtering data(just like the above situation), I got two cells(A1 and A6), then I need to change their background into green.Thanks!
The text was updated successfully, but these errors were encountered: