#anchorlayout.kv
#:import random random
Anchorlayout:
AnchorLayout:
size: root.width, root.height
#right, left, center
anchor_x: "left"
#bottom, top, center
anchor_y: "top"
BoxLayout:
size_hint: .33, .33
orientation: "horizontal"
spacing: "10dp"
Button:
text: "A1"
background_color: [random.random() for i in range(3)] + [1]
size_hint: .5, 1
Button:
text: "A2"
background_color: [random.random() for i in range(3)] + [1]
size_hint: .5, 1
AnchorLayout:
size: root.width, root.height
#right, left, center
anchor_x: "center"
#bottom, top, center
anchor_y: "top"
Button:
text: "B"
background_color: [random.random() for i in range(3)] + [1]
size_hint: .2, .2
AnchorLayout:
size: root.width, root.height
#right, left, center
anchor_x: "right"
#bottom, top, center
anchor_y: "top"
Button:
text: "C"
background_color: [random.random() for i in range(3)] + [1]
size_hint: .2, .2
AnchorLayout:
size: root.width, root.height
#right, left, center
anchor_x: "left"
#bottom, top, center
anchor_y: "center"
Button:
text: "D"
background_color: [random.random() for i in range(3)] + [1]
size_hint: .2, .2
AnchorLayout:
size: root.width, root.height
#right, left, center
anchor_x: "center"
#bottom, top, center
anchor_y: "center"
GridLayout:
cols: 2
rows: 2
spacing: "10dp"
size_hint: .33, .33
Button:
text: "E1"
background_color: [random.random() for i in range(3)] + [1]
size_hint: .5, .5
Button:
text: "E2"
background_color: [random.random() for i in range(3)] + [1]
size_hint: .5, .5
Button:
text: "E3"
background_color: [random.random() for i in range(3)] + [1]
size_hint: .5, .5
Button:
text: "E4"
background_color: [random.random() for i in range(3)] + [1]
size_hint: .5, .5
AnchorLayout:
size: root.width, root.height
#right, left, center
anchor_x: "right"
#bottom, top, center
anchor_y: "center"
Button:
text: "F"
background_color: [random.random() for i in range(3)] + [1]
size_hint: .2, .2
AnchorLayout:
size: root.width, root.height
#right, left, center
anchor_x: "left"
#bottom, top, center
anchor_y: "bottom"
Button:
text: "G"
background_color: [random.random() for i in range(3)] + [1]
size_hint: .2, .2
AnchorLayout:
size: root.width, root.height
#right, left, center
anchor_x: "center"
#bottom, top, center
anchor_y: "bottom"
Button:
text: "H"
background_color: [random.random() for i in range(3)] + [1]
size_hint: .2, .2
AnchorLayout:
size: root.width, root.height
#right, left, center
anchor_x: "right"
#bottom, top, center
anchor_y: "bottom"
BoxLayout:
size_hint: .33, .33
orientation: "vertical"
spacing: "10dp"
Button:
text: "I1"
background_color: [random.random() for i in range(3)] + [1]
size_hint: 1, .5
Button:
text: "I2"
background_color: [random.random() for i in range(3)] + [1]
size_hint: 1, .5
------------------
anchorlayout.py
from kivy.app import App
from kivy.uix.widget import Widget
class Anchorlayout(Widget):
pass
class AnchorlayoutApp(App):
pass
AnchorlayoutApp().run()
reference:
No comments:
Post a Comment