gpt4 book ai didi

python - ScrollLabel 产生 ValueError

转载 作者:太空宇宙 更新时间:2023-11-03 20:09:10 29 4
gpt4 key购买 nike

我是这个网站的新手,所以如果我做错了什么,我提前道歉。当我尝试使用 kivy-garden 的 ScrollLabel 时,它给了我一个错误。基本上我正在尝试创建一个控制台日志,并且我需要能够在文本框填充时滚动它。我尝试了 ScrollView 小部件,但当我显示太多文本时它会产生黑屏。即使我使用示例 ScrollLabel 我也会得到相同的错误

我收到的错误:

 Traceback (most recent call last):
File "/home/fodderpod/Apps/FPCU-02/GUI/main.py", line 184, in <module>
presentation = Builder.load_file("mainScreenHolder.kv")
File "/usr/local/lib/python3.7/dist-packages/kivy/lang/builder.py", line 301, in load_file
return self.load_string(data, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/kivy/lang/builder.py", line 405, in load_string
rule_children=rule_children)
File "/usr/local/lib/python3.7/dist-packages/kivy/lang/builder.py", line 657, in _apply_rule
root=rctx['ids']['root'], rule_children=rule_children)
File "/usr/local/lib/python3.7/dist-packages/kivy/uix/widget.py", line 469, in apply_class_lang_rules
rule_children=rule_children)
File "/usr/local/lib/python3.7/dist-packages/kivy/lang/builder.py", line 538, in apply
rule_children=rule_children)
File "/usr/local/lib/python3.7/dist-packages/kivy/lang/builder.py", line 659, in _apply_rule
child, crule, rootrule, rule_children=rule_children)
File "/usr/local/lib/python3.7/dist-packages/kivy/lang/builder.py", line 654, in _apply_rule
child = cls(__no_builder=True)
File "kivy/_event.pyx", line 188, in kivy._event.EventDispatcher.__cinit__
File "kivy/properties.pyx", line 447, in kivy.properties.Property.link
File "kivy/properties.pyx", line 632, in kivy.properties.NumericProperty.init_storage
File "kivy/properties.pyx", line 418, in kivy.properties.Property.init_storage
File "kivy/properties.pyx", line 655, in kivy.properties.NumericProperty.convert
File "kivy/properties.pyx", line 665, in kivy.properties.NumericProperty.parse_str
ValueError: could not convert string to float:
^C
[11]+ Exit 1 python3 /home/fodderpod/Apps/FPCU-02/GUI/main.py

我无法发布我的代码,但这是产生相同错误的 ScrollView 的示例代码


__version__ = "1.0"

from kivy.app import App
from kivy.lang import Builder
from kivy.garden.scrolllabel import ScrollLabel

LOREM = """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur nec arcu accumsan, lacinia libero sed, cursus nisi. Curabitur volutpat mauris id ornare finibus. Cras dignissim arcu viverra, bibendum est congue, tempor elit. Vivamus luctus sapien sapien, id tincidunt eros molestie vitae. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut commodo eget purus vel efficitur. Duis facilisis ex dolor, vel convallis odio pharetra quis. Vivamus eu suscipit tortor. Proin a tellus a nisl iaculis aliquam. Nam tristique ipsum dui, ut faucibus libero lacinia id. Pellentesque eget rhoncus justo, quis interdum eros. Suspendisse felis lorem, gravida in orci ac, auctor malesuada turpis. Fusce dapibus urna dolor, id viverra enim semper a. Proin dignissim neque quis ante commodo feugiat.
Duis dictum sagittis urna nec dapibus. Vestibulum ac elit vel nunc euismod lobortis. Vivamus sit amet tortor in diam consectetur ultrices vitae vulputate leo. Aenean vehicula orci leo, eget fringilla enim condimentum eget. Sed sapien lacus, vulputate nec ligula eget, luctus feugiat risus. Nullam ultricies quam ac metus imperdiet, eget scelerisque dolor commodo. Ut nec elementum orci. Cras massa lacus, consectetur varius est a, congue pulvinar magna. Proin nec sapien facilisis, tristique turpis vel, malesuada leo. Phasellus faucibus justo vel risus tristique, in laoreet ligula vestibulum. Vestibulum varius eget nibh nec convallis. Morbi eu diam at turpis mollis hendrerit. Aenean sed turpis lectus.
Suspendisse pharetra ligula nec faucibus mattis. Aliquam et felis eget augue efficitur aliquam viverra ut tellus. Aliquam sagittis ut sapien venenatis condimentum. Quisque in turpis ac nisi vehicula commodo vel porttitor erat. Maecenas lobortis, sapien dictum congue gravida, nulla urna ultricies lorem, at tincidunt ex arcu nec eros. Maecenas egestas a augue sit amet euismod. Praesent ut sapien metus. Curabitur lorem erat, consectetur quis rhoncus quis, tristique ac ligula. Suspendisse justo magna, cursus id mauris et, lacinia egestas neque.
Suspendisse bibendum sit amet est eget ullamcorper. Duis pellentesque tristique nisi. Donec id dolor eget arcu lobortis sollicitudin vel et justo. Vivamus vel risus eget felis condimentum tempus ac sed dui. Donec placerat risus quis metus auctor sagittis. Pellentesque vel sem dolor. Praesent erat eros, facilisis placerat ultrices et, interdum quis risus. Donec eleifend risus dapibus, laoreet felis ut, fermentum neque. Aenean purus elit, congue non tempus quis, dictum quis metus. Maecenas finibus rutrum bibendum. Ut vestibulum dapibus felis vel luctus. Aliquam vitae consequat eros, quis ultricies tortor. Quisque eu accumsan erat, id commodo nisi.
Etiam nec risus porttitor, placerat est et, facilisis diam. Etiam vel feugiat ligula. Aliquam at quam congue, lacinia velit nec, congue nibh. In varius quis elit vel sollicitudin. Vivamus molestie elementum ipsum et vehicula. Etiam non augue quis tortor ultrices maximus. Etiam vel blandit nibh. Nullam facilisis posuere erat vel mattis. Vestibulum mattis condimentum purus efficitur vehicula. Aliquam consequat interdum eros eu semper. Etiam feugiat, erat at tempor tincidunt, odio eros maximus sapien, sit amet lacinia nibh tortor quis dui. In hac habitasse platea dictumst.
"""

KV_EXAMPLE = """
#: import LOREM __main__.LOREM
BoxLayout:
orientation: "vertical"
Label:
text: "ScrollLabel Demo"
size_hint_y: None
height: "48sp"

ScrollLabel:
id: sl
text: LOREM * int(sl_count.value)
font_size: sl_fontsize.value

BoxLayout:
size_hint_y: None
height: "48sp"
Label:
text: "Text count"
size_hint_x: None
width: self.texture_size[0] + dp(48)
Slider:
id: sl_count
min: 1
max: 20
value: 1
step: 1

BoxLayout:
size_hint_y: None
height: "48sp"
Label:
text: "Font size"
size_hint_x: None
width: self.texture_size[0] + dp(48)
Slider:
id: sl_fontsize
min: sp(8)
max: sp(100)
value: sp(14)

BoxLayout:
size_hint_y: None
height: "48sp"
Label:
text: "Alignment"
size_hint_x: None
width: self.texture_size[0] + dp(48)
Button:
text: "Left"
on_press: sl.halign = "left"
Button:
text: "Center"
on_press: sl.halign = "center"
Button:
text: "Right"
on_press: sl.halign = "right"

"""


class TestScrollLabel(App):
def build(self):
return Builder.load_string(KV_EXAMPLE)

if __name__ == "__main__":
TestScrollLabel().run()

最佳答案

我提交了一份 PR,其中包含 kivy 1.10+ 所需的修复。
在它被接受之前(存储库在过去 4 年里闲置),您可以从 here 获取修复版本。 .

您还可以在项目中复制(并重命名)__init__.py,然后导入ScrollLabel

关于python - ScrollLabel 产生 ValueError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58796115/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com