I dont understand root['bg'] = 'red' where root is a tkinter.Tk object

ast nomail at invalid.com
Mon Nov 17 08:32:01 EST 2014


Hello,

import tkinter
root = tkinter.Tk()

Let's see all attributes of root:

>>> root.__dict__
{'master': None, 'children': {}, '_tclCommands': ['tkerror', 'exit', '13825848destroy'], 'tk': 
<tkapp object at 0x02949C28>, '_tkloaded': 1}

Now we change the background color using following command:
>>> root['bg'] = 'red'

I am wondering what 'bg' is for object root. Is it an attribute ?

>>> root.__dict__
{'master': None, 'children': {}, '_tclCommands': ['tkerror', 'exit', '13825848destroy'], 'tk': 
<tkapp object at 0x02949C28>, '_tkloaded': 1}

No, 'bg' is not in root attribute's list. So what is it ?

Thx





More information about the Python-list mailing list