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
| import tkinter as tk
import subprocess
def capturerFenetre(evt=None) :
try :
if subprocess.call(['scrot', '-u', '-b', '-z', 'test_capture.png']) :
texte = 'Échec de la capture d\'écran ...'
couleur = 'red'
else :
texte = 'Capture d\'écran enregistrée.'
couleur = 'lightGreen'
except FileNotFoundError :
texte = 'scrot n\'est pas installé sur votre système ...'
couleur = 'red'
resCapture['text'] = texte
resCapture['fg'] = couleur
root = tk.Tk()
root.title('Test capture d\'écran sur linux avec scrot')
resCapture = tk.Label(
bg='black',
fg='lightBlue',
width=50,
text='ctrl gauche + m pour faire une capture'
)
resCapture.grid()
can = tk.Canvas(width=300, height=300, bg='#ffff00')
can.grid()
root.bind('<KeyPress-Control_L><KeyPress-m>', capturerFenetre)
root.mainloop() |
Partager