jeudi 4 juin 2020

How to hide simple Checkbutton from screen when using selectimage in Tkinter?

I'm making a gui application in which I want to use checkboxes (checkbuttons in tkinter). I'd don't really like the design of the simple checkbuttons (and I don't want to use tkk) so I decided to use images from the internet. I have a selected.png, and a deselected.png. When assign them to my Checkbutton they appear, but the original simple checkbox doesn't dissapear. Here is a Screenshot from the window, so you can get a better understanding of what I'm talking about.

...
deselect_image = PhotoImage(file='deselected.png')
select_image = PhotoImage(file='selected.png')

classic = Checkbutton(window, font = ('Courier', 10), image = deselect_image, text = " Classic theme", selectimage = select_image, compound = 'left', variable = theme_classic, bg = "#FFFFFF", command = lambda: select_theme("classic"))
classic.grid(row = 5, column = 1, sticky = "w")

blue = Checkbutton(window, font = ('Courier', 10), image = deselect_image, text = " Dark Blue theme", selectimage = select_image, compound = 'left', variable = theme_blue, bg = "#FFFFFF", command = lambda: select_theme("blue"))
blue.grid(row = 6, column = 1, sticky = "w")

black = Checkbutton(window, font = ('Courier', 10), image = deselect_image, text = " Black theme", selectimage = select_image, compound = 'left', variable = theme_black, bg = "#FFFFFF", command = lambda: select_theme("black"))
black.grid(row = 7, column = 1, sticky = "w")
...



Aucun commentaire:

Enregistrer un commentaire