我正在尝试设置图像的大小,这是TabbedPanel的子项。
如何增加添加图像的大小(如上所示,它很小)并使其响应任何屏幕调整大小事件。以下是我的代码段。
季
TabbedPanel:
do_default_tab: False
tab_height:20
tab_width: self.parent.width / 4
TabbedPanelItem:
text: "ONE"
Image:
src: "img.jpg"
size: 400, 500
allow_stretch: True
keep_ratio: True
TabbedPanelItem:
text: "TWO"
Image:
src: " "
size: 400, 500
allow_stretch: True
keep_ratio: True
图像小部件是否应该包含在另一个布局中?谢谢你的时间。
有关详细信息,请参阅示例。
src:
替换source:
。size: 400, 500
from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.lang import Builder
Builder.load_string("""
<Test>:
do_default_tab: False
tab_height:20
tab_width: self.width / 4
TabbedPanelItem:
text: "ONE"
Image:
source: "brown-bear-150x150.jpg"
allow_stretch: True
keep_ratio: True
TabbedPanelItem:
text: "TWO"
Image:
source: "grizzly-bear-150x150.jpg"
allow_stretch: True
keep_ratio: True
TabbedPanelItem:
text: 'THREE'
Image:
source: "giant-panda-150x150.jpg"
allow_stretch: True
keep_ratio: True
TabbedPanelItem:
text: 'FOUR'
Image:
source: "polar-bear-150x150.jpg"
allow_stretch: True
keep_ratio: True
""")
class Test(TabbedPanel):
pass
class TabbedPanelApp(App):
def build(self):
return Test()
if __name__ == '__main__':
TabbedPanelApp().run()