這篇文章主要介紹python tkinter實現(xiàn)畫出計算器界面的示例,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
成都創(chuàng)新互聯(lián)主營廣陵網(wǎng)站建設的網(wǎng)絡公司,主營網(wǎng)站建設方案,app軟件開發(fā)公司,廣陵h5微信小程序定制開發(fā)搭建,廣陵網(wǎng)站營銷推廣歡迎廣陵等地區(qū)企業(yè)咨詢
需求:設計能計算加法的計算器界面
代碼演示:
from tkinter import * # 創(chuàng)建窗體 root = Tk() #添加標題 root.title("求兩數(shù)之和") 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實現(xiàn)畫出計算器界面的示例的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關知識,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道!