<bdo id='taEDh'></bdo><ul id='taEDh'></ul>
<i id='taEDh'><tr id='taEDh'><dt id='taEDh'><q id='taEDh'><span id='taEDh'><b id='taEDh'><form id='taEDh'><ins id='taEDh'></ins><ul id='taEDh'></ul><sub id='taEDh'></sub></form><legend id='taEDh'></legend><bdo id='taEDh'><pre id='taEDh'><center id='taEDh'></center></pre></bdo></b><th id='taEDh'></th></span></q></dt></tr></i><div id='taEDh'><tfoot id='taEDh'></tfoot><dl id='taEDh'><fieldset id='taEDh'></fieldset></dl></div>

        <legend id='taEDh'><style id='taEDh'><dir id='taEDh'><q id='taEDh'></q></dir></style></legend>
        <tfoot id='taEDh'></tfoot>

        <small id='taEDh'></small><noframes id='taEDh'>

      1. 如何从两个Listbox中同时选择?

        How to select at the same time from two Listbox?(如何从两个Listbox中同时选择?)

            <tfoot id='wlIvK'></tfoot>
          • <i id='wlIvK'><tr id='wlIvK'><dt id='wlIvK'><q id='wlIvK'><span id='wlIvK'><b id='wlIvK'><form id='wlIvK'><ins id='wlIvK'></ins><ul id='wlIvK'></ul><sub id='wlIvK'></sub></form><legend id='wlIvK'></legend><bdo id='wlIvK'><pre id='wlIvK'><center id='wlIvK'></center></pre></bdo></b><th id='wlIvK'></th></span></q></dt></tr></i><div id='wlIvK'><tfoot id='wlIvK'></tfoot><dl id='wlIvK'><fieldset id='wlIvK'></fieldset></dl></div>

              <tbody id='wlIvK'></tbody>
              <bdo id='wlIvK'></bdo><ul id='wlIvK'></ul>

                  <small id='wlIvK'></small><noframes id='wlIvK'>

                1. <legend id='wlIvK'><style id='wlIvK'><dir id='wlIvK'><q id='wlIvK'></q></dir></style></legend>
                2. 本文介绍了如何从两个Listbox中同时选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  from Tkinter import *
                  
                  
                  master = Tk()
                  
                  listbox = Listbox(master)
                  listbox.pack()
                  listbox.insert(END, "a list entry")
                  
                  for item in ["one", "two", "three", "four"]:
                      listbox.insert(END, item)
                  
                  listbox2 = Listbox(master)
                  listbox2.pack()
                  listbox2.insert(END, "a list entry")
                  
                  for item in ["one", "two", "three", "four"]:
                      listbox2.insert(END, item)
                  
                  master.mainloop()
                  

                  上面的代码创建了一个带有两个列表框的 tkinter 窗口.但是,如果您想从两者中检索值,则会出现问题,因为一旦您在其中一个中选择了一个值,它就会取消选择您在另一个中选择的任何内容.

                  The code above creates a tkinter window with two listboxes. But there's a problem if you want to retrieve the values from both because, as soon as you select a value in one, it deselects whatever you selected in the other.

                  这只是开发人员必须忍受的限制吗?

                  Is this just a limitation developers have to live with?

                  推荐答案

                  简答:将所有列表框小部件的 exportselection 属性的值设置为 False 或零.

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

                  来自 a列表框小部件的pythonware概述:

                  默认情况下,选择导出X选择机制.如果你有多个列表框屏幕,这真的把事情搞砸了对于可怜的用户.如果他选择一个列表框中的东西,然后在另一个中选择某些东西,原始选择被清除.它是通常禁用此功能是个好主意这种情况下的机制.在里面下面的例子,三个列表框是在同一个对话框中使用:

                  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)
                  

                  tk 小部件的权威文档基于 Tcl 语言而不是 python,但很容易翻译成 python.exportselection 属性可以在 标准选项手册页.

                  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.

                  这篇关于如何从两个Listbox中同时选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  env: python: No such file or directory(env: python: 没有这样的文件或目录)
                  How to evaluate environment variables into a string in Python?(如何在 Python 中将环境变量评估为字符串?)
                  Python - temporarily modify the current process#39;s environment(Python - 临时修改当前进程的环境)
                  Change current process environment#39;s LD_LIBRARY_PATH(更改当前进程环境的 LD_LIBRARY_PATH)
                  Reading and writing environment variables in Python?(在 Python 中读写环境变量?)
                  When to use sys.path.append and when modifying %PYTHONPATH% is enough(何时使用 sys.path.append 以及何时修改 %PYTHONPATH% 就足够了)
                    <tbody id='potjF'></tbody>

                  <small id='potjF'></small><noframes id='potjF'>

                    <legend id='potjF'><style id='potjF'><dir id='potjF'><q id='potjF'></q></dir></style></legend>

                    • <tfoot id='potjF'></tfoot>

                          <i id='potjF'><tr id='potjF'><dt id='potjF'><q id='potjF'><span id='potjF'><b id='potjF'><form id='potjF'><ins id='potjF'></ins><ul id='potjF'></ul><sub id='potjF'></sub></form><legend id='potjF'></legend><bdo id='potjF'><pre id='potjF'><center id='potjF'></center></pre></bdo></b><th id='potjF'></th></span></q></dt></tr></i><div id='potjF'><tfoot id='potjF'></tfoot><dl id='potjF'><fieldset id='potjF'></fieldset></dl></div>

                            <bdo id='potjF'></bdo><ul id='potjF'></ul>