[Tkinter-discuss] copy-enabled Label

Michael O'Donnell michael.odonnell at uam.es
Sun May 24 10:30:03 CEST 2009


Hi O.C.

The following code shows how to use an Entry widget
which ignores all key presses except Control-c and Control-x
(copy and cut at least under windows).

from Tkinter import *

def copy1(event):
    pass

def printKey(event):
    return "break"

main=Tk()

wt=Entry(main, bg="white")
wt.insert(END, "FRed")
wt.pack(side=LEFT, fill=BOTH,expand=True)
wt.bind("<Control-c>", copy1)
wt.bind("<Control-x>", copy1)
wt.bind("<KeyPress>", printKey)
main.mainloop()



On Sun, May 24, 2009 at 12:17 AM, oc-spam66 <oc-spam66 at laposte.net> wrote:
> Hello,
>
> my application displays the result of a calculation in a Label. I would like
> the user to be able to copy this result somewhere else. I don't know how to
> enable this.
>
> I read on a mailing list that I could use a state=DISABLED Entry widget, but
> this doesn't work (I can't select anything with the mouse when it is
> DISABLED).
> I also found some complicated tcl/tk code which I did not understand.
>
> How to do ? I think a copy-enabled Label is a must.
>
> Best regards,
>
> O.C.
>
>
> Créez votre adresse électronique prenom.nom at laposte.net
> 1 Go d'espace de stockage, anti-spam et anti-virus intégrés.
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>
>


More information about the Tkinter-discuss mailing list