import tkinter
window = tkinter.Tk()
window.title('电话计费')
window.geometry('260x170')
def calculate():
call = var.get()
min = e1.get()
if call == '0':
money = 0.40*int(min)
l2.config(text='国内长途'+str(min)+'分钟,话费'+str('%.2f'%money)+'元')
else:
money = 0.20*int(min)
l2.config(text='本地通话'+str(min)+'分钟,话费'+str('%.2f'%money)+'元')
var=tkinter.StringVar()
var.set(0)
b1 = tkinter.Radiobutton(window,text='国内长途',variable=var,value=0)
b1.pack()
b2 = tkinter.Radiobutton(window,text='本地通话',variable=var,value=1)
b2.pack()
l1 = tkinter.Label(window, text='输入通话时长')
l1.pack()
e1 = tkinter.Entry(window, width=20)
e1.pack()
b3 = tkinter.Button(window, text="计算", command=calculate)
b3.pack()
l2=tkinter.Label(window,text='')
l2.pack()
window.mainloop()
注意缩进
效果图
a=inputbox("请输入时间","提示")if a="" then exit sub
b=iif(a<3,0.5,(a-3)*0.15+0.5)
if hour(time)<7 or hour(time)>19 then b=b/2
msgbox "话费为:" &b
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)