Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
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 - Fatal编程技术网

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,不带lambda
start(…)
,不是在1000毫秒后调用,而是立即调用,
start
函数的返回值用作回调,但它不是函数,而是
None
@fisiksnju,
之后的第二个参数应该是可调用对象。(功能、方法等)