Tkinter颜色名称到颜色对象 [英] Tkinter color name to color object

查看:75
本文介绍了Tkinter颜色名称到颜色对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以某种方式修改小部件的颜色,例如,使其更暗,更绿色以使其反转。
窗口小部件的颜色是按名称给出的,例如兰花4
如何从颜色名称字符串中获取RGB值?

I need to modify a widget's color in some way, for example, to make it darker, greener, to invert it. The widget's color is given by name, for example, 'orchid4'. How do I get RGB values from a color name string?

推荐答案

您应该尝试以下方法:

In [31]: rgb = button.winfo_rgb("orchid4")

In [32]: rgb
Out[32]: (35723, 18247, 35209)

其中 button 是小部件对象的名称。

where button is the name of your widget object.

这篇关于Tkinter颜色名称到颜色对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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