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

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

    1. <small id='pu1qQ'></small><noframes id='pu1qQ'>

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

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

        Tkinter 列表框

        Tkinter Listbox(Tkinter 列表框)

          • <small id='M4oVQ'></small><noframes id='M4oVQ'>

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

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

                  <tbody id='M4oVQ'></tbody>

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

                1. <tfoot id='M4oVQ'></tfoot>
                2. 本文介绍了Tkinter 列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想一键执行功能列表框.这是我的想法:

                  I want to execute function with one click on listbox. This is my idea:

                  from Tkinter import *
                  import Tkinter
                  
                  def immediately():
                      print Lb1.curselection()
                  
                  top = Tk()
                  
                  Lb1 = Listbox(top)
                  Lb1.insert(1, "Python")
                  Lb1.insert(2, "Perl")
                  Lb1.insert(3, "C")
                  Lb1.insert(4, "PHP")
                  Lb1.insert(5, "JSP")
                  Lb1.insert(6, "Ruby")
                  
                  Lb1.pack()
                  
                  
                  Lb1.bind('<Button-1>', lambda event :immediately() )
                  top.mainloop()
                  

                  但是这个函数在执行选择之前打印...当你运行这个代码时你会看到问题是什么.

                  But this function print before execute selecting...You will see what is the problrm when you run this code.

                  推荐答案

                  您可以绑定到 <<ListboxSelect>> 事件,如本文所述:Tkinter 列表框选择更改时获取回调?TKinter 有点奇怪,因为信息似乎不包含在发送给处理程序的事件中.还要注意,不需要创建一个简单地调用你的函数立即的lambda,函数对象可以传入,如下所示:

                  You can bind to the <<ListboxSelect>> event as described in this post: Getting a callback when a Tkinter Listbox selection is changed? TKinter is somewhat strange in that the information does not seemed to be contained within the event that is sent to the handler. Also note, there is no need to create a lambda that simply invokes your function immediately, the function object can be passed in as shown:

                  from Tkinter import *
                  import Tkinter
                  
                  def immediately(e):
                      print Lb1.curselection()
                  
                  
                  top = Tk()
                  
                  Lb1 = Listbox(top)
                  Lb1.insert(1, "Python")
                  Lb1.insert(2, "Perl")
                  Lb1.insert(3, "C")
                  Lb1.insert(4, "PHP")
                  Lb1.insert(5, "JSP")
                  Lb1.insert(6, "Ruby")
                  
                  Lb1.pack()
                  
                  
                  Lb1.bind('<<ListboxSelect>>', immediately)
                  top.mainloop()
                  

                  这篇关于Tkinter 列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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% 就足够了)
                        <legend id='CJDKL'><style id='CJDKL'><dir id='CJDKL'><q id='CJDKL'></q></dir></style></legend>
                        • <bdo id='CJDKL'></bdo><ul id='CJDKL'></ul>
                          <tfoot id='CJDKL'></tfoot>
                        • <i id='CJDKL'><tr id='CJDKL'><dt id='CJDKL'><q id='CJDKL'><span id='CJDKL'><b id='CJDKL'><form id='CJDKL'><ins id='CJDKL'></ins><ul id='CJDKL'></ul><sub id='CJDKL'></sub></form><legend id='CJDKL'></legend><bdo id='CJDKL'><pre id='CJDKL'><center id='CJDKL'></center></pre></bdo></b><th id='CJDKL'></th></span></q></dt></tr></i><div id='CJDKL'><tfoot id='CJDKL'></tfoot><dl id='CJDKL'><fieldset id='CJDKL'></fieldset></dl></div>

                            <tbody id='CJDKL'></tbody>

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