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

    <tfoot id='uxdJw'></tfoot>

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

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

        如何更改列表框项目的文本?

        How can I change the text of Listbox item?(如何更改列表框项目的文本?)
        <tfoot id='nZRtf'></tfoot>
          • <bdo id='nZRtf'></bdo><ul id='nZRtf'></ul>
              <tbody id='nZRtf'></tbody>

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

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

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

                  本文介绍了如何更改列表框项目的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个装满项目的 Listbox,我需要更改项目的文本.使用项目配置我只能找出如何更改颜色.

                  I have a Listbox full of items, and I need to change an item's text. Using item configure I can only find out how to change colors.

                  如何更改 Tkinter Listbox 上的项目文本?

                  How can I change the item text on a Tkinter Listbox?

                  推荐答案

                  要更改文本,您必须删除并在适当的索引处重新添加项目.

                  To change the text you will have to delete and re-add an item at the proper index.

                  这是一个人为的例子,它不断更新列表框中的第二项:

                  Here is a contrived example that continuously updates the second item in the listbox:

                  import Tkinter as tk
                  import time
                  
                  class Example(tk.Frame):
                      def __init__(self, parent):
                          tk.Frame.__init__(self, parent)
                  
                          self.lb = tk.Listbox(self)
                          self.lb.pack(fill="both", expand=True)
                  
                          self.lb.insert("end", "item 1","the current time", "item 3")
                  
                          self.after(1000, self._update_listbox)
                  
                      def _update_listbox(self):
                          self.lb.delete(1)
                          self.lb.insert(1, time.asctime())
                  
                          self.after(1000, self._update_listbox)
                  
                  if __name__ == "__main__":
                      root = tk.Tk()
                      Example(root).pack(fill="both", expand=True)
                      root.mainloop()
                  

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

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

                  相关文档推荐

                  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% 就足够了)

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

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

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