How to select at the same time from two Listbox?

后端 未结 2 938
北海茫月
北海茫月 2020-12-01 23:57
from Tkinter import *


master = Tk()

listbox = Listbox(master)
listbox.pack()
listbox.insert(END, \"a list entry\")

for item in [\"one\", \"two\", \"three\", \"fo         


        
相关标签:
2条回答
  • 2020-12-02 00:05

    exportselection=0 when defining a listbox seems to take care of this issue.

    0 讨论(0)
  • 2020-12-02 00:25

    Short answer: set the value of the exportselection attribute of all listbox widgets to False or zero.

    From a pythonware overview of the listbox widget:

    By default, the selection is exported to the X selection mechanism. If you have more than one listbox on the screen, this really messes things up for the poor user. If he selects something in one listbox, and then selects something in another, the original selection is cleared. It is usually a good idea to disable this mechanism in such cases. In the following example, three listboxes are used in the same dialog:

    b1 = Listbox(exportselection=0)
    for item in families:
        b1.insert(END, item)
    
    b2 = Listbox(exportselection=0)
    for item in fonts:
        b2.insert(END, item)
    
    b3 = Listbox(exportselection=0)
    for item in styles:
        b3.insert(END, item)
    

    The definitive documentation for tk widgets is based on the Tcl language rather than python, but it is easy to translate to python. The exportselection attribute can be found on the standard options manual page.

    0 讨论(0)
提交回复
热议问题