我正在使用带有两个按钮的kivy BoxLayout,其中一个按钮是显示图像。使用水平方向时图像显示正常,但当我使用垂直方向时,它不会显示我的图像。 windows 10,python 3.6.4,kivy 1.10.0
.py文件:
from kivy.app import App
from kivy.core.window import Window
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.properties import ObjectProperty
from kivy.uix.stacklayout import StackLayout
from kivy.uix.boxlayout import BoxLayout
class ClickerScreen(Screen):
pass
class Manager(ScreenManager):
clicker_screen = ObjectProperty(None)
class ClickerApp(App):
def build(self):
return Manager()
if __name__=='__main__':
ClickerApp().run()
.kv文件:
#: import Window kivy.core.window.Window
<Manager>:
id: screen_manager
clicker_screen: clicker_screen
ClickerScreen:
id: clicker_screen
name: 'clicker'
manager: screen_manager
BoxLayout:
orientation: 'vertical'
Button:
background_color: 0,0,0,0
Image:
source: 'Images/button.png'
allow_stretch: False
keep_ratio: True
size: self.parent.size
Button: