在列表框中的组合框中显示用户选择的问题
Problems with displaying an user selection from a Combobox in a Listbox
我想要以下代码片段从组合框中获取用户 selection 并将其显示在我设置的列表框中。当我 运行 代码和组合框中的 select 时,selection 在列表框中显示为 <tkinter.StringVar object at 0x1007ae748>
而不是实际文本。
这是代码片段:
self.datesel = StringVar()
self.entry_date = ttk.Combobox(self.frame_crearorden,width = 24, textvariable = self.datesel)
self.entry_date.config(values = datescroll_list)
self.dateusersel = self.entry_date.get()
global getvalue
getvalue = self.datesel
print(getvalue)
这是我用来在列表框中显示用户 selection 的函数(通过创建一个包含所有要显示的信息的字典):
def orderZoom(self):
nombre = contents1
nicenum = orderResult
email = contents2
num = contents3
fechacreacion1 = fechaDeCreacion
fechaentrega = getvalue
global ordenOrganiz
ordenOrganiz = {"Num Orden": nicenum,
"Nombre": nombre,
"Email": email,
"Num Tel/Cel": num,
"Orden Creada:": fechacreacion1,
"Fecha de Entrega": fechaentrega}
return dict(ordenOrganiz)
问题是您在用户有机会从菜单中 select 之前调用 get
方法。在用户能够 select 某事后,您需要从 orderZoom
内部获取值。
def orderZoom(self):
...
fechaentrega = self.datasel.get()
我想要以下代码片段从组合框中获取用户 selection 并将其显示在我设置的列表框中。当我 运行 代码和组合框中的 select 时,selection 在列表框中显示为 <tkinter.StringVar object at 0x1007ae748>
而不是实际文本。
这是代码片段:
self.datesel = StringVar()
self.entry_date = ttk.Combobox(self.frame_crearorden,width = 24, textvariable = self.datesel)
self.entry_date.config(values = datescroll_list)
self.dateusersel = self.entry_date.get()
global getvalue
getvalue = self.datesel
print(getvalue)
这是我用来在列表框中显示用户 selection 的函数(通过创建一个包含所有要显示的信息的字典):
def orderZoom(self):
nombre = contents1
nicenum = orderResult
email = contents2
num = contents3
fechacreacion1 = fechaDeCreacion
fechaentrega = getvalue
global ordenOrganiz
ordenOrganiz = {"Num Orden": nicenum,
"Nombre": nombre,
"Email": email,
"Num Tel/Cel": num,
"Orden Creada:": fechacreacion1,
"Fecha de Entrega": fechaentrega}
return dict(ordenOrganiz)
问题是您在用户有机会从菜单中 select 之前调用 get
方法。在用户能够 select 某事后,您需要从 orderZoom
内部获取值。
def orderZoom(self):
...
fechaentrega = self.datasel.get()