2017年10月15日 星期日

Tkinter Create Multiplication Table



from tkinter import*
root=Tk()
root.geometry('500x500')
root.title('Multiplication table')
def button1():
x='1*1=1\n1*2=2\n1*3=3\n1*4=4\n1*5=5\n1*6=6\n1*7=7\n1*8=8\n1*9=9\n1*10=10\n'
lbl.config(text=x)
def button2():
y='2*1=2\n2*2=4\n2*3=6\n2*4=8\n2*5=10\n2*6=12\n2*7=14\n2*8=16\n2*9=18\n2*10=20\n'
lbl.config(text=y)
def button3():
z='3*1=3\n3*2=6\n3*3=9\n3*4=12\n3*5=15\n3*6=18\n3*7=21\n3*8=24\n3*9=27\n3*10=30\n'
lbl.config(text=z)
def button4():
z='4*1=4\n4*2=8\n4*3=12\n4*4=16\n4*5=20\n4*6=24\n4*7=28\n4*8=32\n4*9=36\n4*10=40\n'
lbl.config(text=z)
def button5():
z='5*1=5\n5*2=10\n5*3=15\n5*4=20\n5*5=25\n5*6=30\n5*7=35\n5*8=40\n5*9=45\n5*10=50\n'
lbl.config(text=z)
def button6():
z='6*1=6\n6*2=12\n6*3=18\n6*4=24\n6*5=30\n6*6=36\n6*7=42\n6*8=48\n6*9=54\n6*10=60\n'
lbl.config(text=z)
def button7():
z='7*1=7\n7*2=14\n7*3=21\n7*4=28\n7*5=35\n7*6=42\n7*7=49\n7*8=56\n7*9=63\n7*10=70\n'
lbl.config(text=z)
def button8():
z='8*1=8\n8*2=16\n8*3=24\n8*4=32\n8*5=40\n8*6=42\n8*7=56\n8*8=64\n8*9=72\n8*10=80\n'
lbl.config(text=z)
def button9():
z='9*1=9\n9*2=18\n9*3=27\n9*4=36\n9*5=45\n9*6=54\n9*7=63\n9*8=72\n9*9=81\n9*10=90\n'
lbl.config(text=z)
def button10():
z='10*1=10\n10*2=20\n10*3=30\n10*4=40\n10*5=50\n10*6=60\n10*7=70\n10*8=80\n10*9=90\n10*10=100\n'
lbl.config(text=z)
def button11():
z='11*1=11\n11*2=22\n11*3=33\n11*4=44\n11*5=55\n11*6=66\n11*7=77\n11*8=88\n11*9=99\n11*10=110\n'
lbl.config(text=z)
def button12():
z='12*1=12\n12*2=24\n12*3=36\n12*4=48\n12*5=60\n12*6=72\n12*7=84\n12*8=96\n 12*9=108\n  12*10=120\n'
lbl.config(text=z)
def button13():
z='13*1=13\n13*2=26\n13*3=39\n13*4=52\n13*5=65\n13*6=78\n13*7=91\n13*8=104\n13*9=117\n13*10=130\n'
lbl.config(text=z)
def button14():
z='14*1=14\n14*2=28\n14*3=42\n14*4=56\n14*5=70\n14*6=84\n14*7=98\n14*8=112\n14*9=126\n14*10=140\n'
lbl.config(text=z)
def button15():
z='15*1=15\n15*2=30\n15*3=45\n15*4=60\n15*5=75\n15*6=90\n15*7=105\n15*8=120\n15*9=135\n15*10=150\n'
lbl.config(text=z)
def buttonC():
x=' '
lbl.config(text=x)
frm1=Frame(root,bg='lightgreen')
frm2=Frame(root,bg='lightblue')
frm1.place(x=0,y=0,width=350,height=500)
frm2.place(x=250,y=0,width=350,height=500)
lbl=Label(frm2,bg='lightblue',font=('Calibri',18,'bold'))
lbl.place(x=0,y=0,width=350,height=500)

btn1=Button(frm1,text='X1',command=button1,font=('Arial',16,'bold'))
btn2=Button(frm1,text='X2',command=button2,font=('Arial',16,'bold'))
btn3=Button(frm1,text='X3',command=button3,font=('Arial',16,'bold'))
btn4=Button(frm1,text='X4',command=button4,font=('Arial',16,'bold'))
btn5=Button(frm1,text='X5',command=button5,font=('Arial',16,'bold'))
btn6=Button(frm1,text='X6',command=button6,font=('Arial',16,'bold'))
btn7=Button(frm1,text='X7',command=button7,font=('Arial',16,'bold'))
btn8=Button(frm1,text='X8',command=button8,font=('Arial',16,'bold'))
btn9=Button(frm1,text='X9',command=button9,font=('Arial',16,'bold'))
btn10=Button(frm1,text='X10',command=button10,font=('Arial',16,'bold'))
btn11=Button(frm1,text='X11',command=button11,font=('Arial',16,'bold'))
btn12=Button(frm1,text='X12',command=button12,font=('Arial',16,'bold'))
btn13=Button(frm1,text='X13',command=button13,font=('Arial',16,'bold'))
btn14=Button(frm1,text='X14',command=button14,font=('Arial',16,'bold'))
btn15=Button(frm1,text='X15',command=button15,font=('Arial',16,'bold'))
btnC=Button(frm1,text='CLEAR',command=buttonC,font=('Arial',16,'bold'))

btn1.place(x=20,y=50,width=60,height=40)
btn2.place(x=100,y=50,width=60,height=40)
btn3.place(x=180,y=50,width=60,height=40)
btn4.place(x=20,y=120,width=60,height=40)
btn5.place(x=100,y=120,width=60,height=40)
btn6.place(x=180,y=120,width=60,height=40)
btn7.place(x=20,y=190,width=60,height=40)
btn8.place(x=100,y=190,width=60,height=40)
btn9.place(x=180,y=190,width=60,height=40)
btn10.place(x=20,y=260,width=60,height=40)
btn11.place(x=100,y=260,width=60,height=40)
btn12.place(x=180,y=260,width=60,height=40)
btn13.place(x=20,y=330,width=60,height=40)
btn14.place(x=100,y=330,width=60,height=40)
btn15.place(x=180,y=330,width=60,height=40)
btnC.place(x=50,y=400,width=160,height=40)


mainloop()

沒有留言:

張貼留言

113 學年度第 1 學期 RFID應用課程 Arduino程式

113 學年度第 1 學期 RFID應用課程 Arduino程式 https://www.mediafire.com/file/zr0h0p3iosq12jw/MFRC522+(2).7z/file 內含修改過後的 MFRC522 程式庫 (原程式有錯誤) //定義MFRC522...