以下MWE适用于具有水平和垂直滚动条的窗口。窗口包含一个输入框,其中显示当前工作目录。但是,输入框中的文本不能全部显示,因为该框太小。我希望能够在用户放大窗口时显示更多的文本。如何调整下面的示例,使输入框(在UserFileInput中定义)随窗口调整大小?我试过使用window.grid_columnconfigure(见下文),但这没有任何效果。使用画布似乎有问题,因为以前我可以调整输入框的大小,但是我需要画布来在窗口上放置水平和垂直滚动条。window.grid(row=0, column=0, sticky='ew')
window.grid_columnconfigure(0, weight=1)
(也有column=1)但这没有效果。import Tkinter as tk
import tkFileDialog
import os
class AutoScrollbar(tk.Scrollbar):
def set(self, lo, hi):
if float(lo) <= 0.0 and float(hi) >= 1.0:
# grid_remove is currently missing from Tkinter!
self.tk.call("grid", "remove", self)
else:
self.grid()
tk.Scrollbar.set(self, lo, hi)
class Window(tk.Frame):
def UserFileInput(self,status,name):
row = self.row
optionLabel &#