Bonjour,

Je suis débutant python, j'utilise l'interface Tkinter et Python 2.7.6.
Je voudrais savoir comment faire le copier coller du presse-papier avec Tkinter.
Pouvez vous me donner un exemple ?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
#-*- coding: utf-8 -*-
 
#+---------------------------------------------------------------------+
#|                            IMPORTS                               |
#+---------------------------------------------------------------------+
from Tkinter import *
import Tkinter
 
#+---------------------------------------------------------------------+
#|                            VARIABLES                               |
#+---------------------------------------------------------------------+
champs_saisie = None
 
#+---------------------------------------------------------------------+
#|                            CONSTANTES                               |
#+---------------------------------------------------------------------+
TEXTE_DEPUIS_DEBUT = 1.0
DIMENTION_CHAMPS_WIDTH = 80
DIMENTION_CHAMPS_HEIGHT = 20
 
#+---------------------------------------------------------------------+
#|                            FONCTIONS                               |
#+---------------------------------------------------------------------+
def fenetre_principale():
    global fp
    fp = Tkinter.Tk()
 
def valider():
    le_texte = champs_saisie.get(TEXTE_DEPUIS_DEBUT, END)[:-1]
    print le_texte 
 
def champs_saisie():
    global champs_saisie
    champs_saisie = Text(fp, width=DIMENTION_CHAMPS_WIDTH, height=DIMENTION_CHAMPS_HEIGHT, foreground='black', background='white')
    champs_saisie.pack(side=TOP)   
 
    le_texte = champs_saisie.get(TEXTE_DEPUIS_DEBUT, END)[:-1]	
    print "le texte : " + "  '" + le_texte + "'"
 
def boutons():
    bt1 = Button(fp, text='    Valider    ', command=valider)
    bt1.pack()
    bt2 = Button (fp, text = "     Quitter     ", command =fp.destroy)
    bt2.pack()#(side=TOP, fill=X, padx=5, pady=2.5)
 
def executer():
    fenetre_principale()
    champs_saisie()
    boutons()
 
executer()
 
fp.mainloop()
Merci.