给我家宝贝的作业答案

 


import tkinter as tk
from tkinter import ttk
class PyWinDesign:
def __init__(self, 启动窗口):
self.启动窗口 = 启动窗口
self.启动窗口.title('计算器')
self.启动窗口.resizable(width=False, height=False)
screenwidth = self.启动窗口.winfo_screenwidth()
screenheight = self.启动窗口.winfo_screenheight()
size = '%dx%d+%d+%d' % (230, 239, (screenwidth - 230) / 2, (screenheight - 239) / 2)
self.启动窗口.geometry(size)

self.按钮1_标题 = tk.StringVar()
self.按钮1_标题.set('清空')
self.按钮1 = tk.Button(self.启动窗口,textvariable=self.按钮1_标题)
self.按钮1.place(x=118,y=31,width=110,height=39)

self.编辑框1 = tk.Text(self.启动窗口,wrap=tk.NONE)
self.编辑框1.insert(tk.END,'')
self.编辑框1.place(x=0,y=1,width=226,height=27)

self.按钮2_标题 = tk.StringVar()
self.按钮2_标题.set('退回')
self.按钮2 = tk.Button(self.启动窗口,textvariable=self.按钮2_标题)
self.按钮2.place(x=4,y=31,width=111,height=38)

self.按钮3_标题 = tk.StringVar()
self.按钮3_标题.set('7')
self.按钮3 = tk.Button(self.启动窗口,textvariable=self.按钮3_标题)
self.按钮3.place(x=6,y=70,width=48,height=36)

self.按钮4_标题 = tk.StringVar()
self.按钮4_标题.set('8')
self.按钮4 = tk.Button(self.启动窗口,textvariable=self.按钮4_标题)
self.按钮4.place(x=64,y=70,width=48,height=36)

self.按钮5_标题 = tk.StringVar()
self.按钮5_标题.set('9')
self.按钮5 = tk.Button(self.启动窗口,textvariable=self.按钮5_标题)
self.按钮5.place(x=122,y=70,width=48,height=36)

self.按钮6_标题 = tk.StringVar()
self.按钮6_标题.set('/')
self.按钮6 = tk.Button(self.启动窗口,textvariable=self.按钮6_标题)
self.按钮6.place(x=180,y=70,width=48,height=36)

self.按钮7_标题 = tk.StringVar()
self.按钮7_标题.set('4')
self.按钮7 = tk.Button(self.启动窗口,textvariable=self.按钮7_标题)
self.按钮7.place(x=7,y=115,width=48,height=36)

self.按钮8_标题 = tk.StringVar()
self.按钮8_标题.set('5')
self.按钮8 = tk.Button(self.启动窗口,textvariable=self.按钮8_标题)
self.按钮8.place(x=65,y=115,width=48,height=36)

self.按钮9_标题 = tk.StringVar()
self.按钮9_标题.set('6')
self.按钮9 = tk.Button(self.启动窗口,textvariable=self.按钮9_标题)
self.按钮9.place(x=123,y=115,width=48,height=36)

self.按钮10_标题 = tk.StringVar()
self.按钮10_标题.set('*')
self.按钮10 = tk.Button(self.启动窗口,textvariable=self.按钮10_标题)
self.按钮10.place(x=180,y=115,width=48,height=36)

self.按钮11_标题 = tk.StringVar()
self.按钮11_标题.set('1')
self.按钮11 = tk.Button(self.启动窗口,textvariable=self.按钮11_标题)
self.按钮11.place(x=6,y=155,width=48,height=36)

self.按钮12_标题 = tk.StringVar()
self.按钮12_标题.set('2')
self.按钮12 = tk.Button(self.启动窗口,textvariable=self.按钮12_标题)
self.按钮12.place(x=66,y=155,width=48,height=36)

self.按钮13_标题 = tk.StringVar()
self.按钮13_标题.set('3')
self.按钮13 = tk.Button(self.启动窗口,textvariable=self.按钮13_标题)
self.按钮13.place(x=123,y=155,width=48,height=36)

self.按钮14_标题 = tk.StringVar()
self.按钮14_标题.set('-')
self.按钮14 = tk.Button(self.启动窗口,textvariable=self.按钮14_标题)
self.按钮14.place(x=180,y=156,width=48,height=36)

self.按钮15_标题 = tk.StringVar()
self.按钮15_标题.set('0')
self.按钮15 = tk.Button(self.启动窗口,textvariable=self.按钮15_标题)
self.按钮15.place(x=7,y=197,width=48,height=36)

self.按钮16_标题 = tk.StringVar()
self.按钮16_标题.set('.')
self.按钮16 = tk.Button(self.启动窗口,textvariable=self.按钮16_标题)
self.按钮16.place(x=65,y=197,width=48,height=36)

self.按钮17_标题 = tk.StringVar()
self.按钮17_标题.set('=')
self.按钮17 = tk.Button(self.启动窗口,textvariable=self.按钮17_标题)
self.按钮17.place(x=123,y=198,width=48,height=36)

self.按钮18_标题 = tk.StringVar()
self.按钮18_标题.set('+')
self.按钮18 = tk.Button(self.启动窗口,textvariable=self.按钮18_标题)
self.按钮18.place(x=180,y=198,width=48,height=36)





if __name__ == '__main__':
root = tk.Tk()
app = PyWinDesign(root)
root.mainloop()

 
点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注