Jul-12-2019, 09:48 PM
Hi,I'm still confuse how multiple class interact between eachother, undestanding why in the following code, you can create a line but not delete it would help.
When I click butB, nothing happens, could anyone tell me why ? Thanks
When I click butB, nothing happens, could anyone tell me why ? Thanks
from tkinter import * class FaceDom(object): def __init__(self, can): self.can =can self.redline=self.can.create_line(10, 10, 90, 90, fill ='red',width=5) class Projet(Frame): def __init__(self, larg, haut): Frame.__init__(self) self.larg, self.haut = larg, haut self.can = Canvas(self, bg='dark green', width =larg, height =haut) self.can.pack() bList = [("ligne", self.butA),("Delete",self.butB)] for b in bList: Button(self, text =b[0], command =b[1]).pack() self.pack() def butA(self): self.x=FaceDom(self.can) def butB(self): self.can.delete(self.x) Projet(100, 100).mainloop()