如何在Mac OS X上更改Tkinter按钮的前景色或背景色? [英] How to change the foreground or background colour of a Tkinter Button on Mac OS X?

查看:167
本文介绍了如何在Mac OS X上更改Tkinter按钮的前景色或背景色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在遍历Python编程中的Tkinter章节,遇到一个按钮的前景色和背景色不会改变的问题.我正在使用Python 2.6.1在Mac OS X 10.6系统上工作.标签的颜色会改变,但按钮的颜色不会改变.例如:

I've been working through the Tkinter chapters in Programming Python and encountered a problem where the foreground and background colours of a button will not change. I am working on a Mac OS X 10.6 system with Python 2.6.1. The colours of a label will change, but not the colours of a button. For example:

from Tkinter import *

Label(None, text='label', fg='green', bg='black').pack()
Button(None, text='button', fg='green', bg='black').pack()

mainloop()

在我的Mac系统上,标签的颜色会更改,但按钮的颜色不会更改.在使用Python 2.6.1的Windows系统上,标签和按钮的颜色都会改变.

On my Mac system the colours of the label change, but the colours of the button do not. On a Windows system with Python 2.6.1 the colours of both the label and button change.

任何人都知道出了什么问题吗?

Anyone know what is going wrong?

我已经检查了Interface Builder,看来在该工具中没有选项可以更改按钮的前景色或背景色.可以编辑标签的前景色和背景色.

I've checked Interface Builder and it appears that there is no option to change the foreground or background colour of a button in that tool. There is the ability to edit the foreground and background colours of a label.

Mac OS X渲染系统(Quartz?)可能仅不支持(轻松)更改按钮的fg和bg.

The Mac OS X rendering system (Quartz?) may just not support (easily) changing the fg and bg of a button.

推荐答案

我认为答案是Mac上的按钮根本不支持更改背景和前景色.如您所见,这不是Tk独有的.

I think the answer is that the buttons on the mac simply don't support changing the background and foreground colors. As you've seen, this isn't unique to Tk.

这篇关于如何在Mac OS X上更改Tkinter按钮的前景色或背景色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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