For example, I’ve got a bunch of text objects of varying font families on a canvas, can I make some kind of call to iterate through these text objects and alter them?
Advertisement
Answer
You can get a list of all items on a canvas with the find_all()
method and then just list them:
JavaScript
x
7
1
def get_canvas_items(canvas):
2
item_list = canvas.find_all()
3
for item in item_list:
4
item_type = canvas.type(item) # e.g. "text", "line", etc.
5
item_keys = canvas.itemconfig(item).keys() # item options
6
# Do stuff...
7
Have a look at effbot: The Tkinter Canvas Widget for additional info on canvas.