割り勘アプリ(Python)
import tkinter as tk def bt_click(): global amount amount=int(entry_money.get()) global people people=int(entry_members.get()) dnum=amount/people pay=dnum//100*100 if dnum>pay: pay=int(pay+100) payorg=amount-pay*(people-1) msg='一人あたり',int(pay),'円',people-1,'(人)、幹事は',int(payorg),'円です' no_label=tk.Label(root,width=400,height=15,bg='skyblue') no_label.place(x=10,y=290) lavel=tk.Label(root,text=msg,font=('Arial',15),bg='skyblue') lavel.place(x=10,y=290) amount=None people=None root=tk.Tk() root.title('割り勘くん') canvas=tk.Canvas(root,width=400,height=600,bg='skyblue') canvas.pack() label_money=tk.Label(root,text='金額',font=('Arial',20),bg='skyblue') label_money.place(x=10,y=60) entry_money=tk.Entry(width=20) entry_money.place(x=10,y=90) label_members=tk.Label(root,text='人数',font=('Arial',20),bg='skyblue') label_members.place(x=10,y=140) entry_members=tk.Entry(width=20) entry_members.place(x=10,y=170) btn=tk.Button(root,text='計算する',font=('Arial',20),command=bt_click) btn.place(x=10,y=230) root.mainloop()