Python 如何显示';你好';每秒一次,而不是显示五个';你好';在这个节目里? #编码=utf-8 ''Tkinter模块'' 从Tkinter进口* 导入时间 root=Tk() t=文本(根,fg='red') t、 包() def将_hello_插入_text_区域(): t、 插入(1.0,'Hello') 按钮(root,text='hello',command=insert\u hello\u进入\u text\u区域)。pack() def start(): i=0 当i
而不是Python 如何显示';你好';每秒一次,而不是显示五个';你好';在这个节目里? #编码=utf-8 ''Tkinter模块'' 从Tkinter进口* 导入时间 root=Tk() t=文本(根,fg='red') t、 包() def将_hello_插入_text_区域(): t、 插入(1.0,'Hello') 按钮(root,text='hello',command=insert\u hello\u进入\u text\u区域)。pack() def start(): i=0 当i,python,tkinter,Python,Tkinter,而不是时与时间循环。睡眠,使用 after在n(以下代码中的1000)毫秒后调用回调 #coding=utf-8 '''Tkinter module''' from Tkinter import * import time root=Tk() t=Text(root,fg='red') t.pack() def insert_hello_into_text_area(): t.insert(1.0,'Hello') Button(root,text='hello',command=
时
与时间循环。睡眠
,使用
after
在n
(以下代码中的1000)毫秒后调用回调
#coding=utf-8
'''Tkinter module'''
from Tkinter import *
import time
root=Tk()
t=Text(root,fg='red')
t.pack()
def insert_hello_into_text_area():
t.insert(1.0,'Hello')
Button(root,text='hello',command=insert_hello_into_text_area).pack()
def start():
i=0
while i<5:
t.insert(1.0,'Hello\n')
time.sleep(1)
i+=1
Button(root,text='start',command=start).pack()
root.mainloop()
使用,而不是
while
循环时间。sleep
after
在n
(以下代码中的1000)毫秒后调用回调
#coding=utf-8
'''Tkinter module'''
from Tkinter import *
import time
root=Tk()
t=Text(root,fg='red')
t.pack()
def insert_hello_into_text_area():
t.insert(1.0,'Hello')
Button(root,text='hello',command=insert_hello_into_text_area).pack()
def start():
i=0
while i<5:
t.insert(1.0,'Hello\n')
time.sleep(1)
i+=1
Button(root,text='start',command=start).pack()
root.mainloop()
@fisiksnju,不带lambda
start(…)
被调用,不是在1000毫秒后调用,而是立即调用,并且start
函数的返回值用作回调,但它不是函数,而是None
@fisiksnju,之后的的第二个参数应该是可调用对象。(函数,方法,…)@fisiksnju,不带lambdastart(…)
,不是在1000毫秒后调用,而是立即调用,start
函数的返回值用作回调,但它不是函数,而是None
@fisiksnju,之后的第二个参数应该是可调用对象。(功能、方法等)