我有一个手风琴布局,我试图弄清楚如何在Box Layouts中设置不同数量的小部件,并使它们与其他Box布局中的其他小部件保持相同的大小。
我想避免使用Float布局,因为它会花费更多时间,并且会认为应该有一种方法来使用框布局和大小提示等来实现这一点。
目前我有6个Box布局,其中每个都有一个网格布局,以适当地定位小部件,但是,在一些网格布局中,我希望窗口小部件比其他布局更少,这会导致窗口小部件填充剩余空间是否我提出了大小提示。
我尝试在网格布局中添加标签但没有内容,但它不会更改大小调整排列。如果我添加额外的文本输入小部件,它会调整以适应并与其他Box布局相同但不是我想要的。
内部较少小部件的前两个框/网格布局是我想要与其他框/网格布局相同的大小。
如何实现这一目标的任何帮助都将受到赞赏。
下面是.kv代码的摘录:(我删掉了一些,但如果太长则道歉)
<CustButton@Button>:
font_size: 18
spacing: [10, 10]
size_hint: [.5, .8]
<CustLabel@Label>:
font_size: 18
pos_hint: [None, None]
color: 1, 0.757, 0.145, 1
size_hint: [.8,.8]
<CustLabel2@Label>:
font_size: 18
pos_hint: [None, None]
color: 1, 0.757, 0.145, 1
size_hint: [.8,.8]
<CustTextInput@TextInput>:
font_size: 18
write_tab: False
size_hint: [.5,.5]
AccordionItem:
title: "Water Figures"
GridLayout:
padding: [10,10]
rows: 3
cols: 0
BoxLayout:
orientation: 'horizontal'
padding: [10,10]
GridLayout:
rows: 4
cols: 2
padding: [10,10]
CustLabel:
text: "Port FW Tank Volume"
CustTextInput:
id: pfwtv
hint_text: "m3"
CustLabel:
text: "Stbd FW Tank Volume"
CustTextInput:
id: sfwtv
hint_text: "m3"
CustLabel:
text: "Fire Fight FW Tank Volume"
CustTextInput:
id: fffwtv
hint_text: "m3"
GridLayout:
rows: 4
cols: 2
padding: [10,10]
CustLabel:
text: "Port DW Tank Volume"
CustTextInput:
id: pdwtv
hint_text: "m3"
CustLabel:
text: "Stbd DW Tank Volume"
CustTextInput:
id: sdwtv
hint_text: "m3"
BoxLayout:
orientation: 'horizontal'
padding: [10,10]
GridLayout:
rows: 4
cols: 2
padding: [10,10]
CustLabel:
text: "Today #1 Evap Meter"
CustTextInput:
id: ter_1
hint_text: "m3"
CustLabel:
text: "Today #2 Evap Meter"
CustTextInput:
id: ter_2
hint_text: "m3"
CustLabel:
text: "Previous #1 Evap Meter"
CustTextInput:
id: per_1
hint_text: "m3"
CustLabel:
text: "Previous #2 Evap Meter"
CustTextInput:
id: per_2
hint_text: "m3"
GridLayout:
rows: 4
cols: 2
padding: [10,10]
CustLabel2:
text: "Today Total FW Volume"
CustTextInput:
id: ttfwv
hint_text: "m3"
CustLabel:
text: "Previous Total FW Volume"
CustTextInput:
id: ptfwv
hint_text: "m3"
CustLabel2:
text: "Today Total DW Volume"
CustTextInput:
id: ttdwv
hint_text: "m3"
CustLabel:
text: "Previous Total DW Volume"
CustTextInput:
id: ptdwv
hint_text: "m3"
BoxLayout:
padding: [10, 10]
orientation: 'horizontal'
GridLayout:
padding: [10,10]
rows: 4
cols: 2
CustLabel:
text: "No 1 Total Evap Output"
CustTextInput:
id: teout_1
hint_text: "m3"
CustLabel:
text: "No 2 Total Evap output"
CustTextInput:
id: teout_2
hint_text: "m3"
CustLabel:
text: "Date"
CustTextInput:
hint_text: root.dt1
font_size: 25
CustLabel:
text: "Top Left"
CustTextInput:
hint_text: root.dt2
font_size: 25
GridLayout:
rows: 4
cols: 2
padding: [10,10]
CustLabel:
text: "To be determined"
CustTextInput:
hint_text: "m3"
CustLabel:
text: "To be determined"
CustTextInput:
hint_text: "m3"
CustLabel:
text: "To be determined"
CustTextInput:
hint_text: "m3"
CustButton:
text: "Calculate"
CustTextInput:
hint_text: "m3"
答案 0 :(得分:2)
一种可能性是使用<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
require "../db.php";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$desks = $_POST("desks");
for($i = 0; $i < sizeof($desks); $i++) {
$sql = "UPDATE desks SET desk_x=$desks[i]->x WHERE desk_id=$desks[i]->id";
$conn->query($sql);
$sql = "UPDATE desks SET desk_y=$desks[i]->y WHERE desk_id=$desks[i]->id";
$conn->query($sql);
}
$conn->close();
}
?>
属性来强制行的高度。要指定高度,请使用row_force_default: True
属性,并将其与一个完整网格布局的行的大小绑定,例如,使用其中一个小部件。
例如,使用row_default_height
高度作为参考:
ptdwv
可重复示例:
GridLayout:
row_force_default: True
row_default_height: ptdwv.height
rows: 4
cols: 2
padding: [10,10]
<强>输出:强>