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

        <bdo id='uCDKh'></bdo><ul id='uCDKh'></ul>
    2. <legend id='uCDKh'><style id='uCDKh'><dir id='uCDKh'><q id='uCDKh'></q></dir></style></legend>
      <tfoot id='uCDKh'></tfoot>
    3. <i id='uCDKh'><tr id='uCDKh'><dt id='uCDKh'><q id='uCDKh'><span id='uCDKh'><b id='uCDKh'><form id='uCDKh'><ins id='uCDKh'></ins><ul id='uCDKh'></ul><sub id='uCDKh'></sub></form><legend id='uCDKh'></legend><bdo id='uCDKh'><pre id='uCDKh'><center id='uCDKh'></center></pre></bdo></b><th id='uCDKh'></th></span></q></dt></tr></i><div id='uCDKh'><tfoot id='uCDKh'></tfoot><dl id='uCDKh'><fieldset id='uCDKh'></fieldset></dl></div>

        如何使 Tkinter 列表框适合内容

        How to fit Tkinter listbox to contents(如何使 Tkinter 列表框适合内容)
        <tfoot id='VHUKT'></tfoot>
      1. <legend id='VHUKT'><style id='VHUKT'><dir id='VHUKT'><q id='VHUKT'></q></dir></style></legend>

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

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

                  <bdo id='VHUKT'></bdo><ul id='VHUKT'></ul>
                • 本文介绍了如何使 Tkinter 列表框适合内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用下面的代码将字符串添加到列表框.当我运行代码并打开窗口时,由于窗口不够大,较长的字符串会被剪掉(见屏幕截图).我曾尝试使窗口可调整大小并添加滚动条,但我想知道是否有办法自动调整大小以适应内容.

                  I'm adding strings to a listbox using the code below. When I run the code and the window opens, the longer strings get clipped as the window is not large enough (see screenshot). I have tried making the window resizeable and adding scroll bars but I was wondering if there was a way to automatically size it to fit the content.

                  master = tk.Tk()
                  listbox = tk.Listbox(master, selectmode=tk.SINGLE)
                  
                  games = ["Garry's Mod", "Mount and Blade: Warband", "Tekkit"]
                  for game in sorted(games):
                      listbox.insert(tk.END, game)
                  
                  button = tk.Button(master, text="Execute", command=execute)
                  
                  listbox.pack()
                  button.pack()
                  tk.mainloop()
                  

                  推荐答案

                  重置列表框宽度对我有用.我使用了 Oblivion 的答案,发现宽度始终为零.

                  Resetting the listbox width worked for me. I used the Oblivion's answer and noticed that the width is always zero.

                  listbox = tk.Listbox(master, selectmode=tk.SINGLE)
                  listbox.config(width=0)
                  

                  我还建议在重新加载列表内容后重置根窗口几何图形.否则,如果用户手动扩展窗口,窗口将停止适应其内容的大小.

                  I also recommend to reset the root window geometry after reloading a content of the list. Otherwise if user manually extends a window the window would stop accommodate size of its content.

                  root.winfo_toplevel().wm_geometry("")
                  

                  这篇关于如何使 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% 就足够了)
                    • <small id='C1jLm'></small><noframes id='C1jLm'>

                        <tbody id='C1jLm'></tbody>

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

                      1. <tfoot id='C1jLm'></tfoot>
                        <legend id='C1jLm'><style id='C1jLm'><dir id='C1jLm'><q id='C1jLm'></q></dir></style></legend>

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