1. <tfoot id='McsNm'></tfoot>
  2. <small id='McsNm'></small><noframes id='McsNm'>

  3. <legend id='McsNm'><style id='McsNm'><dir id='McsNm'><q id='McsNm'></q></dir></style></legend>

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

    1. <i id='McsNm'><tr id='McsNm'><dt id='McsNm'><q id='McsNm'><span id='McsNm'><b id='McsNm'><form id='McsNm'><ins id='McsNm'></ins><ul id='McsNm'></ul><sub id='McsNm'></sub></form><legend id='McsNm'></legend><bdo id='McsNm'><pre id='McsNm'><center id='McsNm'></center></pre></bdo></b><th id='McsNm'></th></span></q></dt></tr></i><div id='McsNm'><tfoot id='McsNm'></tfoot><dl id='McsNm'><fieldset id='McsNm'></fieldset></dl></div>
    2. Tkinter 全局绑定

      时间:2023-09-03
      <i id='rkpT6'><tr id='rkpT6'><dt id='rkpT6'><q id='rkpT6'><span id='rkpT6'><b id='rkpT6'><form id='rkpT6'><ins id='rkpT6'></ins><ul id='rkpT6'></ul><sub id='rkpT6'></sub></form><legend id='rkpT6'></legend><bdo id='rkpT6'><pre id='rkpT6'><center id='rkpT6'></center></pre></bdo></b><th id='rkpT6'></th></span></q></dt></tr></i><div id='rkpT6'><tfoot id='rkpT6'></tfoot><dl id='rkpT6'><fieldset id='rkpT6'></fieldset></dl></div>
          <legend id='rkpT6'><style id='rkpT6'><dir id='rkpT6'><q id='rkpT6'></q></dir></style></legend>

          <tfoot id='rkpT6'></tfoot>
        1. <small id='rkpT6'></small><noframes id='rkpT6'>

            • <bdo id='rkpT6'></bdo><ul id='rkpT6'></ul>
                  <tbody id='rkpT6'></tbody>

                本文介绍了Tkinter 全局绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                是否可以通过一行将所有小部件绑定到一个命令?如果我可以输入一行而不是单独执行每个小部件,那就太好了.

                Is it possible to bind all widgets to one command, with a single line? It would be nice if I could type in one line as opposed to doing each widget individually.

                推荐答案

                你会使用 bind_all 方法.然后这将应用于所有小部件(除非您从某些小部件中删除绑定标签all").请注意,这些绑定最后触发,因此您仍然可以根据需要覆盖特定小部件上的应用程序范围的绑定.

                You would use the bind_all method on the root window. This will then apply to all widgets (unless you remove the bindtag "all" from some widgets). Note that these bindings fire last, so you can still override the application-wide binding on specific widgets if you wish.

                这是一个人为的例子:

                import Tkinter as tk
                
                class App:
                    def __init__(self):
                        root = tk.Tk()
                        root.bind_all("<1>", self.woot)
                        label1 = tk.Label(text="Label 1", name="label1")
                        label2 = tk.Label(text="Label 2", name="label2")
                        entry1 = tk.Entry(name="entry1")
                        entry2 = tk.Entry(name="entry2")
                        label1.pack()
                        label2.pack()
                        entry1.pack()
                        entry2.pack()
                        root.mainloop()
                
                    def woot(self, event):
                        print "woot!", event.widget
                
                app=App()
                

                您可能还对 我的回答 如何在 Tkinter Text 小部件被 Text 小部件绑定后绑定 self 事件? 我在这里多谈一点绑定标签.

                You might also be interested in my answer to the question How to bind self events in Tkinter Text widget after it will binded by Text widget? where I talk a little more about bindtags.

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

                上一篇:IPython notebook交互功能:如何设置滑块范围 下一篇:链接 ipython 小部件按钮和滑块值

                相关文章

              • <tfoot id='zDi4q'></tfoot>
                  <bdo id='zDi4q'></bdo><ul id='zDi4q'></ul>
              • <legend id='zDi4q'><style id='zDi4q'><dir id='zDi4q'><q id='zDi4q'></q></dir></style></legend>
                1. <small id='zDi4q'></small><noframes id='zDi4q'>

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