# -*- coding: utf-8 -*-
import tkinter as tk
import math
window = tk.Tk()
window.title('一元一次方程计算器')
k = tk.Label(window,text='请输入一元一次方程的参数:',font=('Arial',12))
k.grid(row=0,column=0,columnspan=3,sticky='w',padx=10,pady=10)
x02 = tk.Entry(window)
x02.grid(row=1,column=0,padx=10)
p1 = tk.Label(window,text=' x + ',font=('Arial',12))
p1.grid(row=1,column=1)
x01 = tk.Entry(window)
x01.grid(row=1,column=2)
p2 = tk.Label(window,text=' =',font=('Arial',12))
p2.grid(row=1,column=3)
def cal():
a = float(x02.get())
b = float(x01.get())
if a == 0:
resu.set('无解')
else:
resu.set(-b/a)
b1 = tk.Button(window,text='计算',width=10,command=cal)
b1.grid(row=1,column=6,padx=20)
resu = tk.StringVar()
l = tk.Label(window,textvariable=resu,font=('Arial',12))
l.grid(row=3,column=0,sticky='w',columnspan=3,padx=10)
window.mainloop()