Learning tkinter - a grid problem

Paulo da Silva p_d_a_s_i_l_v_a_ns at nonetnoaddress.pt
Sat Dec 5 13:56:46 EST 2020


Hi!

Why this example does not work?

------------------
from tkinter import *

root=Tk()
root.geometry("400x200")
S=Scrollbar(root)
T=Text(root)
T.grid(row=0,column=0)
S.grid(row=0,column=1)
S.config(command=T.yview)
T.config(yscrollcommand=S.set)
txt="""This is a very big text
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Last line
"""
T.insert(END,txt)
mainloop()
---------------------

I would like it to work more or less like this

---------------------
from tkinter import *

root=Tk()
root.geometry("400x200")
S=Scrollbar(root)
T=Text(root)
S.pack(side=RIGHT,fill=Y)
T.pack(side=LEFT,fill=Y)
S.config(command=T.yview)
T.config(yscrollcommand=S.set)
txt="""This is a very big text
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Last line
"""
T.insert(END,txt)
mainloop()
---------------------

Thanks for any help
Paulo



More information about the Python-list mailing list