我在当前GUI的左上角有很多卡住的地方,我试图基本上分散开来,让我的图像保持正常大小(类似于下面显示的模型)。我想我需要向下扩展Y方向来适应它(使顶部区域更大以适应所有的情况)?但是,当我将size_hint_y
改为>;1时,它会使文本向上间隔,并在GUI外部被切断。有什么想法吗?非常感谢!在
我的kv文件:
#:kivy 1.10.0
<WeatherWidget>:
cols: 1
BoxLayout:
size_hint_y: None
BoxLayout:
size_hint_x: 1
size_hint_y: 1
orientation: "vertical"
Image:
source: 'Code32.png'
keep_ratio: False
halign: 'center'
Label:
text: root.current_temperature()[:3]
bold: True
font_size: 40
Label:
text: root.high_low_temp(0)
font_size: 15
color: [1,255,1,1]
Label:
text: root.get_location()
font_size: 15
color: [1,1,1,1]
bold: True
Label:
text: root.sunrise()
font_size: 10
color: [1,1,1,1]
Label:
text: root.sunset()
font_size: 10
color: [1,1,1,1]
BoxLayout:
orientation: 'vertical'
Image:
source: 'Code32.png'
Label:
text: root.forecast_day(1)
Label:
text: root.high_low_temp(1)
font_size: 12
color: [1,255,1,1]
Label:
text: root.forecast_day(2)
Label:
text: root.forecast_day(3)
Label:
text: root.forecast_day(4)
Label:
text: root.forecast_day(5)
BoxLayout:
size_hint_y: None
BoxLayout:
orientation: 'vertical'
Button:
text: root.TimeHours + ':' + root.TimeMinutes
size_hint_x: 1
font_size: 40
size: self.size
bold: True
halign: 'center'
Label:
text: root.current_date()
size_hint_x: 1
font_size: 15
bold: True
halign: 'center'
解决方法如下:
1。把窗户分成两部分
使用size_hint_y=0.3,将顶部部分设置为父级高度的30%(0.3)。使用size_hint_y=0.7将底部部分设置为父级高度的70%(0.7)
2。避免左上角卡住
要在左上角展开小部件,请使用size\u hint_y=1
代码段
在每日视图.kv在
^{pr2}$输出
相关问题 更多 >
编程相关推荐