这篇文章主要介绍python tkinter实现画出计算器界面的示例,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
需求:设计能计算加法的计算器界面
代码演示:
from tkinter import * # 创建窗体 root = Tk() #添加标题 root.title("求两数之和") root.geometry("700x80") photo = PhotoImage(file = "/Users/yushengtan/Desktop/calc.png") PhotoLabel = Label(root,image = photo).pack(side = LEFT,padx = 10,pady = 5) #文本框 Entry01 = Entry(root,bg = "pink",width = 10,font = ("黑体",20)).pack(side = LEFT,padx = 5,pady = 5) Label_plus = Label(root,text = "+",font = ("黑体",20)).pack(side = LEFT,padx = 5,pady = 5) #文本框 Entry02 = Entry(root,bg = "pink",width = 10,font = ("黑体",20)).pack(side = LEFT,padx = 5,pady = 5) Label_equal = Label(root,text = "=",font = ("黑体",20)).pack(side = LEFT,padx = 5,pady = 5) #文本框 Entry03 = Entry(root,bg = "green",width = 10,font = ("华文黑体",20)).pack(side = LEFT,padx = 5,pady = 5) Button01 = Button(root,text = "计算",width = 10,height = 2,font = ("华文黑体",15)).pack(side = LEFT,padx = 10,pady = 5) # 运行 root.mainloop()
运行效果演示:
以上是python tkinter实现画出计算器界面的示例的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。