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

sv_ttk incorrectly displays Checkbuttons in Tkinter #77

Closed
fieryWaters opened this issue Apr 13, 2023 · 2 comments
Closed

sv_ttk incorrectly displays Checkbuttons in Tkinter #77

fieryWaters opened this issue Apr 13, 2023 · 2 comments
Labels
invalid This doesn't seem right

Comments

@fieryWaters
Copy link

fieryWaters commented Apr 13, 2023

Here is a demo sketch of the issue. Essentially the problem is that it doesn't show that it's checked when it is. To see with and without the issue comment out the "sv_ttk.set_theme("dark")" near the bottom.

import sv_ttk
import tkinter as tk

class CustomWidget(tk.Frame):
    def __init__(self, master, text, row, column, *args, **kwargs):
        super().__init__(master, *args, **kwargs)

        # Label on the left
        self.label = tk.Label(self, text=text)
        self.label.grid(row=row, column=column, padx=5)

        # Checkbox in the middle
        self.var = tk.IntVar()
        self.checkbox = tk.Checkbutton(self, variable=self.var, command=self.update_led)
        self.checkbox.grid(row=0, column=1)

        # Status LED on the right
        self.led_size = 20
        self.canvas = tk.Canvas(self, width=self.led_size, height=self.led_size)
        self.canvas.grid(row=0, column=2, padx=5)
        self.led = self.canvas.create_oval(
            self.led_size / 2 - 5, self.led_size / 2 - 5,
            self.led_size / 2 + 5, self.led_size / 2 + 5,
            fill="red"
        )

    def update_led(self):
        color = "green" if self.var.get() else "red"
        self.canvas.itemconfig(self.led, fill=color)

root = tk.Tk()
sv_ttk.set_theme("dark")

custom_widget = CustomWidget(root, "Example Text", 0,0)
custom_widget.pack()

root.mainloop()
@fieryWaters
Copy link
Author

Note, setting the foreground color fixes the issue. sv_ttk should probably do this for checkboxes, when dark mode is enabled.

Fix:
self.checkbox = tk.Checkbutton(self, variable=self.var, command=self.update_led, fg='black')

@rdbende
Copy link
Owner

rdbende commented Apr 13, 2023

Hi!

The problem is that you're using plain Tkinter widgets, that aren't themable. Please replace them with tkinter.ttk ones, and it will work as expected.

@rdbende rdbende closed this as not planned Won't fix, can't repro, duplicate, stale Apr 15, 2023
@rdbende rdbende added the invalid This doesn't seem right label Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants