import tkinter as tk
window = tk.Tk()
window.title("我的窗口")
window.geometry('200x400')
var1 = tk.StringVar()
label = tk.Label(window,bg='yellow',width=6,heigh=2,textvariable=var1)
label.pack()
def printSelect():
value = lb.get(lb.curselection())
var1.set(value)
b1 = tk.Button(window,text = "print select",
width=15,height=2,command= printSelect)
b1.pack()
var2 = tk.StringVar()
var2.set((22,33,44,55,66,77,"heqinglin"))
lb = tk.Listbox(window,listvariable=var2)
items = [1,2,3,4]
for item in items:
lb.insert('end',item)
lb.insert(1,"first")
lb.insert(2,"second")
lb.delete(2)
lb.pack()
window.mainloop()
window = tk.Tk()
window.title("我的窗口")
window.geometry('200x400')
var1 = tk.StringVar()
label = tk.Label(window,bg='yellow',width=6,heigh=2,textvariable=var1)
label.pack()
def printSelect():
value = lb.get(lb.curselection())
var1.set(value)
b1 = tk.Button(window,text = "print select",
width=15,height=2,command= printSelect)
b1.pack()
var2 = tk.StringVar()
var2.set((22,33,44,55,66,77,"heqinglin"))
lb = tk.Listbox(window,listvariable=var2)
items = [1,2,3,4]
for item in items:
lb.insert('end',item)
lb.insert(1,"first")
lb.insert(2,"second")
lb.delete(2)
lb.pack()
window.mainloop()