Hello,
As most all are aware of, some of the tkinter widget attributes accept color. I'm thinking,
from a logical perspective, that there must be a way to determine programmatically if
that attribute is looking for a color.
for example tkinter Button activebackground
The following code gets most of what is needed:
Larz60+
Update: 8:14 P.M. EST
I don't like this, but guess I'll use a hack looking for foreground, background and whatever else uses a color value
I've been looking at the tkinter source, and I don't see anything that indicates the category of attribute expected. As
one final attempt, I'll examine the tk C code. It would be better to find some other way to do this.
Larz60+
As most all are aware of, some of the tkinter widget attributes accept color. I'm thinking,
from a logical perspective, that there must be a way to determine programmatically if
that attribute is looking for a color.
for example tkinter Button activebackground
The following code gets most of what is needed:
from tkinter import * class GetWidgetAttributes: def __init__(self, root): pass def getAttributes(self, widget): print('widget name: {}'.format(widget.widgetName)) keys = widget.keys() print('\nattributes') for key in keys: print('attr: {}, curval: {}, type: {}'.format(key, widget[key], type(widget[key]))) if __name__ == '__main__': root = Tk() gw = GetWidgetAttributes(root) # For Example, find all attributes of Tkinter Frame gw.getAttributes(Button())but not that activebackground or background are looking for a color.
Larz60+
Update: 8:14 P.M. EST
I don't like this, but guess I'll use a hack looking for foreground, background and whatever else uses a color value
I've been looking at the tkinter source, and I don't see anything that indicates the category of attribute expected. As
one final attempt, I'll examine the tk C code. It would be better to find some other way to do this.
Larz60+