[menico] Sauvegarde image tkinter
Citation:
Envoyé par
wiztricks
Salut,
Un peu de recherche sur Internet avec les mots clefs tkinter imagegrab vous donnerait des pistes. Vous avez même plein de discussions sur ce sujet ici dont la solution
proposée ici récemment.
- W
Merci pour votre réponse mais en recopiant le code proposé dans la solution :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
from PIL import ImageGrab
import tkinter as tk
root = tk.Tk()
root.configure(bg='blue')
x, y, w, h = 100, 100, 200, 200
root.geometry('%dx%d+%d+%d' % (w, h, x, y))
tk.Canvas(root, width=100, height=100, bg='grey').grid(row=0, column=0)
tk.Canvas(root, width=100, height=100, bg='green').grid(row=1, column=1)
root.update()
x = root.winfo_rootx()
y = root.winfo_rooty()
im = ImageGrab.grab((x, y, x+w, y+h))
im.save('test.png')
im.show() |
L'image test.png Pièce jointe 474140ne correspond pas au dessin voulu.