[Tutor] Tkinter checkbutton

Phil phillor9 at gmail.com
Thu Feb 24 17:30:01 EST 2022


On 24/2/22 21:25, Alan Gauld via Tutor wrote:

> def f():
> 	if cb['selectcolor'] != 'red':
> 		cb['selectcolor'] = 'red'
> 	else: cb['selectcolor'] = 'white'

I did something like that but, for some reason, it didn't occur to me 
change the colour back to white after the checkbutton was deselected. 
What a dill!


> I think the wording is misleading. I think it means
> when the colour is set by the programmer not by the user.
> But the default is definitely white, on Linux at least.

I also use Linux and the desk top environment is XFCE which is built on 
GTK so the default tk widgets have a native look. I only have one 
application that use a checkbutton and it shows the indicator box to be 
larger than the checkbutton that I have created using ttk. The buttons 
look the same but not the checkbutton. I suppose It's possible that this 
application wasn't built with tkinter.

Getting back to ttk. The theme 'alt' closely matches the native look and 
so I thought I'd have a play with the other themes. I like the look of 
'clam'. Unfortunately, I didn't get past the first step:

 >>> import tkinter as ttk
 >>>
 >>> style = ttk.Style()
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
AttributeError: module 'tkinter' has no attribute 'Style'
 >>>

No doubt this is a dummy's error.

-- 

Regards,
Phil



More information about the Tutor mailing list