昨天我在Combobox选择时遇到了问题,可以在以下链接中看到:
如何根据组合框选择更改多个标签?
不幸的是,我无法表达自己的想法,因此我的问题没有得到解决。无论如何,谢谢您的帮助。我的意思是,用下面的代码更好地表达问题,问题在于它使用了aListbox而不是a Combobox。
这是代码:
from Tkinter import *
root = Tk()
root.minsize(500,300)
root.maxsize(550,310)
class MyListbox:
def __init__(self, parent, title):
self.parent = parent
self.parent.title(title)
self.parent.protocol("WM_DELETE_WINDOW", self.Closes)
self.myData= (
["1", "Jhon Doe", "Madrid", "0341-672541", "6 SD"],
["2", "Mike Grant", "Barcelona", "0341-435271", "6 SD"],
["3", "Steven Mc Fly", "Rome", "0341-123456", "6 SD"],
["4", "Joao Pontes", "Rio", "0341-234567", "6 SD"],
["5", "Kenji S.", "Tokyo", "0341-213212", "6 SD"])
self.stablishment()
self.SeT()
self.Listbox_Content()
self.Data_Content()
self.listboxData.focus_set()
def SeT(self):
self.listboxData.bind('<ButtonRelease-1>', self.click)
self.listboxData.bind('<KeyRelease>', self.click)
def click(self, event=None):
self.Data_Content()
def Data_Content(self):
index = self.listboxData.curselection()
code = int(index[0])
self.entNumber.delete(0, END)
self.entName.delete(0, END)
self.entCity.delete(0, END)
self.entTel.delete(0, END)
self.entAddress.delete(0, END)
self.entNumber.insert(END, self.myData[code][0])
self.entName.insert(END, self.myData[code][1])
self.entCity.insert(END, self.myData[code][2])
self.entTel.insert(END, self.myData[code][3])
self.entAddress.insert(END, self.myData[code][4])
慕侠2389804
相关分类