【发布时间】:2019-10-20 17:28:23
【问题描述】:
我正在尝试使用 KivyMD 构建三个选项卡,但是当我向每个 MDTabsBase 添加内容时,内容总是占用相同的空间。我尝试了很多改变它的大小,所以内容占据了整个盒子,但只是不起作用。
下面是内容的样子:
还有代码:
Screen:
name: 'itemscad_food'
BoxLayout:
id: boxcad
orientation: 'vertical'
MDToolbar:
id: toolcad
title: "Item Register"
md_bg_color: app.theme_cls.primary_color
anchor_title: 'justify'
left_action_items: [['menu-left', lambda x: app.back_button()]]
BoxLayout:
id: tabox
orientation: 'vertical'
MDTabs:
id: itemstab
tab_display_mode: 'text'
MDTabsBase:
id: ingr_tab
name: 'ingredients'
text: "Ingredientes"
MDTabsBase:
id: prod_tab
name: 'products'
text: "Products"
MyLabel:
text: 'Strawberry Cake'
MyLabel:
text: 'Chocolate Cake'
MDTabsBase:
id: pack_tab
name: 'packs'
text: "Pacotes"
是的,我只为此使用 KV 语言。我正在上面构建大部分应用程序的布局,到目前为止一切都很好,除了这个:/
我也尝试过另一种方式:
- 与 MDTabs 类分开构建选项卡内容,但这样我似乎无法找到为每个选项卡制作不同内容的方法。
这是另一种方式的样子:
还有代码:
Screen:
name: 'itemscad_food'
BoxLayout:
id: boxcad
orientation: 'vertical'
MDToolbar:
id: toolcad
title: "Item Register"
md_bg_color: app.theme_cls.primary_color
anchor_title: 'justify'
left_action_items: [['menu-left', lambda x: app.back_button()]]
BoxLayout:
id: tabox
orientation: 'vertical'
MDTabs:
id: itemstab
tab_display_mode: 'text'
MDTabsBase:
id: ingr_tab
name: 'ingredients'
text: "Ingredientes"
MDTabsBase:
id: prod_tab
name: 'products'
text: "Products"
MDTabsBase:
id: pack_tab
name: 'packs'
text: "Pacotes"
FloatLayout:
BoxLayout:
id: listbox
size_hint_y: None
height: boxcad.height - (toolcad.height + itemstab.tab_bar_height)
orientation: 'vertical'
ScrollView:
do_scroll_x: False
MDList:
OneLineRightIconListItem:
text: 'Strawberry Cake'
MyListDeleteIcon:
icon: 'trash-can'
OneLineRightIconListItem:
text: 'Chocolate Cake'
MyListDeleteIcon:
icon: 'trash-can'
OneLineRightIconListItem:
text: 'Vanilla Cake'
MyListDeleteIcon:
icon: 'trash-can'
...
谁能给我一些想法?
对于任何错误,我深表歉意,因为我仍然习惯于编码 xD
还是谢谢!!!
【问题讨论】:
标签: python kivy kivy-language