Kivy:你能在另一个 BoxLayout 中细分一个 BoxLayout 吗?

Kivy: Can you subdivide a BoxLayout within another BoxLayout?

我正在尝试构建我制作的以下模型:

我正处于非常早期的阶段,我正在尝试弄清楚如何细分左上角(以显示图像、温度、高低、城市、日出、日落)。到目前为止,我将其显示为一个按钮以查看感兴趣的区域。我一直在尝试的一切都将它放入下面一个全新的区域(而不是细分第一个单元格)。谢谢!

这是我用来构建它的 python 文件:

from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.clock import Clock
from kivy.properties import StringProperty
from random import *
import time 
from weather import Weather

# In the kv file, everything to the right of the colon is pure python
# for loading python module in kv file, use format of #:  import keyword module_name

# Pull in the weather data
weather = Weather()
location = weather.lookup_by_location('New York, NY')
condition = location.condition()
forecasts = location.forecast()
astronomy = location.astronomy()

class WeatherWidget(GridLayout):
    TimeSeconds = StringProperty('')
    TimeMinutes = StringProperty('')
    TimeHours = StringProperty('')

    def current_location(self):
        return location.title().replace('Yahoo! Weather - ','')

    def current_temperature(self):
        return condition['temp'] + '° ' +condition['text']

    def update(self, dt):
        current_time = time.localtime()
        self.TimeHours = str(current_time.tm_hour).zfill(2)
        self.TimeMinutes = str(current_time.tm_min).zfill(2)
        self.TimeSeconds = str(current_time.tm_sec).zfill(2)

class DailyViewApp(App):
    def build(self):
        weather = WeatherWidget()
        Clock.schedule_interval(weather.update, 1)
        return weather

if __name__ == '__main__':
    DailyViewApp().run()

这是 Kivy 代码:

#:kivy 1.10.0
<WeatherWidget>:
    cols: 1
    BoxLayout:
        size_hint_y: None
        Button:
            text: root.current_temperature()
            size_hint_x: 1
        Label:
            text: 'Tomorrow'
            size_hint_x: 0.25
        Label:
            text: 'T+2'
            size_hint_x: 0.25
        Label:
            text: 'T+3'
            size_hint_x: 0.25
        Label:
            text: 'T+4'
            size_hint_x: 0.25
        Label:
            text: 'T+5'
            size_hint_x: 0.25
        BoxLayout:
            Label:
                text: root.TimeHours + ':' + root.TimeMinutes
                size_hint_x: 1
                font_size: 30
                bold: True

是的,这是可能的。您只需嵌套另一个 boxlayout。
像这样:

<WeatherWidget>:
    cols: 1
    BoxLayout:
        size_hint_y: None
        BoxLayout:
            size_hint_x: 1
            orientation: "vertical"
            Image:
                src: "yourimage"
            Button:
                text: root.current_temperature()
        Label:
            text: 'Tomorrow'
            size_hint_x: 0.25