请用Python语言编写一个简易的计算器程序。
from tkinter import *
reset=True
def buttonCallBack(event):
global label
global reset
num=event.widget['text']
if num=='C':
label['text']="0"
return
if num in "=":
label['text']=str(eval(label['text']))
reset=True
return
s=label['text']
if s=='0' or reset==True:
s=""
reset=False
label['text']=s+num #主窗口
root=Tk() root.wm_title(" 计算器 ") #显示栏 1 label=Label(root,text="0",background="white",anchor="e")
label['width']=35
label['height']=2
label.grid(row=1,columnspan=4,sticky=W) #按钮
showText="789/456*123-0.C+"
for i in range(4):
for j in range(4):
b=Button(root,text=showText[i*4+j],width=7)
b.grid(row=i+2,column=j)
b.bind("",buttonCallBack) showText="()"
for i in range(2):www.jb51.net
b=Button(root,text=showText[i],width=7)
b.grid(row=6,column=2+i)
b.bind("",buttonCallBack) b=Button(root,text="=")
b.grid(row=6,columnspan=2,sticky="we")
b.bind("",buttonCallBack)
root.mainloop()
暂无解析
在制作滚动按钮过程中:
Photoshop中要暂时隐藏路径在图像中的形状,执行以下的哪一种操作?()
Inmostcitiesandtowns,thehighvolumesofroadtrafficbecomeaproblem.Whatarethecausesofthatandwhatactionscouldbetakentosolvetheproblem?
学校充分意识到校服可以在校内建立一种团结感。
Manypeoplebelievethatscientificresearchshouldbecarriedoutandcontrolledbythegovernmentratherthanprivatecompanies.Towhatextentdoyouagreeordisagree?
Turnoverrate
Idaresaythatthepriceweoffercomparefavorablywithanyquotationyoucanobtainelsewhere.
Locateacontract
AccordingtoUKofficialstatistics,everyyearabout2000livesarelostthroughoccupationaldiseaseorinjury,about20,000majorindustrialinjuriesoccur(e.g.skullfracture,lossofsight)andthereareabout200,000injuriesresultinginaworkdisabilityof3daysormore.
PopularSportsinChina.
题目:ResourcePlanningManager:AssessmentofSuitabilityforHome-basedWorking.
兼职要求学生遵守纪律并相应地分配时间。