【发布时间】:2018-10-04 22:04:23
【问题描述】:
我想有一种方法让用户编辑他们使用工具栏上的编辑选项卡制作的列表。我不知道我应该如何处理仍然使用字典列表的这条鲸鱼
完整代码https://pastebin.com/6VAnZTyi
#************for defining what is in the list*******************
class My_QueryString(tkinter.simpledialog._QueryString):
def body(self, master):
self.bind('<KP_Enter>', self.ok) # KeyPad Enter
super().body(master)
def list_data(title, prompt, **kw):
d = My_QueryString(title, prompt, **kw)
return d.result
root = Tk()
#list
def liststagering(New_List):
for item in New_List:
print(item)
def New_List():
new_list = myaskstring("list", "what do you want to name this list")
List_Data = list_data("list","what should be in this list")
if str(new_list):
print(new_list)
newList = dict()
newList['title'] = new_list
newList['listData'] = List_Data
List_MASTER.append(newList)
print("title : "+new_list)
print(List_Data)
List_MASTER = []
lll=print (List_MASTER)
def printtext():
T = Text(root)
T.pack(expand=True, fill='both')
printData = ""
print(List_MASTER)
for i in range(len(List_MASTER)):
printData += List_MASTER[0]['title'] +"\n"+List_MASTER [i]['listData'] + "\n";
T.insert(END,
printData
,
)
for printData in T:
T.delete(0,END)
【问题讨论】:
-
要编辑
dict的list,您指定字典所在的索引,然后指定要在该字典内编辑的键。像这样:list_name[ndex_number][dict_key].
标签: python list user-interface dictionary tkinter