• <bdo id='LlPH5'></bdo><ul id='LlPH5'></ul>
  • <tfoot id='LlPH5'></tfoot>
    1. <small id='LlPH5'></small><noframes id='LlPH5'>

    2. <legend id='LlPH5'><style id='LlPH5'><dir id='LlPH5'><q id='LlPH5'></q></dir></style></legend>

        <i id='LlPH5'><tr id='LlPH5'><dt id='LlPH5'><q id='LlPH5'><span id='LlPH5'><b id='LlPH5'><form id='LlPH5'><ins id='LlPH5'></ins><ul id='LlPH5'></ul><sub id='LlPH5'></sub></form><legend id='LlPH5'></legend><bdo id='LlPH5'><pre id='LlPH5'><center id='LlPH5'></center></pre></bdo></b><th id='LlPH5'></th></span></q></dt></tr></i><div id='LlPH5'><tfoot id='LlPH5'></tfoot><dl id='LlPH5'><fieldset id='LlPH5'></fieldset></dl></div>
      1. 更改 tkinter 列表框中的项目顺序

        changing order of items in tkinter listbox(更改 tkinter 列表框中的项目顺序)

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

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

              • <legend id='sNMIl'><style id='sNMIl'><dir id='sNMIl'><q id='sNMIl'></q></dir></style></legend>
                  <tbody id='sNMIl'></tbody>
                • 本文介绍了更改 tkinter 列表框中的项目顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有没有比删除特定键的值然后重新输入新信息更简单的方法来更改 tkinter 列表框中的项目顺序?

                  Is there an easier way to change the order of items in a tkinter listbox than deleting the values for specific key, then re-entering new info?

                  例如,我希望能够重新排列列表框中的项目.如果我想交换两个位置,这就是我所做的.它有效,但我只是想看看是否有更快的方法来做到这一点.

                  For example, I want to be able to re-arrange items in a listbox. If I want to swap the position of two, this is what I've done. It works, but I just want to see if there's a quicker way to do this.

                  def moveup(self,selection):
                      value1 = int(selection[0]) - 1 #value to be moved down one position
                      value2 = selection #value to be moved up one position
                      nameAbove = self.fileListSorted.get(value1) #name to be moved down
                      nameBelow = self.fileListSorted.get(value2) #name to be moved up
                  
                      self.fileListSorted.delete(value1,value1)
                      self.fileListSorted.insert(value1,nameBelow)
                      self.fileListSorted.delete(value2,value2)
                      self.fileListSorted.insert(value2,nameAbove)
                  

                  推荐答案

                  有没有比删除特定键的值然后重新输入新信息更简单的方法来更改 tkinter 列表框中的项目顺序?

                  Is there an easier way to change the order of items in a tkinter listbox than deleting the values for specific key, then re-entering new info?

                  没有.删除并重新插入是唯一的方法.但是,如果您只想将单个项目向上移动一个,则只需一次删除和插入即可.

                  No. Deleting and re-inserting is the only way. If you just want to move a single item up by one you can do it with only one delete and insert, though.

                  def move_up(self, pos):
                      """ Moves the item at position pos up by one """
                  
                      if pos == 0:
                          return
                  
                      text = self.fileListSorted.get(pos)
                      self.fileListSorted.delete(pos)
                      self.fileListSorted.insert(pos-1, text)
                  

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

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

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

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