fix(tui): 修复set_timer(0)导致的ZeroDivisionError
_render_welcome_animated中delay=i*0.1在i=0时为0.0, Textual 8.x的set_timer(0,...)内部interval为0导致除零崩溃。 使用max(0.01, delay)确保最小延迟。
This commit is contained in:
1 parent
fe79f0e5d4
commit
038fbe24c8
1 file changed
+3
-3
+3
-3
@@ -509,12 +509,12 @@ if TEXTUAL_AVAILABLE:
|
||||
|
||||
widget = Static(line, classes=cls)
|
||||
scroll.mount(widget)
|
||||
# 延迟显示每一行
|
||||
delay = i * 0.1
|
||||
# 延迟显示每一行(避免 delay=0 导致 Textual 除零错误)
|
||||
delay = max(0.01, i * 0.1)
|
||||
self.set_timer(delay, lambda w=widget: w.add_class("visible"))
|
||||
|
||||
# 最后滚动到底部
|
||||
self.set_timer(len(welcome_lines) * 0.1 + 0.1,
|
||||
self.set_timer(max(0.01, len(welcome_lines) * 0.1 + 0.1),
|
||||
lambda: scroll.scroll_end(animate=True, duration=0.3))
|
||||
|
||||
def _render_welcome(self):
|
||||
|
||||
Reference in new issue
Block a user