pythontkinterstatettkttkbootstrap

How to change the state of a ttkbootstrap ScrolledText widget after creation?


Problem

I'm trying to change the state of a ScrolledText ttkboostrap widget after creation. I can set its state as I please when I create it, but trying to change it after creation fails for both examples below with error message: _tkinter.TclError: unknown option "-state".

Question

How can I change the state after creation?

Minimal RepEx

import ttkbootstrap as ttk
from ttkbootstrap.scrolled import ScrolledText

app = ttk.Window()

# scrolled text with autohide vertical scrollbar
st = ScrolledText(
    app,
    padding=5,
    height=10,
    autohide=True,
    # Both of these work
    state='normal'
    # state='disabled'
)
st.pack(fill='both', expand=True)

# add text
st.insert('end', 'Insert your text here.')

# Neither of these work
st.config(state='disabled')
st.configure(state='disabled')

app.mainloop()

Solution

  • Solution

    As pointed out by @jasonharper the ScrolledText widget is just a combined 'container' of a text input and a scrollbar. To change the state of the Text element, it has to be accessed directly like so:

    st.text.config(state=...)  # st is a ScrolledText object