开发者

Python Listbox selection cleared whenever something is highlighted when it is working with Text or Entry widget

I found a problem with Tkinter.Listbox when it is working with Entry or Text widgets.

Whenever something is highlighted in the Ent开发者_StackOverflow社区ry or Text widget, it clears the listbox selection.

I am using Python 2.6.5. The following is the testing scripts.

from Tkinter import *


root = Tk()

List = ['It is a listbox: item1','item2','item3','item4','item5']
app  = Listbox(root,  width = 50, height = 6, selectmode = 'multiple')
for item in List:
    app.insert(END, item)
app.select_set(0,END)
app.pack()

entrvar = StringVar()
entry = Entry(root,width = 50, textvariable = entrvar)
entry.pack()
entrvar.set('it is an entry widget')

texter = Text(root,width = 38,height = 5)
texter.pack()
texter.insert(END,'it is a text widget\nit is a text widget\nit is a text widget\n')

label = Label(root,width = 50,height = 5, text = 'it is a label widget')
label.pack()

app.mainloop()


You need to set the exportselection attribute of the listbox to False

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜