我如何以kivy向后发送图像?

时间:2018-02-01 05:45:42

标签: python image widget kivy

我正在尝试使用python和kivy为我的程序添加背景图像。我该怎么做呢?这是我到目前为止所拥有的。

我的.kv文件

BoxLayout:
    Image:
        size_hint: None, None
        source: 'pexels-photo-127673.jpeg'
        pos: self.pos
        size: self.size
    Button:
        size_hint_y: None
        height: "48dp"
        text: "Button normal"
    Button:
        size_hint_y: None
        height: "48dp"
        text: "Button down"
        state: "down"
    Button: 
        size_hint_y: None
        height: "48dp"
        text: "Button disabled"
        disabled: True
    Button:
        size_hint_y: None
        height: "48dp"
        text: "Button down disabled"
        state: "down"
        disabled: True

和我的python文件:

from kivy.app import App
from kivy.uix.widget import Widget

class ImageBackground(Widget):
    pass

class customwidget(App):
    pass

if __name__ == "__main__":
    customwidget().run()

1 个答案:

答案 0 :(得分:1)

add_action( 'save_post', 'save_details', 100); function save_details( $post_id ) { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return $post_id; } update_post_meta( $post_id, "mycustomfields_bookname", $_POST["mycustomfields_bookname"] ); update_post_meta( $post_id, "mycustomfields_youtubeid", $_POST["mycustomfields_youtubeid"] ); } 是一个小部件,因此您将其放在Image的一行中,而不是它的背景。您必须使用画布指令。使用BoxLayout指令和source属性设置图像:

Rectangle