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

查看:34
本文介绍了如何在 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天全站免登陆