简体   繁体   English

如何让 ttk.Progressbar 占据一帧的整个宽度?

[英]How to make ttk.Progressbar take up the entire width of a frame?

I have a GUI that I'm working on and it's mostly coming along well after a few hiccups but one thing I can't figure out is how to make ttk.Progressbar take up the entire width of the frame it's been placed in.我有一个我正在开发的 GUI,在经历了几次小问题之后,它大部分都运行良好,但我不知道的一件事是如何让ttk.Progressbar占据它所在框架的整个宽度。

Here's the code I use to create the progress bar:这是我用来创建进度条的代码:

    def _create_progressbar(self):
        self.progress = ttk.Progressbar(self.bottom, orient=tk.HORIZONTAL, mode='determinate')
        self.progress.grid(row=0, column=0, sticky=tk.E+tk.W)

I've tried a few approaches, with the latest you can see in the code with sticky=tk.E+tk.W but none of them seem to do anything and the bar stays narrow (highlighted in red) even though the frame it is in takes up the entire width of the parent window.我尝试了几种方法,最新的你可以在代码中看到sticky=tk.E+tk.W但它们似乎都没有做任何事情,即使框架它也保持狭窄(以红色突出显示) in 占据了父 window 的整个宽度。 Also from what I'd checked it doesn't seem like progress bar widget has width parameter at all.同样从我检查的内容来看,进度条小部件似乎根本没有width参数。

在此处输入图像描述

Does anyone know how to change the width?有谁知道如何改变宽度?

Even though you tell the progress bar to take up all the horizontal space of the cell, but you didn't tell the layout manager that column 0 (where the progress bar is) to take up all the available horizontal space of the frame:即使您告诉进度条占用单元格的所有水平空间,但您没有告诉布局管理器第 0 列(进度条所在的位置)占用框架的所有可用水平空间:

self.bottom.columnconfigure(0, weight=1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM