0

## Python 服裝

Han iT邦新手 3 級 ‧ 2020-03-27 14:23:40 檢舉

1212313 iT邦新手 5 級 ‧ 2020-03-27 14:24:43 檢舉

dragonH iT邦超人 5 級 ‧ 2020-03-27 14:25:22 檢舉
>假設上衣300元、褲子350元與背心400元，使用者可以自行輸入三種服裝的數量，請設計一個程式計算訂購服裝的總金額。
total = 300x+350y+400z
1212313 iT邦新手 5 級 ‧ 2020-03-27 14:27:07 檢舉

1212313 iT邦新手 5 級 ‧ 2020-03-27 14:27:55 檢舉

1212313 iT邦新手 5 級 ‧ 2020-03-27 14:32:08 檢舉

1212313 iT邦新手 5 級 ‧ 2020-03-27 14:39:54 檢舉

sslinn iT邦新手 5 級 ‧ 2020-03-27 16:18:12 檢舉

wingkawa iT邦新手 4 級 ‧ 2020-03-27 17:51:26 檢舉

echochio iT邦高手 1 級 ‧ 2020-03-29 17:50:52 檢舉

### 1 個回答

0
echochio
iT邦高手 1 級 ‧ 2020-03-29 18:04:14

https://www.javatpoint.com/python-tkinter-entry

``````import tkinter as tk
from functools import partial

def call_result(label_result, n1, n2, n3):
num1 = (n1.get())
num2 = (n2.get())
num3 = (n3.get())
result = int(num1)+int(num2)+int(num3)
label_result.config(text="Result = %d" % result)
return

root = tk.Tk()
root.geometry('400x200+100+200')

root.title('Calculator')

number1 = tk.StringVar()
number2 = tk.StringVar()
number3 = tk.StringVar()

labelNum1 = tk.Label(root, text="A").grid(row=1, column=0)
labelNum2 = tk.Label(root, text="B").grid(row=2, column=0)
labelNum3 = tk.Label(root, text="C").grid(row=3, column=0)

labelResult = tk.Label(root)
labelResult.grid(row=7, column=2)

entryNum1 = tk.Entry(root, textvariable=number1).grid(row=1, column=2)
entryNum2 = tk.Entry(root, textvariable=number2).grid(row=2, column=2)
entryNum3 = tk.Entry(root, textvariable=number3).grid(row=3, column=2)

call_result = partial(call_result, labelResult, number1, number2, number3)

buttonCal = tk.Button(root, text="Calculate", command=call_result).grid(row=4, column=0)

root.mainloop()
``````