[Tutor] Question about grid layout

2016-01-17 Thread Ricardo Martínez
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!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Question about grid layout

2016-01-17 Thread Alan Gauld
On 17/01/16 18:27, Ricardo Martínez wrote:
> Hi folks, first thanks to Peter and Alan for the comments about the
> Interpreter, i really appreciate that.

I don't remember giving any comments about the interpreter,
but if I did you're welcome! :-)

> 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.

Personally I rarely use grid() unless it really is
a form that I'm creating. Usually I use pack() because
I find it more flexible. So I'd suggest that you pack()
the treeview into the frame then grid() the frame.

In the packer use the expand=True and fill=BOTH options.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor