우분투의 TKinter
에 파이썬 프로그램을 작성하여 Text
위젯에있는 특정 폴더의 파일 이름을 으로 가져오고 인쇄합니다. Text
위젯에있는 이전의 파일 이름에 파일 이름을 추가하는 것입니다.하지만 먼저 파일 이름을 지우고 새 파일 이름 목록을 추가하고 싶습니다. 그러나 Text
위젯의 이전 목록 인 개의 파일 이름을 지우려고 고심하고 있습니다.Tkinter Text 위젯의 내용을 지우거나 지우는 방법은 무엇입니까?
누군가 Text
위젯을 삭제하는 방법을 설명해 주실 수 있습니까?
Screenshoot 및 코딩은 아래주고있다 :
import os
from Tkinter import *
def viewFile():
path = os.path.expanduser("~/python")
for f in os.listdir(path):
tex.insert(END, f + "\n")
if __name__ == '__main__':
root = Tk()
step= root.attributes('-fullscreen', True)
step = LabelFrame(root, text="FILE MANAGER", font="Arial 20 bold italic")
step.grid(row=0, columnspan=7, sticky='W', padx=100, pady=5, ipadx=130, ipady=25)
Button(step, text="File View", font="Arial 8 bold italic", activebackground=
"turquoise", width=30, height=5, command=viewFile).grid(row=1, column=2)
Button(step, text="Quit", font="Arial 8 bold italic", activebackground=
"turquoise", width=20, height=5, command=root.quit).grid(row=1, column=5)
tex = Text(master=root)
scr=Scrollbar(root, orient=VERTICAL, command=tex.yview)
scr.grid(row=2, column=2, rowspan=15, columnspan=1, sticky=NS)
tex.grid(row=2, column=1, sticky=W)
tex.config(yscrollcommand=scr.set, font=('Arial', 8, 'bold', 'italic'))
root.mainloop()
텍스트 위젯에 대한 문서를 읽으셨습니까? 이 기능은 명확하게 문서화되어 있습니다. 당신이 고군분투하고 있다고 말하면서, 당신이 시도한 것을 보여줄 수 있습니까? –
아마 http://effbot.org/tkinterbook/entry.htm#Tkinter.Entry.delete-method –
내 요구 결과를 얻으려면 여기에 하나의 성명을 쓰십시오. – Fahadkalis