我在kivy上使用多行TextField,一切正常,直到键入多行,然后在UI上按任意位置。在python代码部分中,我没有涉及到与文本字段有关的任何内容,因此我认为这没有问题。如果kv文件不够用,我很乐意提供更多信息。
谢谢!
这是我的main.kv代码:
<HomeScreen>:
name: "home"
GridLayout:
name: "main_grid"
id: maingrid
cols: 1
MDToolbar:
title: app.title
md_bg_color: app.theme_cls.primary_color
background_palette: "Primary"
elevation: 10
right_action_items: [['play', app.execute]]
MDLabel:
text: "Code:"
size_hint: None, pt(.1)
MDSeparator:
MDTextFieldRect:
id: code_field
multiline: True
pos_hint: {"center_x": .5}
hint_text: "Enter your code here!"
background_color: (0,0,0,0)
MDLabel:
text: "Result:"
size_hint: None, pt(.1)
MDSeparator:
MDTextFieldRect:
id: result_field
multiline: True
readonly: True
pos_hint: {"center_x": .5}
background_color: (0,0,0,0)
color: "accent"
需要完整的日志记录:
Traceback (most recent call last):
File "main.py", line 166, in <module>
RextesterApp().run()
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/app.py", line 826, in run
runTouchApp()
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/base.py", line 502, in runTouchApp
EventLoop.window.mainloop()
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/core/window/window_pygame.py", line 403, in mainloop
self._mainloop()
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/core/window/window_pygame.py", line 289, in _mainloop
EventLoop.idle()
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/base.py", line 340, in idle
self.dispatch_input()
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/base.py", line 325, in dispatch_input
post_dispatch_input(*pop(0))
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/base.py", line 231, in post_dispatch_input
listener.dispatch('on_motion', etype, me)
File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/core/window/__init__.py", line 1360, in on_motion
self.dispatch('on_touch_down', me)
File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/core/window/__init__.py", line 1376, in on_touch_down
if w.dispatch('on_touch_down', touch):
File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/uix/screenmanager.py", line 1191, in on_touch_down
return super(ScreenManager, self).on_touch_down(touch)
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/uix/widget.py", line 460, in on_touch_down
if child.dispatch('on_touch_down', touch):
File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/uix/relativelayout.py", line 288, in on_touch_down
ret = super(RelativeLayout, self).on_touch_down(touch)
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/uix/widget.py", line 460, in on_touch_down
if child.dispatch('on_touch_down', touch):
File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/uix/widget.py", line 460, in on_touch_down
if child.dispatch('on_touch_down', touch):
File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/uix/textinput.py", line 1340, in on_touch_down
if super(TextInput, self).on_touch_down(touch):
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/uix/behaviors/focus.py", line 441, in on_touch_down
self.focus = True
File "kivy/properties.pyx", line 483, in kivy.properties.Property.__set__
File "kivy/properties.pyx", line 524, in kivy.properties.Property.set
File "kivy/properties.pyx", line 579, in kivy.properties.Property.dispatch
File "kivy/_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
File "kivy/_event.pyx", line 1120, in kivy._event.EventObservers._dispatch
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/uix/behaviors/focus.py", line 384, in _on_focus
self._bind_keyboard()
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/uix/behaviors/focus.py", line 399, in _bind_keyboard
self._ensure_keyboard()
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/uix/behaviors/focus.py", line 393, in _ensure_keyboard
self._keyboard_released, self, input_type=self.input_type)
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/core/window/window_pygame.py", line 445, in request_keyboard
callback, target, input_type)
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/core/window/__init__.py", line 1902, in request_keyboard
self.release_keyboard(target)
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/core/window/window_pygame.py", line 451, in release_keyboard
super(WindowPygame, self).release_keyboard(*largs)
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/core/window/__init__.py", line 1980, in release_keyboard
callback()
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/uix/behaviors/focus.py", line 433, in _keyboard_released
self.focus = False
File "kivy/properties.pyx", line 483, in kivy.properties.Property.__set__
File "kivy/properties.pyx", line 524, in kivy.properties.Property.set
File "kivy/properties.pyx", line 579, in kivy.properties.Property.dispatch
File "kivy/_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
File "kivy/_event.pyx", line 1096, in kivy._event.EventObservers._dispatch
File "/home/alexandrumarcel/.local/lib/python3.7/site-packages/kivy/lang/builder.py", line 64, in custom_callback
exec(__kvlang__.co_value, idmap)
File "<string>", line 89, in <module>
File "/usr/local/lib/python3.7/dist-packages/kivymd/textfields.py", line 330, in anim_rect
instance_line = root_canvas.children[2]
AttributeError: 'kivy.graphics.context_instructions.BindTexture' object has no attribute 'children'
答案 0 :(得分:0)
发布此问题时,我在GitHub上发布了一个问题,该问题已由kivymd的开发人员解决