I need display checkbox as a value for entries in my TreeView.
Basically this:
In the example on the screenshot I use UTF-8 symbols ✅ and ☐ respectively. And it is somewhat OK, but there are couple issues.
First, "checked" and "unchecked" look differently (both size and shape) and I can't find stylistically matching checked/unchecked boxes in UTF-8. There are 2 version of "checked" though - ❎✅ - which genuinely surprises me why.
Second, the above doesn't work on Linux, i.e. the "unchecked" box is still shown, but instead of "checked" it shows empty space.
And last, when I "edit" the boolean cell, I put in-place ttk.Checkbutton
which looks different from both symbols. This discrepancy is less important though, the two above issues are more annoying.
I thought about using tkinter.PhotoImage
but it allows to put image only as an left-most icon for entire row, not as specific column value.
Any idea how to make it look nice and be cross-platform?
if it matters, MacOS irrelevant, need only Windows and Linux.
Try using unicode characters '\U00002610'
(unchecked) and '\U00002611'
(checked).
Sample code:
import tkinter as tk
UNCHECK = '\U00002610'
CHECKED = '\U00002611'
FNT = ('', 24)
root = tk.Tk()
root.config(bg='gray50')
tk.Label(root, text=UNCHECK, font=FNT, bg='gray50').pack(padx=100)
tk.Label(root, text=CHECKED, font=FNT, bg='gray50').pack(padx=100)
root.mainloop()
Result in Windows and Debian Linux: