如何清洁 / 删除文本窗口小部件内容 Tkinter?
我写了一个节目 Python 在
在 Ubuntu 用于进口和打印
从窗口小部件中的特定文件夹中的文件名
.
这只是将文件名添加到窗口小部件中的先前文件名。
, 但我想首先清除它,然后添加一个新的文件名列表。
但我正在尝试清理以前的小部件列表
经过
文件名。
有人可以解释如何清洁小部件
?
屏幕截图和编码如下:
https://i.stack.imgur.com/B7ASq.png
TKinter
在 Ubuntu 用于进口和打印
从窗口小部件中的特定文件夹中的文件名
Text
.
这只是将文件名添加到窗口小部件中的先前文件名。
Text
, 但我想首先清除它,然后添加一个新的文件名列表。
但我正在尝试清理以前的小部件列表
Text
经过
文件名。
有人可以解释如何清洁小部件
Text
?
屏幕截图和编码如下:
https://i.stack.imgur.com/B7ASq.png
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//
没有找到相关结果
已邀请:
6 个回复
八刀丁二
赞同来自:
你也可以尝试一下。
莫问
赞同来自:
它为我工作。
http://effbot.org/tkinterbook/text.htm#patterns
这与输入元件的清洁不同,如下所示:
entry.delete/0,END/ #note 0 反而 1.0
二哥
赞同来自:
这是一个例子
, 如前所述。
使用
允许我们删除内容而不定义实际功能。
我希望这个能帮上忙
窦买办
赞同来自:
郭文康
赞同来自:
当您需要清除它时,调用以下代码。 在我的情况下有一个按钮 Save, 从输入文本字段中保存数据,然后按下按钮文本字段已清除
莫问
赞同来自:
或者如果你这样做了
这应该是工作