what is the best way to write tkinter menus? As toplevels or as frame
with Menubutton?
im doing like this
class MyWidget(Frame) :
def __init__(self, master=None): """ should this master be
parent? Because my first tought was that this is toplevel master than i
found that its not"""
Frame.__init__( self, master) # and this too than
self.config(wid th=200, height=200)
self.pack(fill= BOTH, expand=YES)
self.makeMenuBa r()
def makeMenuBar(sel f):
self.menubar = Menu(self.maste r)
self.master.con fig(menu=self.m enubar)
pulldown = Menu(self.menub ar, tearoff=0)
pulldown.add_co mmand(label='Ne w', command=self.ne w)
pulldown.add_co mmand(label='Op en', command=self.on Open)
pulldown.add_co mmand(label='Sa ve', command=self.sa ve)
pulldown.add_co mmand(label='Sa ve As', command=self.sa veas)
pulldown.add_se parator()
pulldown.add_co mmand(label='Ex it', command=self.on Exit)
self.menubar.ad d_cascade(label ='File', underline=0, menu=pulldown)
Please tell me is here anything that I should change.
with Menubutton?
im doing like this
class MyWidget(Frame) :
def __init__(self, master=None): """ should this master be
parent? Because my first tought was that this is toplevel master than i
found that its not"""
Frame.__init__( self, master) # and this too than
self.config(wid th=200, height=200)
self.pack(fill= BOTH, expand=YES)
self.makeMenuBa r()
def makeMenuBar(sel f):
self.menubar = Menu(self.maste r)
self.master.con fig(menu=self.m enubar)
pulldown = Menu(self.menub ar, tearoff=0)
pulldown.add_co mmand(label='Ne w', command=self.ne w)
pulldown.add_co mmand(label='Op en', command=self.on Open)
pulldown.add_co mmand(label='Sa ve', command=self.sa ve)
pulldown.add_co mmand(label='Sa ve As', command=self.sa veas)
pulldown.add_se parator()
pulldown.add_co mmand(label='Ex it', command=self.on Exit)
self.menubar.ad d_cascade(label ='File', underline=0, menu=pulldown)
Please tell me is here anything that I should change.
Comment