我正在利用 python/tkinter 创建一个电子表格来收集制造车间的问题。
我有 (2) 个组合框。
第一个组合框从给定的dictionary.keys() 获取其“值”,该字典更新第二个组合框的“值”。但是,在选择第一个组合框后选择第二个组合框的值时,这些值仅显示dictionary.values() 中的单数字符。
这是 txt 文件中的列表。每行的第一项是键,而同一行的其余项是其值。
Bondshop, Plies: Layup Difficulty, Plies: Cutting Edge
IB Postbond, POU, Equipment, Inspection, Available Work Space, Big Paint, 1575, QN
General Postbond, Inspection
Seal Area, Inspection
Big Paint, Inspection
Deflash, Inspection
Run Code Online (Sandbox Code Playgroud)
为什么我的第二个组合框会这样出现?见下文。

===snip===
def loadcategory(self):
# Reads production areas & cateogries from dictCategory.txt file
self.textfileCategory = open('dictCategory.txt', 'r')
self.lines_category = self.textfileCategory.readlines()
for line in self.lines_category:
splitLine = line.split(',')
dict_category[str(splitLine[0])] = ",".join(splitLine[1:])
self.textfileCategory.close()
===snip===
def UpdateData(self, event):
# Updates Category Combobox based on Production Area selection
self.menu_category.set('---')
category = self.menu_production_area.get()
self.menu_category['values'] = sorted(dict_category[category])
===snip===
self.menu_production_area = ttk.Combobox(Main_Frame, state='readonly', values = sorted(list(dict_category.keys())), width=25)
self.menu_production_area.bind('<<ComboboxSelected>>', self.UpdateData)
self.menu_production_area.grid(row=2, column=1, sticky='w')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
681 次 |
| 最近记录: |