【发布时间】:2017-02-01 12:43:54
【问题描述】:
文档提供了 an example 如何使用 DragBehaviour,只要我使用 pos 来指示小部件的位置,它就可以工作,但如果我使用 pos_hint 则不会:
from kivy.uix.label import Label
from kivy.app import App
from kivy.uix.behaviors import DragBehavior
from kivy.lang import Builder
kv = '''
<DragLabel>:
# Define the properties for the DragLabel
drag_rectangle: self.x, self.y, self.width, self.height
drag_timeout: 10000000
drag_distance: 0
FloatLayout:
DragLabel:
##################################
##### Comment this line and works!
pos_hint: {'x': 0.5, 'y':0.5}
size_hint: 0.25, 0.2
text: 'Drag me'
'''
class DragLabel(DragBehavior, Label):
pass
class TestApp(App):
def build(self):
return Builder.load_string(kv)
TestApp().run()
如何将pos_hint 与DragBehaviour 一起使用?它们不兼容是因为 Kivy 绑定属性的方式吗?
【问题讨论】:
标签: python kivy kivy-language