更新显示tkinter?

时间:2016-03-30 22:36:15

标签: python tkinter

我在如何弄清楚如何制作显示器方面遇到了一些麻烦。我有两个问题:我应该使用哪个小部件?我怎样才能让它做我想做的事呢? 当谈到Tkinter时,我仍然是初学者,所以这对我来说很困惑。在发布这个问题之前我曾尝试在线搜索,但这只会让我更加困惑。如果有人愿意提供帮助,我将非常感激。提前谢谢!

这是我到目前为止所拥有的。

#Imports Tkinter as tk

import Tkinter as tk
root=tk.Tk()
root.title("Phone Dial")


#def display:
#creates a display
#update display when a button is pressed
#continues to list numbers when button is pressed
    #ex. only 2 is displayed -> (Button "3" is pressed)-> displays 23
        #like a calculator display


#Dial buttons from #0-10
b=tk.Button(root,text="1",bd=5,width="5").grid(row=2,column=1)
b1=tk.Button(root,text="2",bd=5,width="5").grid(row=2,column=2)
b2=tk.Button(root,text="3",bd=5,width="5").grid(row=2,column=3)
b3=tk.Button(root,text="4",bd=5,width="5").grid(row=3,column=1)
b4=tk.Button(root,text="5",bd=5,width="5").grid(row=3,column=2)
b5=tk.Button(root,text="6",bd=5,width="5").grid(row=3,column=3)
b6=tk.Button(root,text="7",bd=5,width="5").grid(row=4,column=1)
b7=tk.Button(root,text="8",bd=5,width="5").grid(row=4,column=2)
b8=tk.Button(root,text="9",bd=5,width="5").grid(row=4,column=3)
b9=tk.Button(root,text="0",bd=5,width="5").grid(row=5,column=2)


root.mainloop()

1 个答案:

答案 0 :(得分:0)

以下是有关更新的一些内容。

  • 您需要做的就是在最后添加root.update()
  • 它只是更新你所有的显示器。
  • 你会认为python会做一些疯狂的事情来让它更新。

这是一个关于更新的网站。

http://www.tutorialspoint.com/python/dictionary_update.htm