【发布时间】:2019-07-24 16:38:05
【问题描述】:
我试图让人们画一个时钟,当他们完成点击提交按钮时,它会截取屏幕截图。当我使用画布绘制时,我不能再使用按钮了。
有没有办法将按钮放置在画布顶部以使其仍可点击?
main.py
class Clock(Screen):
def on_touch_down(self, touch):
print(touch)
with self.canvas.before:
touch.ud["line"] = Line(points = (touch.x, touch.y), width = 2)
def on_touch_move(self, touch):
print(touch)
touch.ud["line"].points += (touch.x, touch.y)
def on_touch_up(self, touch):
print("released", touch)
时钟.kv
#:import utils kivy.utils
<Clock>:
FloatLayout
canvas.before:
Color:
rgba: .5, .5, .5, .5
Line:
width: 50
rectangle: self.x, self.y, self.width, self.height
Label:
pos_hint: {"top": .9, "center_x": .5}
size_hint: 1, .1
text: "Draw a clock."
font_size: 25
BoxLayout:
id: myexport
Button:
pos_hint: {"top": .1, "right": 1}
size_hint: .1, .1
text:
"Submit"
on_release:
app.change_screen("animals1")
myexport.export_to_png("Clock.png")
【问题讨论】:
标签: python python-3.x canvas kivy kivy-language