Assalomu alaykum men sizlarga Python dasturlash tilida, tkinter modulida testlarni javobini tekshirib beruvchi dastur tuzishni o'rgatmoqchiman. Tkinter-bu pythonda GUI oynasida ishlashga yordam beruvchi moduli ya'ni bu modul orqali grafik interfeys yaratish mumkin.

# tkinter modulini yuklab olib, tkinter onasini ochamiz.
from tkinter import *
w=Tk()
# w bu yerda oyna nomi.
w.configure(bg='cyan')
w.geometry('310x450')
w.title('Test checker')

Xohishga ko'ra tkinter oynasiga logotip qo'yamiz. Rasm .ico formatida bo'lishi shart! 

 

# 'B:\py_to_exe\Test.ico' bu icon joylashgan yerga yo'l
w.iconbitmap(r'B:\py_to_exe\Test.ico')

Dasturga javoblar abcdbcba...(30 ta) holatda kiritilladi va unga mos javobni tekshiruvchi funksiya tuzamiz.

def fun1(a,b):
    if a==b:
        x=1
    else:
        x=0
    return x

Va endi dasturga kiritish, chiqarish maydonlarini hamda tugmalarni joylashtiramiz.

t1=str("TESTLARNI TEKSHIRUVCHI DASTUR"+'\n'*2+"To'g'ri javoblarni kiriting:")
# Label - bu matnni chiqarish mumkin bo'lgan maydon
# .grid(row=0,column=0) - bu nuqta maydonning joylashgan o'rni (0-qator,0-ustun) 
l1=Label(w,width=43,height=3,bg='cyan',text=t1)
l1.grid(row=0,column=0)
# Entry matn kiritish mumkin bo'lgan maydon.
e1=Entry(w,width=35)
e1.grid(row=1,column=0)
t2=str('\n'*2+'Abituriyent javoblaini kiriting:'+'\n'*2)
l2=Label(w,width=43,height=3,bg='cyan',text=t2)
l2.grid(row=2,column=0)
e2=Entry(w,width=35)
e2.grid(row=3,column=0)
def fun2():
    t_o1.delete(0.0,END)
    k=str(e1.get())
    m=str(e2.get())
    if len(k)==30:
        if len(m)==30:
            na=fun1(k[0],m[0])+fun1(k[1],m[1])+fun1(k[2],m[2])+fun1(k[3],m[3])+fun1(k[4],m[4])+fun1(k[5],m[5])+fun1(k[6],m[6])+fun1(k[7],m[7])+fun1(k[8],m[8])+fun1(k[9],m[9])+fun1(k[10],m[10])+fun1(k[11],m[11])+fun1(k[12],m[12])+fun1(k[13],m[13])+fun1(k[14],m[14])+fun1(k[15],m[15])+fun1(k[16],m[16])+fun1(k[17],m[17])+fun1(k[18],m[18])+fun1(k[19],m[19])+fun1(k[20],m[20])+fun1(k[21],m[21])+fun1(k[22],m[22])+fun1(k[23],m[23])+fun1(k[24],m[24])+fun1(k[25],m[25])+fun1(k[26],m[26])+fun1(k[27],m[27])+fun1(k[28],m[28])+fun1(k[29],m[29])
            n2=str(na)
            n1=str('Natija:'+'\n'+' 1)'+ str(fun1(k[0],m[0]))+' '*3+'11)'+str(fun1(k[10],m[10]))+' '*3+'21)'+str(fun1(k[20],m[20]))+' '*3+'\n'+' 2)'+str(fun1(k[1],m[1]))+' '*3+'12)'+ str(fun1(k[11],m[11]))+' '*3+'22)'+ str(fun1(k[21],m[21]))+' '*3+'\n'+' 3)'+ str(fun1(k[2],m[2]))+' '*3+'13)'+ str(fun1(k[12],m[12]))+' '*3+'23)'+str(fun1(k[22],m[22]))+' '*3+'\n'+' 4)'+ str(fun1(k[3],m[3]))+' '*3+'14)'+str(fun1(k[13],m[13]))+' '*3+'24)'+str(fun1(k[23],m[23]))+' '*3+'\n'+' 5)'+str(fun1(k[4],m[4]))+' '*3+'15)'+ str(fun1(k[14],m[14]))+' '*3+'25)'+ str(fun1(k[24],m[24]))+' '*3+'\n'+' 6)'+ str(fun1(k[5],m[5]))+' '*3+'16)'+ str(fun1(k[15],m[15]))+' '*3+'26)'+str(fun1(k[25],m[25]))+' '*3+'\n'+' 7)'+ str(fun1(k[6],m[6]))+' '*3+'17)'+ str(fun1(k[16],m[16]))+' '*3+'27)'+str(fun1(k[26],m[26]))+' '*3+'\n'+' 8)'+ str(fun1(k[7],m[7]))+' '*3+'18)'+str(fun1(k[17],m[17]))+' '*3+'28)'+str(fun1(k[27],m[27]))+' '*3+'\n'+' 9)'+str(fun1(k[8],m[8]))+' '*3+'19)'+ str(fun1(k[18],m[18]))+' '*3+'29)'+ str(fun1(k[28],m[28]))+' '*3+'\n'+'10)'+ str(fun1(k[9],m[9]))+' '*3+'20)'+ str(fun1(k[19],m[19]))+' '*3+'30)'+str(fun1(k[29],m[29]))+' '*3+'\n'+'Jami:'+n2+'ball')
        else:
            n1=str('Abituriyent javobi 30ta emas,'+str(len(m))+'ta')
    else:
        n1=str("Tog'ri javob 30ta emas,"+str(len(k))+'ta')
    t_o1.insert(END,n1)
# Text - esa natijani chiqaruvchi maydon.
t_o1=Text(w,width=35,height=12)
t_o1.grid(row=7,column=0)
l3=Label(w,width=43,height=2,bg='cyan',text='\n')
l3.grid(row=4,column=0)
b1=Button(w,text="Tekshir",command=fun2)
b1.grid(row=5,column=0)
l4=Label(w,width=43,height=2,bg='cyan',text='\n')
l4.grid(row=6,column=0)
w.mainloop()
1 lar  to'gri  javoblar  0 lar esa noto'g'ri.
1 lar  to'gri  javoblar  0 lar esa noto'g'ri.

Va qarabsiz-ki dastur tayyor.

Agar javoblar 30ta bolmasa dastur tekshirmaydi.
Agar javoblar 30ta bolmasa dastur tekshirmaydi.