[Tkinter-discuss] problem of understanding objects
zizou afix
ziz.root at gmail.com
Sat Jun 26 08:26:12 CEST 2010
hi,
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()
##########################################################################
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20100626/eb0faef6/attachment-0001.html>
More information about the Tkinter-discuss
mailing list