[英]Displaying an image over multiple buttons - kivy
I want to display a single image over multiple different buttons (as shown in the picture: https://i.stack.imgur.com/BQ99R.jpg )我想在多个不同的按钮上显示单个图像(如图所示: https : //i.stack.imgur.com/BQ99R.jpg )
When I try to do so, the image gets covered by the buttons and hidden in the background.当我尝试这样做时,图像被按钮覆盖并隐藏在背景中。
What I want to know is that is this even possible in kivy?我想知道的是,这在 kivy 中甚至可能吗? If yes, where do I define the image, in the label or button?如果是,我在哪里定义图像,在标签或按钮中?
This code:这段代码:
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.lang import Builder
Builder.load_string("""
<Base>:
GridLayout:
cols: 2
size_hint: 1, 1
Button:
text: "Button 1"
on_press: print(self.text)
Button:
text: "Button 2"
on_press: print(self.text)
Button:
text: "Button 3"
on_press: print(self.text)
Button:
text: "Button 4"
on_press: print(self.text)
Image:
source: 'wolf.png'
""")
class Base(FloatLayout):
def __init__(self, **kwargs):
super(Base, self).__init__(**kwargs)
class SampleApp(App):
def build(self):
return Base()
if __name__ == "__main__":
SampleApp().run()
Of course you have to provide an image yourself ;o)当然,您必须自己提供图像;o)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.