def add_widget(self, widget, tab=None): if tab is None: if not hasattr(widget, 'tab'): raise Exception('Widget added without tab information') else: tab = widget.tab button = MTButton(label=tab, size=(120, 40)) button.tab_container = self button.connect('on_release', curry(self.select, tab)) self.topbar.add_widget(button) self.tabs[tab] = (button, widget)
def create_button(self,label,callback):#,flag=None,widget=None): _btn = MTButton(multiline=True, label=label, anchor_x='left', halign='left', padding_x=8) _btn.connect('on_press', callback) _max = 1 for _s in label.splitlines(): _l = len(_s) if _l > _max: _max = _l _btn.width = min(int(_max * pixels),100) return _btn