带有 bg、fg 指定的选定单选按钮中的点消失 [英] Dot in a selected radiobutton with bg, fg specified disappears

查看:23
本文介绍了带有 bg、fg 指定的选定单选按钮中的点消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

初学者问题:我正在尝试更改 GUI 的颜色,尤其是单选按钮的颜色.我需要反转颜色,所以黑色背景,白色文字.

Beginner question: I'm trying to change the colour of my GUI, particularly the radiobuttons. I need inverted colours, so black background, white text.

self.radiobuttonVariable = Tkinter.IntVar()
radiobutton1 = Tkinter.Radiobutton(self, text=u'E', variable = self.radiobuttonVariable, 
                                       bg='black', fg='white' activebackground='black', activeforeground='white', 
                                       value = 1, command = self.RadioSelect)
radiobutton1.grid(column=2, row=1, sticky='ES')

这看起来不错,但是当我按下按钮时,它的点只有在我按下它时才存在,一旦我松开它就会消失.变量不会改变,它保持在正确的值上,只是点消失了.当我删除颜色管理选项时,没有任何问题.有什么想法吗?

This looks just fine, but when I press the button, it's the dot is there only as long I'm pressing it, disappears as soon as I let it go. The variable doesn't change, it stays on the right value, just that the dot disappears. No issue whatsoever when I remove the colour-management options. Any ideas?

推荐答案

据我所知,指定前景(大概用于文本) 设置选定的点颜色".您可以设置元素的 selectcolor 属性来为单选按钮的背景"着色,以便您可以看到白点.

As far as I can tell, specifying the foreground (presumably for the text) also sets the selected "dot color". You can set the selectcolor attribute of the element to color the "background" of the radiobutton so that you can see the white dot.

例如,selectcolor='red' 在 Windows 中:

For example, selectcolor='red' in Windows:

请注意,手册页 表示着色所有 带有 selectcolor 的单选按钮(而不是仅选定的按钮)可能仅限 Windows:

Be aware that the manpage indicates that coloring all radio buttons with selectcolor (instead of only the selected button) may be Windows-only:

在 Windows 下,无论选择状态如何,此颜色都用作指示器的背景.

Under Windows, this color is used as the background for the indicator regardless of the select state.

话虽如此,我在 Python 2.7 和 3.3 下的 linux 中得到了相同的效果:

That being said, I got the same effect in linux under Python 2.7 and 3.3:

我只是用红色来区分 selectcolor 影响的小部件部分,您可能想要 selectcolor='black' 或稍微淡一点的东西来显示抑郁 selectcolor='#222222'(下):

I just used red to distinguish the part of the widget that selectcolor affected, you'd probably want selectcolor='black' or something a bit lighter to show the depression selectcolor='#222222' (below):

这篇关于带有 bg、fg 指定的选定单选按钮中的点消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆