Python Tkinter TTK Separator With Label

后端 未结 1 870
孤街浪徒
孤街浪徒 2021-01-19 01:41

I am trying to create a custom widget that includes a separator behind a label. I would like the separator to stretch out behind the label to each side of the window (using

1条回答
  •  攒了一身酷
    2021-01-19 02:30

    The only problem with your code is that you haven't called grid_columnconfigure to tell tkinter what to do with extra space. Since you didn't tell the inner frame what to do with extra space, it left it blank. When the widget is placed in its parent and expands, your inner widgets weren't using the extra space.

    Add the following in your __init__:

    self.grid_columnconfigure(0, weight=1)
    

    As a general rule of thumb, you always want to set the weight of at least one row and one column in a parent that uses grid to manage it's children.

    0 讨论(0)
提交回复
热议问题