我正在尝试以kivy设置弹出窗口的高度,以使其适合其内容。但是,我无法使用height: self.minimum_height
,因为弹出窗口没有属性minimum_height。
我还尝试将弹出窗口的高度设置为等于内容的高度,但结果远非理想(尤其是在不同屏幕尺寸下不一致)。
这是我的代码:
#:set row_height '35sp'
<ConfirmPopup@Popup>:
box: box
message: message
noButton: noButton
yesButton: yesButton
size_hint: .8, None
height: box.height + sp(80)
auto_dismiss: False
StackLayout:
id: box
orientation: 'lr-tb'
size_hint: 1, None
height: self.minimum_height
padding: main_padding
Label:
id: message
text: "" # This text is updated later from the py script
text_size: self.width, None
size_hint: None, None
width: self.parent.width
height: self.texture_size[1]
Label: # just empty space
size_hint: .15, None
Button:
id: noButton
size_hint: .3, None
height: row_height
Label:
size_hint: .1, None
Button:
id: yesButton
size_hint: .3, None
height: row_height
Label:
size_hint: .15, None