Self Check
1
from tkinter import *
sayhello = ['안녕하세요', 'hello', '니하오', '봉쥬르']
idx = 0
# ----- 프로그램 기능 부분 ----------
def plus():
global idx
idx = (idx + 1) % 4
hello_txt.set(sayhello[idx])
def minus():
global idx
idx = (idx - 1) % 4
hello_txt.set(sayhello[idx])
# ----- 프로그램 화면 부분 -----
root = Tk()
root.geometry('250x100')
btn_minus = Button(root, text='<--', command=minus, width=5)
btn_minus.grid(row=0, column=0)
hello_txt = StringVar()
hello_lbl = Label(root, textvariable=hello_txt, width=20)
hello_lbl.grid(row=0, column=1)
btn_plus = Button(root, text='-->', command=plus, width=5)
btn_plus.grid(row=0, column=2)
root.mainloop()