0
我試圖做一個kivy程序與圖像做什麼(打印按摩),但它不起作用。 我甚至沒有收到錯誤信息,我得到的只是一個黑屏。 看起來程序打開,但圖像不顯示。使用kivy圖像像按鈕
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.widget import Widget
from kivy.core.window import Window
from kivy.clock import Clock
from kivy.animation import Animation
from kivy.properties import ListProperty
from kivy.properties import NumericProperty
root_widget = Builder.load_string('''
<Root>:
canvas.before:
Color:
rgba: 1, 1, 1, 1
Knopf:
pos: 400, 100
BILD1:
pos: root.Width/4, root.Height/4
BILD2:
pos: root.Width/2, root.Height/4
BILD3:
pos: root.Width/4, root.Height/2
BILD4:
pos: root.Width/2, root.Height/2
<Knopf>:
Image:
pos: root.pos
id: my_image
source: 'bestatigung.png'
<BILD1>:
Image:
pos: root.pos
id: pic1
source: 'Bild1.png'
<BILD2>:
Image:
pos: root.pos
id: pic2
source: 'Bild2.png'
<BILD3>:
Image:
pos: root.pos
id: pic3
source: 'Bild3.png'
<BILD4>:
Image:
pos: root.pos
id: pic4
source: 'Bild4.png'
''')
class Root(Widget):
pass
class Knopf(Widget):
Width = NumericProperty(Window.width)
Height = NumericProperty(Window.height)
velocity = ListProperty([1, 0])
def __init__(self, **kwargs):
super(Knopf, self).__init__(**kwargs)
Clock.schedule_interval(self.Update, 1/60.)
def Update(self, *args):
pass
def on_touch_down(self, touch):
if self.collide_point(*touch.pos):
print 'es geht'
class BILD1(Knopf):
def on_touch_down(self, touch):
if self.collide_point(*touch.pos):
print 'es geht'
class BILD2(Knopf):
def on_touch_down(self, touch):
if self.collide_point(*touch.pos):
print 'es geht'
class BILD3(Knopf):
def on_touch_down(self, touch):
if self.collide_point(*touch.pos):
print Window.width
class BILD4(Knopf):
def on_touch_down(self, touch):
if self.collide_point(*touch.pos):
print Window.height
class app(App):
def build(self):
return root_widget
if __name__ == "__main__":
app().run()