我有一個手風琴佈局,我想弄清楚如何在盒子佈局中有不同數量的小部件,並保持它們的大小與其他Box Layouts中的其他小部件。我如何保持標籤和文本輸入小部件大小在KIVY中的盒子佈局內相同
我想避免使用浮動佈局開始有點耗費更多的時間,並會認爲應該做到這一點用箱的佈局和大小提示等方法
目前我有6個箱佈局一個網格佈局裏面的每一個來適當地放置窗口小部件,然而,在一些網格佈局中,我會比其他窗口小部件更少,這會導致窗口小部件填充剩餘的空間,無論我是否放入大小提示。
我曾嘗試在沒有內容的網格佈局中添加標籤,但它不會更改尺寸安排。如果我添加額外的文本輸入小部件,它將調整爲適合並與其他Box Layouts相同,但不是我想要的。
前兩名盒/網格用更少的部件佈局裏面是我想要的大小與其他盒/網格佈局相同的人。
任何幫助如何實現這一點,將不勝感激。
下面是.kv代碼的摘錄:(我切一些了,但道歉,如果太長)
<[email protected]>:
font_size: 18
spacing: [10, 10]
size_hint: [.5, .8]
<[email protected]>:
font_size: 18
pos_hint: [None, None]
color: 1, 0.757, 0.145, 1
size_hint: [.8,.8]
<[email protected]>:
font_size: 18
pos_hint: [None, None]
color: 1, 0.757, 0.145, 1
size_hint: [.8,.8]
<[email protected]>:
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"
很好,再次感謝您的協助。它正是我想要的。 – Aiden