Python Forum
[Tkinter] Delete an object created from another class
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Delete an object created from another class
#3
Thanks, I don't understand yet. So if I don't add "self.readlin=..", how can it be deleted ?

from tkinter import *

class FaceDom(object):
	def __init__(self, can):
		self.can =can
		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)
		print(self.x)

	def butB(self):
		self.can.delete(self.x)
		
Projet(100, 100).mainloop()
Reply


Messages In This Thread
RE: Delete an object created from another class - by alan9979 - Jul-12-2019, 11:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter moving an class object with keybinds gr3yali3n 5 3,380 Feb-10-2021, 09:13 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020