无法使用Kivy将小部件定位在GridLayout和BoxLayout的组合中

时间:2016-01-08 23:23:57

标签: kivy

我正在尝试根据下面的结构实现一个由4列组成的固定大小的UI(参见链接“有线帧”)。在第3栏,我在学习数小时后迷失了方向,看了一些例子和大量的反复试验。谁能帮我?低于kv的内容也是如此。 提前谢谢。

Wired frame

<IeditHome>:
    GridLayout:
        cols: 4
        # 1st Column
        BoxLayout:
            orientation: 'vertical'
            Label:
                canvas.before:
                    Color:
                        rgb: .7,.7,.7
                    Rectangle:
                        pos: self.pos
                        size: self.size
                    BorderImage:
                        source: 'C:/images/border.png'
                        border: (2,2,2,2)
                        size: self.size
                        pos: self.pos
                text: '1'
                size_hint: None, None
                height: 120
                width: 25
                halign: 'right'
                valign: 'middle'
                color: .4,.4,.4,1

                # Add 4 Label bloks of the same.
                # Re-engineer duplicated stuff later...

        # 2nd Column
        BoxLayout:
            orientation: 'vertical'
            Image:
                canvas.before:
                    Color:
                        rgb: .7,.7,.7
                    Rectangle:
                        pos: self.pos
                        size: self.size
                    BorderImage:
                        source: 'C:/images/border.png'
                        border: (2,1,1,2)
                        size: self.size
                        pos: self.pos
                size_hint_x: None
                size_hint_y: None
                size: 240, 120
                source: 'C:/temp/Object1.png'

                # Add 4 image bloks of the same.
                # Re-engineer duplicated stuff later...

        # 3rd Column   
        BoxLayout:
            orientation: 'vertical'
            Label:
                canvas.before:
                    Color:
                        rgb: .7,.7,.7
                    Rectangle:
                        pos: self.pos
                        size: self.size
                text: 'This is the titel'
            Image:
                canvas.before:
                    Color:
                        rgb: .7,.7,.7
                    Rectangle:
                        pos: self.pos
                        size: self.size
                    BorderImage:
                        source: 'C:/images/border.png'
                        border: (2,1,1,2)
                        size: self.size
                        pos: self.pos
                size_hint_x: None
                size_hint_y: None
                size: 300, 200
                source: 'C:/temp/MediumImage.png'
            Image:
                canvas.before:
                    Color:
                        rgb: .7,.7,.7
                    Rectangle:
                        pos: self.pos
                        size: self.size
                    BorderImage:
                        source: 'C:/images/border.png'
                        border: (2,1,1,2)
                        size: self.size
                        pos: self.pos
                size_hint_x: None
                size_hint_y: None
                size: 500, 300
                source: 'C:/temp/LargeImage.png'

    ActionBar:
        pos: 0, 600
        font_size: 16
        size: 1200, 40
        # background color in Kivy acts as a tint and not just a solid color.
        # set a pure white background image first.
        background_image: 'C:/images/white-bg.png'
        background_color: .2,.6,.7,1
        ActionView:
            ActionPrevious:
                size: 1200, 40
                font_size: 16
                title: 'Ieditor'
                with_previous: False
            ActionOverflow:
            ActionButton:
                icon: 'C:/images/butt_prev.png'
            ActionButton:
                icon: 'C:/images/butt_next.png'

1 个答案:

答案 0 :(得分:0)

这是第3列的一个小的工作示例应该看起来像(A类)

View

我想把它放在你的大榜样里面。