cuốn sách gpt4 ai đã làm

python - ScrollLabel 产生 ValueError

In lại Tác giả: Vũ trụ không gian Thời gian cập nhật: 2023-11-03 20:09:10 29 4
mua khóa gpt4 Nike

Tôi mới biết đến trang web này, vì vậy tôi xin lỗi trước nếu tôi làm sai điều gì. Khi tôi cố gắng sử dụng ScrollLabel của kivy-garden, nó báo lỗi. Về cơ bản, tôi đang cố gắng tạo nhật ký bảng điều khiển và tôi cần có khả năng cuộn qua hộp văn bản khi nó đầy. Tôi đã thử tiện ích ScrollView nhưng nó tạo ra màn hình đen khi tôi hiển thị quá nhiều văn bản. Ngay cả khi tôi sử dụng ví dụ ScrollLabel tôi cũng gặp lỗi tương tự

Lỗi tôi nhận được:

 Traceback (most recent call last):
Tệp "/home/fodderpod/Apps/FPCU-02/GUI/main.py", dòng 184, trong
bản trình bày = Builder.load_file("mainScreenHolder.kv")
Tệp "/usr/local/lib/python3.7/dist-packages/kivy/lang/builder.py", dòng 301, trong Load_file
trả về self.load_string(data, **kwargs)
Tệp "/usr/local/lib/python3.7/dist-packages/kivy/lang/builder.py", dòng 405, trong Load_string
quy_trẻ em=quy tắc_con)
Tệp "/usr/local/lib/python3.7/dist-packages/kivy/lang/builder.py", dòng 657, trong _apply_rule
root=rctx['ids']['root'], Rule_children=rule_children)
Tệp "/usr/local/lib/python3.7/dist-packages/kivy/uix/widget.py", dòng 469, trong apply_class_lang_rules
quy_trẻ em=quy tắc_con)
Tệp "/usr/local/lib/python3.7/dist-packages/kivy/lang/builder.py", dòng 538, đang áp dụng
quy_trẻ em=quy tắc_con)
Tệp "/usr/local/lib/python3.7/dist-packages/kivy/lang/builder.py", dòng 659, trong _apply_rule
con, crule, rootrule, Rule_children=rule_children)
Tệp "/usr/local/lib/python3.7/dist-packages/kivy/lang/builder.py", dòng 654, trong _apply_rule
con = cls(__no_builder=True)
Tệp "kivy/_event.pyx", dòng 188, trong kivy._event.EventDispatcher.__cinit__
Tệp "kivy/properties.pyx", dòng 447, trong kivy.properties.Property.link
Tệp "kivy/properties.pyx", dòng 632, trong kivy.properties.NumericProperty.init_storage
Tệp "kivy/properties.pyx", dòng 418, trong kivy.properties.Property.init_storage
Tệp "kivy/properties.pyx", dòng 655, trong kivy.properties.NumericProperty.convert
Tệp "kivy/properties.pyx", dòng 665, trong kivy.properties.NumericProperty.parse_str
ValueError: không thể chuyển đổi chuỗi thành float:
^C
[11]+ Thoát 1 python3 /home/fodderpod/Apps/FPCU-02/GUI/main.py

Tôi không thể đăng mã của mình nhưng đây là mã mẫu cho ScrollView gây ra lỗi tương tự


__phiên bản__ = "1.0"

từ ứng dụng nhập kivy.app
từ kivy.lang import Builder
từ kivy.garden.scrolllabel nhập ScrollLabel

LOREM = """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur nec arcu accumsan, lacinia libero sed, cursus nisi. sapien, id tincidunt eros molestie vitae. Lorem ipsum dolor sit amet, consectetur adipiscing elit. ipsum dui, ut faucibus libero lacinia id. Pellentesque eget rhoncus justo, quis interdum eros.
Duis dictum sagittis urna nec dapibus. Vestibulum ac elit vel Nusmod lobortis. Vivamus sit amet tortor in diam consectetur ultrices vitae vulputate leo. luctus feugiat risus. Nullam ultricies quam ac metus imperdiet, eget scelerisque dolor commodo. Cras massa lacus, consectetur varius est a, congue pulvinar magna. risus tristique, trong laoreet ligula vestibulum. Vestibulum varius eget nibh nec convallis.
Tạm dừng pharetra ligula nec faucibus mattis Aliquam et felis eget augue efficitur aliquam viverra ut Tellus. Nulla urna ultricies lorem, at tincidunt ex arcu nec eros. Maecenas egestas augue sit amet euismod.
Suspendisse bibendum sit amet est eget ullamcorper Duis pellentesque tristique nisi. Praesent erat eros, facilisis placerat ultrices et, interdum quis risus. Donec eleifend risus dapibus, laoreet felis ut, fermentum neque, congue non tempus quis, dictum quis metus. Aliquam vitae consequat eros, quis ultricies tortor.
Etiam nec risus porttitor, placerat est et, facilisis diam Etiam vel feugiat ligula. Etiam vel blandit nibh. Nullam facilisis posuere erat vel mattis. Ở hac Hac Hac Hac Platea dictumst.
"""

KV_EXAMPLE = """
#: nhập LOREM __main__.lorem
Bố cục hộp:
định hướng: "dọc"
Nhãn:
văn bản: "Bản trình diễn nhãn cuộn"
size_hint_y: Không có
chiều cao: "48sp"

Nhãn cuộn:
ID: sl
văn bản: LOREM * int(sl_count.value)
font_size: sl_fontsize.value

Bố cục hộp:
size_hint_y: Không có
chiều cao: "48sp"
Nhãn:
text: "Số lượng văn bản"
size_hint_x: Không có
chiều rộng: self.texture_size[0] + dp(48)
Thanh trượt:
id: sl_count
tối thiểu: 1
tối đa: 20
giá trị: 1
bước: 1

Bố cục hộp:
size_hint_y: Không có
chiều cao: "48sp"
Nhãn:
văn bản: "Cỡ chữ"
size_hint_x: Không có
chiều rộng: self.texture_size[0] + dp(48)
Thanh trượt:
id: sl_fontsize
phút:sp(8)
tối đa: sp(100)
giá trị: sp(14)

Bố cục hộp:
size_hint_y: Không có
chiều cao: "48sp"
Nhãn:
văn bản: "Căn chỉnh"
size_hint_x: Không có
chiều rộng: self.texture_size[0] + dp(48)
Cái nút:
văn bản: "Trái"
on_press: sl.halign = "trái"
Cái nút:
văn bản: "Trung tâm"
on_press: sl.halign = "trung tâm"
Cái nút:
văn bản: "Đúng"
on_press: sl.halign = "đúng"

"""


lớp TestScrollLabel (Ứng dụng):
xây dựng chắc chắn (tự):
trả về Builder.load_string(KV_EXAMPLE)

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

câu trả lời hay nhất

Tôi đã gửi PR kèm theo các bản sửa lỗi cần thiết cho kivy 1.10+.
Cho đến khi nó được chấp nhận (kho lưu trữ đã không hoạt động trong 4 năm qua), bạn có thể tải xuống từ đây Lấy phiên bản cố định. .

Bạn cũng có thể sao chép (và đổi tên) trong dự án của mình__init__.py, sau đó nhậpNhãn cuộn

Về python - ScrollLabel tạo ra ValueError, chúng tôi đã tìm thấy một câu hỏi tương tự trên Stack Overflow: https://stackoverflow.com/questions/58796115/

29 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress