2017-04-13 15 views
0

私は現在、GridLayout(2 * 2)のおかげで4ウィジェットに分割されたkivy(1.9.1)のアプリケーションをコーディングしています。私は上の2つを180度反転させて検索します。GridLayoutの中で '複雑な' Kivyウィジェットを回転させる

私はScatterLayoutでしようとしましたが、セルが右下にジャンプします... Scatterをウィジェットに挿入しようとしましたが、サイズを正しく設定する方法が見つかりません。

私はressources消費を最適化するために、次のコードを使用することをお読みください。

 canvas.before: 
      PushMatrix 
      Rotate: 
       angle: 180 
       origin: self.center 
     canvas.after: 
      PopMatrix 

それは一見動作しますが、「感動の領域は」残念ながら回転していません。

私が見つけた2つのだけのものは内部ScatterLayoutとAnchorLayoutを置くか、それぞれの子のために、以前のコードを使用しています...

私はよりよい解決策があると思いますが、私はできていませんしましたこれまでのところそれを見つけること。

私が実験したもののコンパイルのために以下の私の.kvファイルを見てください:

GridLayout: 
    cols: 2 
    rows: 2 

    AnchorLayout: 
     ScatterLayout: 
      center: self.parent.center 
      do_rotation: False 
      do_translation: False 
      do_scale: False 
      rotation: 180 

      GridLayout: 
       cols: 2 
       Button: 
        text: '1.1' 
       Button 
        text: '1.2' 

    Button: 
     text: '2' 

    GridLayout: 
     size: self.parent.size 
     center: self.parent.center 
     cols: 3 

     Button: 
      canvas.before: 
       PushMatrix 
       Rotate: 
        angle: 180 
        origin: self.center 
      canvas.after: 
       PopMatrix 
      text: '3.1' 

     Button: 
      canvas.before: 
       PushMatrix 
       Rotate: 
        angle: 180 
        origin: self.center 
      canvas.after: 
        PopMatrix 
      text: '3.2' 

     GridLayout: 
      size: self.parent.size 
      center: self.parent.center 
      rows: 2 

      canvas.before: 
       PushMatrix 
       Rotate: 
        angle: 180 
        origin: self.center 
      canvas.after: 
       PopMatrix 

      Button: 
       text: '3.3.1' 
      Button: 
       text: '3.3.2' 

    Button: 
     text: '4' 

の.pyファイルがそれ以外の何ものでもありません:中

from kivy.app import App 

class MainApp(App): 
    pass 

if __name__ == '__main__': 
    MainApp().run() 

感謝を前進。

答えて

0

はい、このためにスキャッターを使用できます。
試用:

from kivy.app import App 
from kivy.uix.gridlayout import GridLayout 
from kivy.lang import Builder 


KV = ''' 

MyGrid: 
    rows: 2 
    cols: 2 
    BoxLayout: 
     id: w1 
     Scatter: 
      size: w1.size 
      rotation: 180 
      do_rotation: False 
      Button: 
       size: w1.size 
       text: "Label1" 

    BoxLayout: 
     id: w2 
     Scatter: 
      size: w2.size 
      rotation: 180 
      do_rotation: False 
      Button: 
       size: w2.size 
       text: "Label2" 

    Button: 
     text: "Label3" 
    Button: 
     text: "Label4" 

''' 



class MyGrid(GridLayout): 
    pass 


class MyApp(App): 

    def build(self): 
     return Builder.load_string(KV) 


MyApp().run() 
関連する問題