tkinter resizable text with grid

Peter Otten __peter__ at web.de
Thu Dec 6 03:24:01 EST 2018


Paulo da Silva wrote:

> Does anybody know why this code does not expand the text widget when I
> increase the window size (with mouse)? I want height and width but as
> minimum (or may be initial) size.
> 
> import tkinter as tk
> 
> class App:
>     def __init__(self,master):
>         self.tboard=tk.Text(master,height=40,width=50)
>         self.tboard.grid(row=1,column=1,sticky="nsew")

You have to set the column/row weight of the /master/:

          master.grid_columnconfigure(1, weight=1)
          master.grid_rowconfigure(1, weight=1)

Also, columns and rows usually start with 0.
 
> root=tk.Tk()
> app=App(root)
> 
> root.mainloop()
> 
> Thanks





More information about the Python-list mailing list