You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调整Tkinter应用窗口尺寸后仍无法显示完整内容及日历组件求助

问题:Tkinter应用窗口尺寸不生效+日历组件被遮挡
  • 开发名为“Gerenciador de Apostas”的Tkinter应用,设置self.geometry("1000x700")试图放大窗口,但窗口并未按设置尺寸显示。
  • 原本页面无法滚动,添加Canvas和Scrollbar后实现了滚动,但日期筛选的日历选择组件因屏幕空间不足被遮挡。
  • 尝试配置frame_principal的grid布局权重,问题仍未解决。

应用截图

  • 主界面:App image
  • 被遮挡的日历组件:Hidden Calendar Error

相关代码

class App(tk.Tk):
    def __init__(self, gerenciador):
        super().__init__()
        self.gerenciador = gerenciador
        self.title("Gerenciador de Apostas")
        self.geometry("1000x700")  # 尝试增大窗口空间
        
        # Canvas 和 Scrollbar
        self.canvas = tk.Canvas(self)
        self.canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)

        self.scrollbar = ttk.Scrollbar(self, orient=tk.VERTICAL, command=self.canvas.yview)
        self.scrollbar.pack(side=tk.RIGHT, fill=tk.Y)

        self.canvas.configure(yscrollcommand=self.scrollbar.set)
        self.canvas.bind('<Configure>', self.on_canvas_configure)

        self.frame_principal = ttk.Frame(self.canvas)
        self.canvas.create_window((0, 0), window=self.frame_principal, anchor=tk.NW)

尝试的布局配置

# 响应式布局配置
self.frame_principal.grid_rowconfigure(0, weight=1)
self.frame_principal.grid_rowconfigure(1, weight=3)            
self.frame_principal.grid_rowconfigure(2, weight=2)   
self.frame_principal.grid_columnconfigure(0, weight=1)

内容的提问来源于stack exchange,提问作者Jonh Alex

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 06:30:55