【问题标题】:How to show large scrollbar in Kivy's RecycleView如何在 Kivy 的 RecycleView 中显示大滚动条
【发布时间】:2020-02-15 19:53:22
【问题描述】:

我用 Python 在 Kivy 中编写了以下代码。

这是一个只有五个可以滚动的按钮的 GUI。

我在 Anacond 环境中运行以下命令。

#-*- coding: utf-8 -*-

from kivy.lang import Builder
Builder.load_string("""
<TextWidget>:
    BoxLayout:
        size: root.size
        orientation: 'vertical'

        RecycleView:
            size_hint: 1.0,1.0

            BoxLayout:
                orientation: 'vertical'
                size_hint_y: 5

                Button:
                    halign: 'center'
                    valign: 'center'
                    text: 'TEST1'

                Button:
                    halign: 'center'
                    valign: 'center'
                    text: 'TEST2'

                Button:
                    halign: 'center'
                    valign: 'center'
                    text: 'TEST3'

                Button:
                    halign: 'center'
                    valign: 'center'
                    text: 'TEST4'

                Button:
                    halign: 'center'
                    valign: 'center'
                    text: 'TEST5'
""")

from kivy.app import App
from kivy.uix.widget import Widget

from kivy.properties import StringProperty 

class TextWidget(Widget):
    text = StringProperty()

    def __init__(self, **kwargs):
        super(TextWidget, self).__init__(**kwargs)

class TestApp(App):
    def __init__(self, **kwargs):
        super(TestApp, self).__init__(**kwargs)
        self.title = 'test'

    def build(self):
        return TextWidget()

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

出现一个滚动条,但太小而无法触摸。

所以我必须用鼠标中键滚动。

有没有办法显示大滚动条?

【问题讨论】:

    标签: python kivy


    【解决方案1】:

    你可以使用bar_width属性:

            RecycleView:
                size_hint: 1.0,1.0
                bar_width: dp(10)
                scroll_type: ["bars", "content"]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-06
      • 2017-02-02
      • 2010-12-31
      相关资源
      最近更新 更多