Learning tkinter - a grid problem
MRAB
python at mrabarnett.plus.com
Sat Dec 5 15:20:11 EST 2020
On 2020-12-05 18:56, Paulo da Silva wrote:
> Hi!
>
> Why this example does not work?
>
There are a few bits of configuration missing:
> ------------------
> from tkinter import *
>
> root=Tk()
> root.geometry("400x200")
Add:
root.grid_rowconfigure(0, weight=1)
root.grid_columnconfigure(0, weight=1)
root.grid_columnconfigure(1, weight=0)
> S=Scrollbar(root)
> T=Text(root)
> T.grid(row=0,column=0)
> S.grid(row=0,column=1)
Change to:
T.grid(row=0, column=0, sticky=NSEW)
S.grid(row=0, column=1, sticky=NS)
> S.config(command=T.yview)
> T.config(yscrollcommand=S.set)
> txt="""This is a very big text
> -
> -
> -
> -
> -
> -
> -
> -
> -
> -
> -
> -
> -
> -
> -
> -
> Last line
> """
> T.insert(END,txt)
> mainloop()
> ---------------------
>
[snip]
More information about the Python-list
mailing list