0

While using ScrolledText, clicking the mouse over an existing text will cause the line to appear and be pushed.

When only a button is clicked

After dragging over the text with the mouse

import tkinter as tk
import tkinter.scrolledtext as tkst
count=0

win = tk.Tk()

win.geometry("640x400+100+100")

text=tk.Text(win)
#text = Text(app, state='disabled', width=44, height=5)
frame1 = tk.Frame(
    master = win,
    bg = '#808000'
)
frame1.pack(fill='both', expand='yes')

editArea = tkst.ScrolledText(
    master = frame1,
    wrap   = "word",
    width  = 20,
    height = 10
)
def countUP():
    global count
    editArea.configure(state='normal')
    count +=1
    label.config(text=str(count))
    editArea.insert(tk.INSERT, "\nhello.\n")
    editArea.configure(state='disabled')

# Don't use widget.place(), use pack or grid instead, since
# They behave better on scaling the window -- and you don't
# have to calculate it manually!
text.configure(state='normal')
text.insert('end', 'Some Text')
text.configure(state='disabled')
label = tk.Label(win, text="0")
label.pack()
#editArea.insert("1.0","helloworld")
#editArea.configure(state='disabled')

editArea.pack(padx=10, pady=10, fill=tk.BOTH, expand=True)
button = tk.Button(win, overrelief="solid", width=15, 
command=countUP, repeatdelay=1000, repeatinterval=100)
button.pack()
# Adding some text, to see if scroll is working as we expect it
win.mainloop()

It's dirty because I can't organize it yet. But I wish I could solve this problem

I don't want the text to be properly aligned and pushed down

  • 1
    You *don’t* want the text to be properly aligned? What does that mean? How should it improperly be aligned? – Bryan Oakley May 14 '20 at 03:18
  • Sorry to use a translator! – 엄마쉬맘 May 14 '20 at 05:01
  • How can I organize the text by listing it underneath? If you write my code and do it like a photo, the text will be pushed – 엄마쉬맘 May 14 '20 at 05:03
  • listbox doesn't like the underline when I click it Can you customize the listbox design? So that the underline does not appear – 엄마쉬맘 May 14 '20 at 13:38
  • I have already seen that document What I want is to make sure that the text is not pushed and aligned like the question – 엄마쉬맘 May 14 '20 at 15:13
  • If `Text` is **read-only**, the user can't change the contents. Please confirm, you want a **read-only** `Text` widget? – stovfl May 14 '20 at 16:24
  • I already know text.configure (state = 'disabled'), but I want to fix a bug that looks like my photo – 엄마쉬맘 May 15 '20 at 02:09
  • ***looks like my photo***: Your image isn't that clear for me and you don't respond to my questions. I still didn't get your problem and therefore can't provide a answer. Are you aware of this: [readonly-tkinter-text-widget](https://stackoverflow.com/questions/21873195) – stovfl May 15 '20 at 08:41

0 Answers0