''' tk_scrolledtext101.py
explore Tkinter's ScrolledText widget
inside the edit_space use
ctrl+c to copy, ctrl+x to cut selected text,
ctrl+v to paste, and ctrl+a to select all

uses the same methods as the Text() widget
'''

try:
    # for Python2
    import Tkinter as tk
    import ScrolledText as tkst
except ImportError:
    # for Python3
    import tkinter as tk
    import tkinter.scrolledtext as tkst


root = tk.Tk()
root.title("ScrolledText")
frame = tk.Frame(root, bg='brown')
frame.pack(fill='both', expand='yes')

edit_space = tkst.ScrolledText(
    master = frame,
    wrap   = 'word',  # wrap text at full words only
    width  = 25,      # characters
    height = 10,      # text lines
    bg='beige'        # background color of edit area
)
# the padx/pady space will form a frame
edit_space.pack(fill='both', expand=True, padx=8, pady=8)

mytext = '''\
Man who drive like hell, bound to get there.

Man who run in front of car, get tired.

Man who run behind car, get exhausted.

The Internet: where men are men, women are men, and children are FBI agents.
'''

edit_space.insert('insert', mytext)

root.mainloop()

# optiona info
#help(tkst.ScrolledText)
3
Contributors
2
Replies
23
Views
2 Years
Discussion Span
Last Post by toyota_1
0

I wanted to add another textbox to bottom. That textbox act as input. Just single line only but no scrolledtext.
in old python2:
entry = Entry(root, width = 20)
entry.pack( side = BOTTOM )
How can I used scrolledtedtext without scrolling?

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.