Learning tkinter - a grid problem

Paulo da Silva p_d_a_s_i_l_v_a_ns at nonetnoaddress.pt
Sat Dec 5 15:45:12 EST 2020


Às 20:20 de 05/12/20, MRAB escreveu:
> 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
>> -

Ok, thank you.


More information about the Python-list mailing list