도순씨의 코딩일지
두근두근파이썬 10장 2번 본문
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 | from tkinter import * total = 0 window = Tk() label = Label(window, text = "현재 합계:" + str(total)) label.grid(row = 0, column = 0, columnspan = 3) entry = Entry(window) entry.grid(row = 1, column = 0, columnspan = 3) def plus(): global total total = total + float(entry.get()) label = Label(window, text = "현재 합계:" + str(total)) label.grid(row = 0, column = 0, columnspan = 3) def minus(): global total total = total - float(entry.get()) label = Label(window, text = "현재 합계:" + str(total)) label.grid(row = 0, column = 0, columnspan = 3) def reset(): global total total = 0 label = Label(window, text = "현재 합계:" + str(total)) label.grid(row = 0, column = 0, columnspan = 3) b1 = Button(window, text = "더하기(+)", command = plus).grid(row=2, column = 0) b2 = Button(window, text = "빼기(-)", command = minus).grid(row=2, column = 1) b3 = Button(window, text = "초기화", command = reset).grid(row=2, column = 2) | cs |
'𝐏𝐑𝐎𝐆𝐑𝐀𝐌𝐌𝐈𝐍𝐆 > 𝐏𝐘𝐓𝐇𝐎𝐍' 카테고리의 다른 글
파이썬 :: 문자열 관련 함수 (0) | 2020.07.15 |
---|
Comments