def create_accordion_widget_list(self, treelist): acf = AccordionFrame(self.widgetlist) acf.grid(sticky=tk.NSEW) acf.bind('<<AccordionGroupToggle>>', self.on_widgetlist_group_toogle) #Default widget image: default_image = '' try: default_image = StockImage.get('22x22-tk.default') except StockImageException as e: pass #Start building widget tree selector roots = {} sections = {} for key, wc in treelist: root, section = key.split('>') #insert root if root not in roots: roots[root] = acf.add_group(root, root) #insert section if key not in sections: sectionacf = AccordionFrame(roots[root]) sectionacf.grid(sticky=tk.NSEW, padx='5 0') sectionacf.bind('<<AccordionGroupToggle>>', self.on_widgetlist_group_toogle) sectiongrp = sectionacf.add_group(key, section) sections[key] = AutoArrangeFrame(sectiongrp) sections[key].grid(sticky=tk.NSEW) #insert widget w_image = default_image try: w_image = StockImage.get('22x22-{0}'.format(wc.classname)) except StockImageException as e: pass #define callback for button def create_cb(cname): return lambda: self.on_add_widget_event(cname) b = ttk.Button(sections[key], text=wc.label, image=w_image, style='Toolbutton', command=create_cb(wc.classname)) tooltip.create(b, wc.classname) b.grid() #Expand prefered widget set hidews = 'tk' prefws = get_option('widget_set') if hidews == prefws: hidews = 'ttk' acf.group_toogle(hidews) self.widgetlist_sf.reposition()
def configure_widget_list(self): acf = AccordionFrame(self.widgetlist) acf.grid(sticky=tk.NSEW) acf.bind('<<AccordionGroupToggle>>', self.on_widgetlist_group_toogle) root_tagset = set(('tk', 'ttk')) #create unique tag set tagset = set() for c in builder.CLASS_MAP.keys(): wc = builder.CLASS_MAP[c] tagset.update(wc.tags) tagset.difference_update(root_tagset) treelist = [] for c in builder.CLASS_MAP.keys(): wc = builder.CLASS_MAP[c] ctags = set(wc.tags) roots = (root_tagset & ctags) sections = (tagset & ctags) for r in roots: for s in sections: key = '{0}>{1}'.format(r,s) treelist.append((key, wc)) #sort tags by label def by_label(t): return "{0}{1}".format(t[0], t[1].label) treelist.sort(key=by_label) #Default widget image: default_image = '' try: default_image = StockImage.get('22x22-tk.default') except StockImageException as e: pass #Start building widget tree selector roots = {} sections = {} for key, wc in treelist: root, section = key.split('>') #insert root if root not in roots: roots[root] = acf.add_group(root, root) #insert section if key not in sections: sectionacf = AccordionFrame(roots[root]) sectionacf.grid(sticky=tk.NSEW, padx='5 0') sectionacf.bind('<<AccordionGroupToggle>>', self.on_widgetlist_group_toogle) sectiongrp = sectionacf.add_group(key, section) sections[key] = AutoArrangeFrame(sectiongrp) sections[key].grid(sticky=tk.NSEW) #insert widget w_image = default_image try: w_image = StockImage.get('22x22-{0}'.format(wc.classname)) except StockImageException as e: pass #define callback for button def create_cb(cname): return lambda: self.on_add_widget_event(cname) b = ttk.Button(sections[key], text=wc.label, image=w_image, style='Toolbutton', command=create_cb(wc.classname)) tooltip.create(b, wc.classname) b.grid() #hide tk widget by default acf.group_toogle('tk') self.widgetlist_sf.reposition()
def configure_widget_list(self): acf = AccordionFrame(self.widgetlist) acf.grid(sticky=tk.NSEW) acf.bind('<<AccordionGroupToggle>>', self.on_widgetlist_group_toogle) root_tagset = set(('tk', 'ttk')) #create unique tag set tagset = set() for c in builder.CLASS_MAP.keys(): wc = builder.CLASS_MAP[c] tagset.update(wc.tags) tagset.difference_update(root_tagset) treelist = [] for c in builder.CLASS_MAP.keys(): wc = builder.CLASS_MAP[c] ctags = set(wc.tags) roots = (root_tagset & ctags) sections = (tagset & ctags) for r in roots: for s in sections: key = '{0}>{1}'.format(r, s) treelist.append((key, wc)) #sort tags by label def by_label(t): return "{0}{1}".format(t[0], t[1].label) treelist.sort(key=by_label) #Default widget image: default_image = '' try: default_image = StockImage.get('22x22-tk.default') except StockImageException as e: pass #Start building widget tree selector roots = {} sections = {} for key, wc in treelist: root, section = key.split('>') #insert root if root not in roots: roots[root] = acf.add_group(root, root) #insert section if key not in sections: sectionacf = AccordionFrame(roots[root]) sectionacf.grid(sticky=tk.NSEW, padx='5 0') sectionacf.bind('<<AccordionGroupToggle>>', self.on_widgetlist_group_toogle) sectiongrp = sectionacf.add_group(key, section) sections[key] = AutoArrangeFrame(sectiongrp) sections[key].grid(sticky=tk.NSEW) #insert widget w_image = default_image try: w_image = StockImage.get('22x22-{0}'.format(wc.classname)) except StockImageException as e: pass #define callback for button def create_cb(cname): return lambda: self.on_add_widget_event(cname) b = ttk.Button(sections[key], text=wc.label, image=w_image, style='Toolbutton', command=create_cb(wc.classname)) tooltip.create(b, wc.classname) b.grid() #hide tk widget by default acf.group_toogle('tk') self.widgetlist_sf.reposition()