python - How to make TabbedPannel's tabs fill all horizontal space? -


i'm creating simple app interface using kivy , kv language. interface consists of search text input, button search confirmation , 'add' button. bellow this, there tabbedpanel app's contents:

#:import label kivy.uix.label #:import sla kivy.adapters.simplelistadapter  <menuscreen>:     anchorlayout:         anchor_x: 'left'         anchor_y: 'top'         boxlayout:             orientation: 'vertical'             boxlayout:                 orientation: 'horizontal'                 size_hint_y: 0.15                 textinput:                     text: 'search'                  button:                     size_hint_x: 0.2                     text: 'ok'                 button:                     size_hint_x: 0.2                     text: '+'             tabbedpanel:                 do_default_tab: false                  tabbedpanelitem:                     text: 'tab1'                     listview:                         orientation: 'vertical'                         adapter:                             sla.simplelistadapter(                             data=["item #{0}".format(i) in range(100)],                             cls=label.label)                 tabbedpanelitem:                     text: 'tab2'                     boxlayout:                         label:                             text: 'second tab content area'                         button:                             text: 'button nothing'                 tabbedpanelitem:                     text: 'tab3'                     rstdocument:                         text:                             '\\n'.join(("hello world", "-----------",                             "you in third tab.")) 

this design output:

kivy regular app interface

the tabbedpannel works way desire, want tabs fill horizontal space. instance, if use boxlayout buttons, expand using horizontal space, want it:

boxlayout:     orientation: 'horizontal'     size_hint_y: 0.1     button:         text: 'tab1'     button:         text: 'tab2'     button:         text: 'tab3' 

horizontal boxlayout buttons

is there way tune tabbedpannel tabbedpannelitems tabs can use horizontal space?

set tab_width property of tabbedpanel width divided number of tabs:

from kivy.app import app kivy.uix.tabbedpanel import tabbedpanel kivy.lang import builder  builder.load_string("""  <test>:     do_default_tab: false     tab_width: self.size[0]/len(self.tab_list)     tabbedpanelitem:         text: 'tab 1'     tabbedpanelitem:         text: 'tab2'      tabbedpanelitem:         text: 'tab3' """)  class test(tabbedpanel):     pass  class tabbedpanelapp(app):     def build(self):         return test()  if __name__ == '__main__':     tabbedpanelapp().run() 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -