How to copy one tkinter object's options when creating another object of the same type?
As you can see, itemconfig
doesn't return just a dictionary of simple key/value pairs. For each option it will return a tuple made up of the following five items:
- option name
- option name for the option database
- option class for the option database
- the default value
- the current value
If you want to replicate all of the options, you need the last item returned for each option.
You can do that fairly easily with a dictionary comprehension:
config = canvas.itemconfig(canvas_tag_or_id)new_config = {key: config[key][-1] for key in config.keys()}canvas.create_rectangle(coords, **new_config)
For more information see