I am having trouble figuring out how to update label text from a cascaded context menu. I've got the menu, but I can't get the labels to update with the text I want.
def main_context_menu(self):
self.mnu1 = tk.Menu(self.main_frme, tearoff=0)
self.mnu2 = tk.Menu(self.main_frme, tearoff=0)
self.mnu1.add_cascade(label='Overwrite Type', menu=self.mnu2)
self.mnu2.add_command(label='Bar Beer', command=self.context_menu_command)
self.mnu2.add_command(label='Store Beer', command=self.context_menu_command)
self.mnu2.add_command(label='Vapors', command=self.context_menu_command)
self.mnu2.add_command(label='Cigarettes', command=self.context_menu_command)
self.mnu2.add_command(label='Gas', command=self.context_menu_command)
self.mnu2.add_command(label='Misc.', command=self.context_menu_command)
self.mnu2.add_command(label='Bills', command=self.context_menu_command)
def do_context_menu1(self, event):
try:
self.mnu1.tk_popup(event.x_root, event.y_root)
finally:
self.mnu1.grab_release()
def do_context_menu2(self, event):
print('go')
self.c_type = event.widget
print(self.c_type)
def context_menu_command(self):
self.lblt.configure(text=self.c_type)
self.lblt = tk.Label(self.grid_frme, text=exp_type,
width=13, height=2, bg='white')
self.lblt.grid(row=self.row, column=2)
self.lblt.bind('<Button-3>', self.do_context_menu1)
self.mnu2.bind('<Button-1>', self.do_context_menu2)
That is the business end excerpt from a larger script. It's what I've tried. The labels don't update. What am I doing wrong? Sorry about the formatting. Copy and paste BS. I don't have the time to properly indent here.