[Tutor] Question about grid layout

Ricardo Martínez lordrip at gmail.com
Sun Jan 17 13:27:40 EST 2016


Hi folks, first thanks to Peter and Alan for the comments about the
Interpreter, i really appreciate that.

The question that i have in mind is about grid layout, i have the below
code and i want to resize every widget when the user resize the main
windows.

"""
START
"""


import tkinter  as tk
import tkinter.ttk as ttk


class sqlConsole(ttk.Frame):
    def __init__(self):
        self.root = tk.Tk()
        self.width = "640"
        self.height = "480"

        ttk.Frame.__init__(self, self.root)
        self.createWidgets()
        self.layoutWidgets()

        self.root.mainloop()


    def createWidgets(self):
        self.frmFrame = ttk.Frame(self.root, width=self.width,
height=self.height)
        self.grdResult = ttk.Treeview(self.frmFrame)

        self.grdResult.column("#0", width=self.width)
        self.frmFrame.grid_propagate(0)


    def layoutWidgets(self):
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)
        self.frmFrame.rowconfigure(0, weight=1)
        self.frmFrame.columnconfigure(0, weight=1, minsize=self.width)

        self.grdResult.grid(row=0, column=0, columnspan=5, padx=5, pady=5, \
            sticky="nsew")
        self.frmFrame.grid(sticky="nsew")


if __name__ == "__main__":
    app = sqlConsole()


"""
END
"""

The issue that i have is when i resize the window the Treeview won't, i
tried combinations of sticky as NWSE, or WS, but is not working for me,
and i think that i'm missing some instruction in the grid layout that is
avoiding the widget resize.

I've googled the issue but not finish to understand the "misterious ways of
the grid layout", sometimes i think that is like "the ways of the force".

Thanks in advice!


More information about the Tutor mailing list