Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tk_obj_add_tag_and_delete_tag.py
- from tkinter import *
- root = Tk()
- root.geometry("300x100")
- root.title("tk Tagging" )
- canvas = Canvas(root)
- p_tag = canvas.create_oval(10, 10, 50, 50, fill="green")
- canvas.pack()
- # add tag "yes"
- canvas.addtag("yes", 'withtag', p_tag)
- # add tag "no"
- canvas.addtag("no", 'withtag', p_tag)
- # print all tags from p_tag
- print(canvas.gettags(p_tag))
- # delete tag "no"
- canvas.dtag(p_tag, "no")
- # print all tags from p_tag
- print(canvas.gettags(p_tag))
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement