Just another WordPress site
kv language designing with anchorlayout
(original posted: 2012)
When designing a Kivy menu with the kv language I run into troubles with the anchorlayout object.
It seems that you need to put every object inside a achorlayout which itself is part of a anchorlayout.
Sounds a bit vague so an example should do:
AnchorLayout: id: topmenu anchor_x: 'center' anchor_y: 'top' BoxLayout: orientation: 'horizontal' AnchorLayout: anchor_x: 'left' anchor_y: 'top' padding: 8 Button: id: infobutton size: (48, 48) size_hint: None, None background_normal: 'info_button.png' background_down: 'info_button.png' on_press: root.on_button_clicked("info") AnchorLayout: anchor_x: 'center' anchor_y: 'top' padding: 8 BoxLayout: padding: 0 spacing: 4 size: (300, 48) size_hint: None, None orientation: 'horizontal' AnchorLayout: anchor_x: 'center' anchor_y: 'top' Button: size: (48, 48) size_hint: None, None background_normal: 'star1.png' on_press: root.on_button_clicked("star1") AnchorLayout: anchor_x: 'center' anchor_y: 'top' Button: size: (48, 48) size_hint: None, None background_normal: 'star1.png' on_press: root.on_button_clicked("star2") AnchorLayout: anchor_x: 'right' anchor_y: 'top' padding: 8 Button: id: quitbutton size: (48, 48) size_hint: None, None background_normal: 'quit_button.png' background_down: 'quit_button_ro.png' on_press: root.on_quit_button_clicked()
Leave a Reply
You must be logged in to post a comment.