【发布时间】:2017-10-19 05:45:56
【问题描述】:
在一个更大的应用程序中,我在一个单独的屏幕中拥有一种第一编辑器。只要我在输入小部件中键入一个字符,我就会得到一个持续的关键时钟警告列表: [CRITICAL] [Clock ] 警告,在下一帧之前完成了太多迭代。检查你的代码,或者增加 Clock.max_iteration 属性
我增加了 max-iteration 属性,但这并不能解决问题。同样在下面的代码中,我设置大小没有任何区别。
我该如何解决这个问题?
编辑画面文件:
from kivy.uix.screenmanager import Screen
from kivy.lang import Builder
from kivy.clock import Clock
from functools import partial
Builder.load_file('editscreen.kv')
class EditScreen(Screen):
'''Screen class.'''
def __init__(self, **kwargs):
super(EditScreen, self).__init__(**kwargs)
def updaterst(self):
inptext = self.txt_inpt.text
Clock.schedule_once(partial(self.do_update, inptext), 0.1)
def do_update(self, text, *args):
self.rsttxt.text = text
还有kv文件:
# File: editscreen.kv
#: import editscreen editscreen
<EditScreen>:
name: 'EditScreen'
txt_inpt:txt_inpt
rsttxt:rsttxt
BoxLayout:
orientation: 'vertical'
#size_hint: (.99, .99)
TextInput:
id: txt_inpt
#size_hint: None, None
#size: 400, 400
on_text: root.updaterst()
RstDocument:
id: rsttxt
#size_hint: None, None
#size: 400, 400
show_errors: True
【问题讨论】:
-
至于“[CRITICAL] [Clock] 警告,在下一帧之前完成了太多迭代。检查你的代码,或者增加Clock.max_iteration 属性”,请参考另一篇帖子stackoverflow.com/questions/38448755/…
-
我关注了这篇文章,正如您在我的代码示例中看到的那样。另请参阅下面项目中的我的 cmets。
标签: kivy restructuredtext kivy-language