Python中ttk的界面刷新问题

Python011

Python中ttk的界面刷新问题,第1张

一个建议的编程思想:

通过一个可变变量来传递任务完成的进度,例如可变变量命名为p,(p位于0到1之间,表示百分比。)

主程序显示一个progressbar,其值为p。

DoJob()在运行过程中会更改p的值。

则此更改在mainloop()的作用下将实时显示到progressbar上。

from tkinter import *

import time

def updatetimer():

    timer=time.strftime("%H:%M:%S")

    timelabel.configure(text=timer)

    timelabel.after(1000,updatetimer)

root=Tk()

timelabel=Label(root)

timelabel.pack()

timelabel.after(1000,updatetimer)

root.mainloop()

用urlopen和time组合一下呗,我一菜鸟只想到这个 #!/usr/bin/env python #coding=utf-8 import urllib2 html = urllib2.urlopen("http://****",timeout = 30).read() print html.decode("gbk").encode("utf-8")