def refresh_plots_menu(self): plots_menu = self['Plots'] plots_menu.delete(0, 'end') # create menu entries, and get list of categories entries = KeyedList( ) # keep the order of plotgroup_templates (which is also KL) categories = [] for label, plotgroup in plotgroups.items(): entries[label] = PlotsMenuEntry(plotgroup) categories.append(plotgroup.category) categories = sorted(set(categories)) # The Basic category items appear on the menu itself. assert 'Basic' in categories, "'Basic' is the category for the standard Plots menu entries." for label, entry in entries: if entry.plotgroup.category == 'Basic': plots_menu.add_command(label=label, command=entry.__call__) categories.remove('Basic') plots_menu.add_separator() # Add the other categories to the menu as cascades, and the plots of each category to # their cascades. for category in categories: category_menu = ControllableMenu(plots_menu, tearoff=0) plots_menu.add_cascade(label=category, menu=category_menu) # could probably search more efficiently than this for label, entry in sorted(entries): if entry.plotgroup.category == category: category_menu.add_command(label=label, command=entry.__call__) plots_menu.add_separator() plots_menu.add_command( label="Help", command=(lambda x=plotting_help_locations: self.open_location(x)))
def refresh_plots_menu(self): plots_menu = self['Plots'] plots_menu.delete(0,'end') # create menu entries, and get list of categories entries=OrderedDict() # keep the order of plotgroup_templates (which is also KL) categories = [] for label,plotgroup in plotgroups.items(): entries[label] = PlotsMenuEntry(plotgroup) categories.append(plotgroup.category) categories = sorted(set(categories)) # The Basic category items appear on the menu itself. assert 'Basic' in categories, "'Basic' is the category for the standard Plots menu entries." for label,entry in entries.items(): if entry.plotgroup.category=='Basic': plots_menu.add_command(label=label,command=entry.__call__) categories.remove('Basic') plots_menu.add_separator() # Add the other categories to the menu as cascades, and the plots of each category to # their cascades. for category in categories: category_menu = ControllableMenu(plots_menu,tearoff=0) plots_menu.add_cascade(label=category,menu=category_menu) # could probably search more efficiently than this for label,entry in entries.items(): if entry.plotgroup.category==category: category_menu.add_command(label=label,command=entry.__call__) plots_menu.add_separator() plots_menu.add_command(label="Help",command=(lambda x=plotting_help_locations: self.open_location(x)))