Tyl*_*ner 5 user-interface kivy
我正在为我正在创建的应用程序设计一个主菜单,但我似乎无法弄清楚如何在 kivy 中为盒子布局设置边框,有没有办法做到这一点?如果是的话有人可以帮忙。我尝试使用 canvas.before 并与矩形接壤,但这不起作用。
<MainMenuWindow>:
id: Main_Menu_window ## setting the id to Login_window
BoxLayout: ## whole screen
orientation: 'horizontal'
BoxLayout: ## left hand side 1/3
canvas.before:
Color:
rgba: 0, 0, 0, 1
Line:
width:
rectangle: self.x, self.y, self.width, self.height
orientation: 'vertical' ## setting orientation of the screen to vertical
size_hint_x: 1/3 ## setting size of box to 1/3 of the screen
canvas.before:
Color: ## just for debugging reasons
rgba: (255/255,255/255,255/255, 1) ## setting colour
Rectangle:
size: self.size ## setting size to the size of the box layout
pos: self.pos ## setting position to the position of the box layout
Run Code Online (Sandbox Code Playgroud)
ABoxLayout尝试通过为每个子进程分配共享来使用其所有可用空间。由于您的内部BoxLayout是外部的唯一子级BoxLayout,因此它将分配外部的整个空间BoxLayout。BoxLayout因此,您可以通过调整外部的大小BoxLayout或显式设置size内部的BoxLayout(使用)来控制内部的大小size_hint: None, None。
因此,这是一种使内部宽度BoxLayout达到屏幕宽度三分之一的方法:
<MainMenuWindow>:
id: Main_Menu_window ## setting the id to Login_window
BoxLayout: ## whole screen
orientation: 'horizontal'
BoxLayout: ## left hand side 1/3
canvas.before:
Color:
rgba: 1, 0, 0, 1
Line:
width: 20
rectangle: self.x, self.y, self.width, self.height
orientation: 'vertical' ## setting orientation of the screen to vertical
Label: ## middle third
text: 'Abba'
Label: ## right third
text: 'Dabba'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3864 次 |
| 最近记录: |