On Sat, Jun 26, 2010 at 08:26:12AM +0200, zizou afix wrote: . . . > i try to organize my code. but i ' ve some problem with basic objet oriented > programing use. > if some one can show me the way to destroy my canvas with this structure. > thanks > > laurent > > ########################################################################## > from Tkinter import * > > class Root: > > def __init__(self, master): > myMenu = MyMenu(master) > myAccueil = MyAccueil(master) > > class MyAccueil(object): > def __init__(self, master): > > canvas = Canvas(master, width = 500, height = 500, bg='yellow' ) > canvas.pack(expand = YES, fill = BOTH) > > def delete(self): # my object problem > canvas.destroy() # is here > > > class MyMenu(object): > > def __init__(self, master): > self.menubar = Menu(master) > master.config(menu=self.menubar) > self.createmenubar(master) > > def createmenubar(self, master): > self.Fmenu = Menu(self.menubar, tearoff=0) > self.menubar.add_cascade(label="exec",menu=self.Fmenu) > # exec Content > self.Fmenu.add_command(label="bang", command=self.bang) > # Displays menubar > master.config(menu=self.menubar) > > def bang(self): # and > myAccueil.delete() # here > > root = Tk() > app = Root(root) > > root.mainloop() > ########################################################################## . . . I'm uncertain what you're trying to achieve; does the following help you approach your goal? ############################################################### from Tkinter import *
class Root: def __init__(self, master): myMenu = MyMenu(master) self.myAccueil = MyAccueil(master) class MyAccueil(object): def __init__(self, master): self.canvas = Canvas(master, width = 500, height = 500, bg='yellow' ) self.canvas.pack(expand = YES, fill = BOTH) def delete(self): # my object problem self.canvas.destroy() # is here class MyMenu(object): def __init__(self, master): self.menubar = Menu(master) master.config(menu=self.menubar) self.createmenubar(master) def createmenubar(self, master): self.Fmenu = Menu(self.menubar, tearoff=0) self.menubar.add_cascade(label="exec",menu=self.Fmenu) # exec Content self.Fmenu.add_command(label="bang", command=self.bang) # Displays menubar master.config(menu=self.menubar) def bang(self): # and app.myAccueil.delete() # here root = Tk() app = Root(root) root.mainloop() _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss