tkinter resize label width (grid_propagate not working)
<p>I'm having problem with adjusting the width of the label to reflect current width of the window. When the window size changes I'd like label to fill the rest of the width that is left after other widgets in row consume width they need.
Putting the label in a Frame and using <em>grid_propagate(False)</em> does not seem to work.
Consider following code:</p>

<pre><code>import tkinter as tk
import tkinter.ttk as ttk


class PixelLabel(ttk.Frame):
    def __init__(self,master, w, h=20, *args, **kwargs):
        '''
        creates label inside frame,
        then frame is set NOT to adjust to child(label) size
        and the label keeps extending inside frame to fill it all,
        whatever long text inside it is
        '''
        ttk.Frame.__init__(self, master, width=w, height=h,borderwidth=1)
        #self.config(highlightbackground="blue")

        self.grid_propagate(False) # don't shrink
        self.label = ttk.Label(*args, **kwargs)
        self.label.grid(sticky='nswe')

    def resize(self,parent,*other_lenghts):
        '''
        resizes label to take rest of the width from parent
        that other childs are not using
        '''
        parent.update()
        new_width = parent.winfo_width()
        print(new_width)

        for lenght in other_lenghts:
            new_width -= lenght
            print(new_width)

        self.configure(width = new_width)

root = tk.Tk()

master = ttk.Frame(root)
master.grid()

label = ttk.Label(master,text='aaa',borderwidth=1, relief='sunken')
label.grid(row=0,column=0)

label1_width = 7
label1 = ttk.Label(master,text='bbbb',borderwidth=1, relief='sunken',width=label1_width)
label1.grid(row=0,column=1)

label2 = ttk.Label(master,text='ccccccccccccccccccccccccccccccccccccc',borderwidth=1, relief='sunken')
label2.grid(row=0,column=2)

label3_width = 9
label2 = ttk.Label(master,text='ddddd',borderwidth=1, relief='sunken',width=label2_width)
label2.grid(row=0,column=3)

label4 = ttk.Label(master,text='ee',borderwidth=1, relief='sunken')
label4.grid(row=1,column=0)

label5 = ttk.Label(master,text='f',borderwidth=1, relief='sunken')
label5.grid(row=1,column=1,sticky='we')

nest_frame = ttk.Frame(master)
nest_frame.grid(row=2,columnspan=4)

label8_width = 9
label8 = ttk.Label(nest_frame,text='xxxxx',borderwidth=1, relief='sunken',width=label8_width)
label8.grid(row=0,column=0)

label9 = PixelLabel(nest_frame, 5, text='should be next to xxxxx but is not?',borderwidth=1, relief='sunken')
label9.grid(row=0,column=1)
label9.resize(root,label2_width)

root.mainloop()
</code></pre>

<ol>
<li>Why label9 does not appear next to label8</li>
<li>How to make label9 resize to meet current window size (this code is just a sample, I would like to be able to resize label9 as the window size changes dynamically when functions are reshaping the window)</li>
</ol>