In your question you are using pack . pack has options to say that it grows or contracts in either the one or both x and y axes. Vertical scrollbars should usually increase / decrease along the y axis, and horizontal scroll bars should be along the x axis. Text widgets usually need to fill in both directions.
To create a text widget and scrollbar in a frame, you usually do something like this:
scr.pack(side="right", fill="y", expand=False) text.pack(side="left", fill="both", expand=True)
The following is said above:
- the scroll bar is on the right (
side="right" ) - the scroll bar must stretch to fill any extra space along the y axis (
fill="y" ) - the text widget is on the left (
side="left" ) - the text widget must be stretched to fill any extra space along the x and y axis (
fill="both" ) - the text widget will expand to take up all the remaining space in the containing frame (
expand=True )
For more information see http://effbot.org/tkinterbook/pack.htm
source share