Notice
Recent Posts
Recent Comments
Link
«   2024/10   »
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
Tags
more
Archives
Today
Total
관리 메뉴

main

[Python] tkinter 사용 예제 - 슬래쉬, 역슬래쉬 변경 GUI 본문

Python

[Python] tkinter 사용 예제 - 슬래쉬, 역슬래쉬 변경 GUI

1984 2022. 9. 2. 20:26

실행화면

import tkinter

def Convert():
    text = textExample.get("1.0","end")
    if '/' in text:
        text = text.replace('/', '\\')
    elif '\\' in text :
        text = text.replace('\\', '/')
    else :
        print('변경할 문자가 없습니다.')
    textExample.delete(1.0,"end")
    textExample.insert(1.0, text)

# 화면 생성
window = tkinter.Tk()
# 제목
window.title("Convert Slash")
# 화면 크기 설정
window.geometry('320x240')
# label
label = tkinter.Label(window, text="입력란", font=("돋음", 10))
# textbox
textExample=tkinter.Text(window, height=10)
textExample.pack()
# 버튼
btnRead=tkinter.Button(window, height=1, width=10, text="Convert", command=Convert)
btnRead.pack()
# 프로그램이 종료될 때까지 실행됨
window.mainloop()
Comments