I have some Tkinter code with a Label object. The user needs to be able to select text from the Label in order to copy the text (and paste into something else). However, it seems Labels aren't selectable? I can't figure out how to enable this... any suggestions?

from Tkinter import *

master = Tk()

label = Label(master, text="Example: foo_bar(1,2,3)")


That sort of works, however when you select the text, it's clear that its a text entry field instead of a label. This is because a thick border appears around the text box when you click on it. Is there any way to not have the border appear when selected?

Hi, your code works perfectly fine:

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')

But instead of 'Some text' I would like to put a variable of an entry, to display what the user types, but that you are able to copy paste it! For now my code is:

from Tkinter import *

frame = Tk()

userinput = StringVar()

entry = Entry(frame, textvariable=userinput)


entry2 = Entry(frame, state="readonly")




It displays an error, and I have to figure this out soon, for a school project
Hope you can help :D Thanx

Edited 1 Year Ago by FredyTek

This article has been dead for over six months. Start a new discussion instead.