我想将数据插入到ttk treeview小部件的特定列中。用户唯一输入的是扫描器,因此我必须解析每个代码以确定它进入哪一列。现在,parseData()
函数在按 Enter 时运行,因此我想在此进行插入。
我尝试使用treeview.set(item, column, new_value)
,但是在插入空白行时会崩溃。
class MainGUI:
def __init__(self, master):
self.master = master
self.data_view = ttk.Treeview(master)
self.data_view['columns'] = ["Date", "Item 1", "Item 2", "Item 3", "Item 4", "Source", "Destination", "Cart #",]
self.data_view['show'] = 'headings'
self.data_view.heading("Date", text="Date")
self.data_view.heading("Item 1", text="Item 1")
self.data_view.heading("Item 2", text="Item 2")
self.data_view.heading("Item 3", text="Item 3")
self.data_view.heading("Item 4", text="Item 4")
self.data_view.heading("Source", text="Source")
self.data_view.heading("Destination", text="Destination")
self.data_view.heading("Cart #", text="Cart #")
self.data_view.pack()
self.scan_entry = ttk.Entry(master)
self.scan_entry.pack()
self.scan_entry.bind('<Return>', self.parseEntry)
self.scan_entry.focus()
self.close_button = tk.Button(master, text="Close", command=self.adminLogout, width=15, height=5)
self.close_button.pack(anchor='se')
def parseEntry(self,event):
#INSERT self.scan_entry.get() into #ITEM 1 column, not date volumn
#If contains certain characters, maybe insert into Source or Destination
self.scan_entry.delete(0,'end')
理想情况下,我希望能够将空白树插入任何列,或者在某些情况下可以抓取所选内容,然后根据输入更改值。
答案 0 :(得分:1)
您将必须在不想填写的列中插入空白。
您可以使用@ECHO OFF
If exist (C:/Path/file.strm) (
Rem | File exists, run script
Echo Do something
)
GOTO :EOF
检查在in
中寻找的字符:
self.scan_entry.get()