python - 如何在 Kivy 的 RecycleView 中显示大滚动条
问题描述
我在 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()
出现滚动条,但太小而无法触摸。
所以我必须用鼠标中键滚动。
有没有办法显示大滚动条?
解决方案
您可以使用以下bar_width
属性:
RecycleView:
size_hint: 1.0,1.0
bar_width: dp(10)
scroll_type: ["bars", "content"]
推荐阅读
- postgresql - Postgres 聚合查询太慢
- azure-active-directory - 添加 displayName 或 ApplicationID URI 作为客户端凭据声明
- database - SQL 命令未以插入语句正确结束
- c++ - 不懂C++栈
行为 - windows - 使用 ForEach 循环计算 PowerShell 中安全日志文件 ID 的出现次数
- three.js - 如何访问相机三.js 编辑器?
- python - 在 Numpy 中,如何使用一个项目数组作为指导来确定第二个数组中项目的索引?
- c++ - sfml 网络 - 套接字接收忽略
- ruby-on-rails - 构建 gem 原生扩展失败?
- firebase - firebase-admin createUser 具有随机密码或默认未定义