python - 为什么 TextBox 没有属性“插入”?
问题描述
我需要在 ListBox 中按结果过滤 CSV 文件,并将结果显示在 Text 小部件中。当我使用此搜索功能时说文本没有属性“插入”。
我需要为我的家庭作业做这件事。我尝试了在这个站点和许多其他站点中可以找到的所有内容,但没有解决问题
global search_input
with open(f, 'r', encoding = 'utf-8') as f_in:
for line in f_in:
line = line.strip()
global row
row = []
if search_input in line:
row.append(line)
TextBox = tkinter.Text(root, height=20, width=30,state='disabled').grid(row=2,column=0,)
TextBox.insert('end',*row)
解决方案
他有:
import tkinter as tk
root = tk.Tk()
text_box = tk.Text(root, height=2, width=30)
text_box.pack()
text_box.insert(tk.END, "Text\ntext\n")
tk.mainloop()
推荐阅读
- msbuild - 找不到 signtool 的临时位置。退出
- python - Pyspark - 使用广播字典中的日期过滤 RDD
- java - 动态 TextView 未在片段中更新
- azure - Azure 多个部署 409 冲突
- html - 当我保存时,内联 css 在文本编辑器中被删除。它创建了一个丑陋的 html 按钮,无处可去
- ios - 如何正确补偿CGContextRef坐标系,使原点在左上角
- chromecast - Chromecast Ultra 会限制 HTML 分辨率吗?
- python - 使用 Python 在 Glade 中显示我在 frame1 上录制的图像文件在 frame2 上显示
- r - 将因子值转换为数值时出错
- java - 我可以使用方法而不是类 Quartz 来定义作业实例吗?