2016-02-29 35 views

回答

0

根據inclement的回答,我在分散佈局上創建了一個按鈕,它的點擊框正確設置。

from kivy.app import App 
from kivy.lang import Builder 

kv = ''' 
FloatLayout: 

    ScatterLayout: 
     size_hint: None, None 
     size: 200, 200 
     pos_hint: {'center_x': .5, 'center_y': .5} 

     rotation: 45 

     do_rotation: False 
     do_scale: False 
     do_translation: False 

     Button: 
      text: 'hello world' 
''' 


class RotationApp(App): 
    def build(self): 
     return Builder.load_string(kv) 

RotationApp().run() 

我使用了散點圖佈局而不是散點圖,因爲它將其大小傳遞給子窗口小部件。在這個例子中不需要do_x: False,因爲按鈕攔截觸摸事件,但如果我放置了標籤,它將會移動。

3

您可能會重寫其collide_point方法以通過轉換觸摸座標來解釋旋轉。

如果您使用小工具系統(例如將Button放在Scatter中),碰撞就會爲您照顧。