【发布时间】:2020-02-19 18:24:00
【问题描述】:
我不是一个经验丰富的程序员,所以如果我问一个基本问题,请提前道歉。我正在使用 for 循环打印 tkinter 条目并尝试将这些条目的引用返回给调用函数。但是,当我尝试获取在条目中键入的文本时,它总是返回空字符串?所以我的问题是是否可以在 python 中返回控制变量的引用?还是我使用了错误的方法?
def data_entry_txtfield(self,rn,cn,pu,pd):
# Creates the Entry to enter data - rn is the row and cn is column
# pd and pu are padding up and padding down
entry = tk.StringVar()
tk.Entry(self.inputlab,width=32,bg=entrycolor,textvariable=entry)
entry.grid(column=cn,row=rn,pady=(pu,pd))
return entry
tbtlocationentry = self.data_entry_txtfield(9,4,0,12)
text = tbtlocationentry.get()
print(text)`
【问题讨论】:
标签: python-3.x variables tkinter return controls