tkinter - label widget text selection

R

rahulnag22

Hi,
I guess this is a very trivial question --
I am using a label widget to display text (black font in a white
background color). I am trying to use my mouse to scroll over the
displayed text to select it, but tkinter does not allow me to do it.
Is there a method/option to do this.
Thanks
Rahul
 
R

Rob Wolfe

Hi,
I guess this is a very trivial question --
I am using a label widget to display text (black font in a white
background color). I am trying to use my mouse to scroll over the
displayed text to select it, but tkinter does not allow me to do it.
Is there a method/option to do this.

Try to use an entry widget in read-only state:

<code>
import Tkinter as Tk
root = Tk.Tk()

ent = Tk.Entry(root, state='readonly', readonlybackground='white', fg='black')
var = Tk.StringVar()
var.set('Some text')
ent.config(textvariable=var, relief='flat')
ent.pack()
root.mainloop()
</code>
 
R

rahulnag22

Try to use an entry widget in read-only state:

<code>
importTkinteras Tk
root = Tk.Tk()

ent = Tk.Entry(root, state='readonly', readonlybackground='white', fg='black')
var = Tk.StringVar()
var.set('Some text')
ent.config(textvariable=var, relief='flat')
ent.pack()
root.mainloop()
</code>

Thanks Rob I will try it out...Rahul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top