【问题标题】:ScrollView in a anchorlayout. python. kivy滚动视图在锚布局中。 Python。基维
【发布时间】:2016-09-27 18:08:16
【问题描述】:

practice screen

这是来自 .py 文件

如您所见,屏幕由屏幕管理器控制

class Practice_Page(Screen):
    pass

class PracticeList(BoxLayout):
    def practicelist(ScrollView):

        practicelist.bind(minimum_height=layout.setter('height'))

.KV 文件:

<Practice_page>:
    canvas.before:
        Rectangle:
            pos: self.pos
            size: self.size
            source: 'background1.png'


    AnchorLayout:
        anchor_x: 'center'
        anchor_y: 'center'
        PracticeList:
            size: 900,30
            size_hint: None,None
            do_scroll_x: False        
            BoxLayout:
                orientation: 'vertical'
                padding: 10
                cols: 1
                Button:
                    text: 'The Real Number System'           
                    on_press: root.manager.current = 'open_topics'
                Button:
                    text: 'Absolute Value'
                    on_press: root.manager.current = 'open_practice'
                Button:
                    text: 'Operations W/ Integers & Fractions'           
                    on_press: root.manager.current = 'open_topics'                    
                Button:
                    text: 'Operations W/ Zero'
                    on_press: root.manager.current = 'open_formulas'

我还有大约 30 个按钮。我不知道自己做错了什么,任何帮助或建议都会非常有帮助。

【问题讨论】:

  • 尝试解释更多,我现在不知道你的问题是什么。如果你解释得更好,那么我可能会帮助你。
  • @MatthiasSchreiber 正如您从图像中看到的那样,所有按钮都堆叠在彼此之上,因此您可以看到它们。我想在锚布局中添加一个滚动视图,以便用户可以滚动浏览主题名称列表。再次感谢您,我很感激

标签: python scrollview kivy


【解决方案1】:
AnchorLayout:
    anchor_x: 'center'
    anchor_y: 'center'
    ScrollView:
        #size: 900,30
        size: self.size
        #do_scroll_x: False        
        GridLayout:
           # orientation: 'vertical'
            #padding: 10
            size_hint_y: None
            height: self.minimum_height
            cols: 1
            Button:
                size_hint_y: None
                text: 'The Real Number System'           
                on_press: root.manager.current = 'open_topics'
            Button:
                size_hint_y: None
                text: 'Absolute Value'
                on_press: root.manager.current = 'open_practice'
            Button:
                size_hint_y: None
                text: 'Operations W/ Integers & Fractions'           
                on_press: root.manager.current = 'open_topics'                    
            Button:
                size_hint_y: None
                text: 'Operations W/ Zero'
                on_press: root.manager.current = 'open_formulas'

            ##MORE BTNS

对于任何需要它的人。

【讨论】:

    猜你喜欢
    • 2018-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多