【发布时间】:2022-01-26 04:13:56
【问题描述】:
我有一个 Tkinter 应用程序,其中PanedWindow 的左侧使用如here 所述的框架容器,右侧有一个ScrolledText 用于如here 所述的日志记录。我还使用this 来调整框架容器中框架的大小,因为它们具有不同的大小。
我的问题是,每当使用here 中的show_frame(..) 方法显示不同的帧时,右侧(ScrolledText)不会调整大小以匹配新的帧大小并覆盖左帧内容。
这是构造 PanedWindow 和框架容器的代码部分。
class Main(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
self.protocol("WM_DELETE_WINDOW", self.on_closing)
self.geometry('1366x768')
self.resizable(True, True)
self.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)
# Horizontal pane
self.horizontal_pane = tk.PanedWindow(self, orient=HORIZONTAL)
self.horizontal_pane.grid(row=0, column=0, sticky="nsew")
# Frames container
self.container = tk.Frame(self.horizontal_pane)
self.horizontal_pane.add(self.container)
# Log frame
self.console_frame = tk.Frame(self.horizontal_pane)
self.console_frame.columnconfigure(0, weight=1)
self.console_frame.rowconfigure(0, weight=1)
self.horizontal_pane.add(self.console_frame, stretch='always')
我该如何解决这个问题?
【问题讨论】:
标签: python user-interface tkinter