tkinter 题目
from tkinter import *
serendipitv=["天津","北京","上海","重庆"]
root=Tk()
root.geometry("200x300")
l=Listbox(root,
selectmode="extented",
height=12)
l.pack()
for item in range (len(serendipitv)):
l.insert(END,item)
b=Button(root,
text="删除",
command=lambda x=l:x.delete("active"))
b.pack()
mainloop()
运行的结果,想显示”天津“、”北京“、”上海”、“重庆”,而不要1、2、3、4,怎么修改程序 ? from tkinter import *
serendipitv=["天津","北京","上海","重庆"]
root=Tk()
root.geometry("200x300")
l=Listbox(root,
selectmode="extented",
height=12)
l.pack()
for item in serendipitv: # 改了这行
l.insert(END,item)
b=Button(root,
text="删除",
command=lambda x=l:x.delete("active"))
b.pack()
mainloop()
isdkz 发表于 2023-3-13 17:10
谢谢!
页:
[1]