• <legend id='z314L'><style id='z314L'><dir id='z314L'><q id='z314L'></q></dir></style></legend>
  • <small id='z314L'></small><noframes id='z314L'>

    • <bdo id='z314L'></bdo><ul id='z314L'></ul>
  • <tfoot id='z314L'></tfoot>

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

        如何查看 Tkinter 中是否存在小部件?

        How to see if a widget exists in Tkinter?(如何查看 Tkinter 中是否存在小部件?)
        1. <i id='pxmNv'><tr id='pxmNv'><dt id='pxmNv'><q id='pxmNv'><span id='pxmNv'><b id='pxmNv'><form id='pxmNv'><ins id='pxmNv'></ins><ul id='pxmNv'></ul><sub id='pxmNv'></sub></form><legend id='pxmNv'></legend><bdo id='pxmNv'><pre id='pxmNv'><center id='pxmNv'></center></pre></bdo></b><th id='pxmNv'></th></span></q></dt></tr></i><div id='pxmNv'><tfoot id='pxmNv'></tfoot><dl id='pxmNv'><fieldset id='pxmNv'></fieldset></dl></div>
          <legend id='pxmNv'><style id='pxmNv'><dir id='pxmNv'><q id='pxmNv'></q></dir></style></legend>
            <tfoot id='pxmNv'></tfoot>

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

              • <bdo id='pxmNv'></bdo><ul id='pxmNv'></ul>

                    <tbody id='pxmNv'></tbody>

                  本文介绍了如何查看 Tkinter 中是否存在小部件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  现在,我知道您可以通过以下方式检查窗口是否存在:

                  Now, I know that you can check to see if a window exists by:

                  x.winfo_exists()
                  

                  返回一个布尔值.我已经搜索过这个,但无法找到我正在寻找的确切内容.更具体地说,我需要检查我的按钮、标签、列表框、滑块等是否存在.

                  Which returns a Boolean. I have searched for this, but haven't been able to find exactly what I am looking for. More specifically I need to check the existence of my buttons, labels, list boxes, sliders etc.

                  推荐答案

                  winfo_exists 返回 1 除非你已经销毁了小部件,在这种情况下它返回 0.这个方法可以在任何小部件类上调用,不仅是 Tk 根或 Toplevels.或者,您可以使用 winfo_children 获取小部件的所有子级:

                  winfo_exists returns 1 unless you have destroyed the widget, in which case it returns 0. This method can be called on any widget class, not only the Tk root or Toplevels. Alternatively, you can get all the children of a widget with winfo_children:

                  >>> import Tkinter as tk
                  >>> root = tk.Tk()
                  >>> label = tk.Label(root, text="Hello, world")
                  >>> label.winfo_exists()
                  1
                  >>> root.winfo_children()
                  [<Tkinter.Label instance at 0x0000000002ADC1C8>]
                  >>> label.destroy()
                  >>> label.winfo_exists()
                  0
                  >>> root.winfo_children()
                  []
                  

                  这篇关于如何查看 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% 就足够了)
                  <i id='6Fi4m'><tr id='6Fi4m'><dt id='6Fi4m'><q id='6Fi4m'><span id='6Fi4m'><b id='6Fi4m'><form id='6Fi4m'><ins id='6Fi4m'></ins><ul id='6Fi4m'></ul><sub id='6Fi4m'></sub></form><legend id='6Fi4m'></legend><bdo id='6Fi4m'><pre id='6Fi4m'><center id='6Fi4m'></center></pre></bdo></b><th id='6Fi4m'></th></span></q></dt></tr></i><div id='6Fi4m'><tfoot id='6Fi4m'></tfoot><dl id='6Fi4m'><fieldset id='6Fi4m'></fieldset></dl></div>

                  1. <tfoot id='6Fi4m'></tfoot>
                      <tbody id='6Fi4m'></tbody>

                    <small id='6Fi4m'></small><noframes id='6Fi4m'>

                          <bdo id='6Fi4m'></bdo><ul id='6Fi4m'></ul>
                          <legend id='6Fi4m'><style id='6Fi4m'><dir id='6Fi4m'><q id='6Fi4m'></q></dir></style></legend>