
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
from math import* import tkinter from tkinter import* from tkinter import messagebox def out(): wd.quit() def xuli(): try: a1=float(txt_11.get()) b1=float(txt_12.get()) c1=float(txt_13.get()) a2=float(txt_21.get()) b2=float(txt_22.get()) c2=float(txt_23.get()) D=a1*b2-a2*b1 Dx=b2*c1-b1*c2 Dy=a1*c2-a2*c1 if (D!=0): kq="Hệ Phương Trình Có Nghiệm: x= "+str(round(Dx/D,2))+" và y= "+str(round(Dy/D,2)) messagebox.showinfo("Thông Báo",kq) elif (Dx==0) and (Dy==0): kq="Hệ Phương Trình Vô Số Nghiệm" messagebox.showinfo("Thông Báo","Hệ Phương Trình Vô Số Nghiệm") else: kq="Hệ Phương Trình Vô Nghiệm" messagebox.showinfo("Thông Báo","Hệ Phương Trình Vô Nghiệm") out=StringVar() out.set(kq) txt = Entry(wd, textvariable=out,font=('tahoma',14,'bold'),fg='blue') txt.place(x=150, y=300, width=500, height=60) txt=Entry(state=DISABLED) except: messagebox.showwarning("Cảnh báo","Xin lỗi! Hệ số không hợp lệ") def mouse_in1(event): kq['background']='blue' def mouse_out1(event): kq['background']='SystemButtonFace' def mouse_in2(e): out['background']='red' def mouse_out2(e): out['background']='SystemButtonFace' wd = Tk() wd.geometry("700x500") wd.title("ngoccs.edu.vn - GIẢI HỆ PHƯƠNG TRÌNH") wd.iconbitmap("ngoccs.ico") wd.configure(bg="black") lb_tb=Label(wd,text="GIẢI HỆ PHƯƠNG TRÌNH BẬC NHẤT HAI ẨN",bg="black",fg="white", font=("Tahoma",14,"bold")) lb_tb.place(x=150, y=30) lb1=Label(wd,text="Hệ số phương trình 1: ",bg="black",fg="white", font=("Tahoma",13,"bold")) lb1.place(x=100, y=100) lb11=Label(wd,text="a1 = ",bg="black",fg="white",font=("Tahoma",13,"bold")) lb11.place(x=100,y=150) lb12=Label(wd,text="b1 = ",bg="black",fg="white",font=("Tahoma",13,"bold")) lb12.place(x=100,y=200) lb13=Label(wd,text="c1 = ",bg="black",fg="white",font=("Tahoma",13,"bold")) lb13.place(x=100,y=250) txt_11=Entry(wd,font=("tahoma",15,"bold"),width=10,border=1) txt_11.place(x=200,y=150) txt_12=Entry(wd,font=("Tahoma",15,"bold"),width=10,border=1) txt_12.place(x=200, y=200) txt_13=Entry(wd,font=("Tahoma",15,"bold"),width=10,border=1) txt_13.place(x=200,y=250) lb2=Label(wd,text="Hệ số phương trình 2: ",bg="black",fg="white", font=("Tahoma", 13, "bold")) lb2.place(x=400, y=100) lb21=Label(wd,text="a2 = ",bg="black",fg="white",font=("tahoma",13,"bold")) lb21.place(x=400,y=150) lb22=Label(wd,text="b2 = ",bg="black",fg="white",font=("tahoma",13,"bold")) lb22.place(x=400,y=200) lb23=Label(wd,text="c2 = ",bg="black",fg="white",font=("tahoma",13,"bold")) lb23.place(x=400,y=250) txt_21=Entry(wd,font=("Tahoma",15, "bold"),width=10,border=1) txt_21.place(x=450,y=150) txt_22=Entry(wd,font=("Tahoma",15,"bold"),width=10,border=1) txt_22.place(x=450,y=200) txt_23=Entry(wd,font=("Tahoma",15, "bold"),width=10,border=1) txt_23.place(x=450, y=250) txt = Entry(wd,text="", font=("tahoma",20, "bold"),state=DISABLED, border=1) txt.place(x=150, y=300, width=500, height=60) kq=Button(wd, text="Giải HPT", bg="white", fg="black", font=("Tahoma",12,"bold"), command=xuli) kq.place(x=200,y=400) out=Button(wd, text="Thoát", bg="white", fg="black", font=("Tahoma",12, "bold"), command=out) out.place(x=500,y=400) kq.bind('<Enter>',mouse_in1) kq.bind('<Leave>',mouse_out1) out.bind('<Enter>',mouse_in2) out.bind('<Leave>',mouse_out2) wd.mainloop() |