Bonjour,
j'aurais voulu savoir si il était possible de faire un programme tkinter qui affiche une image sur le bureau, tel mouton.exe, pour ceux qui connaissent.
En gros une image transparente, sans fenetre.
Bonjour,
j'aurais voulu savoir si il était possible de faire un programme tkinter qui affiche une image sur le bureau, tel mouton.exe, pour ceux qui connaissent.
En gros une image transparente, sans fenetre.
Bonjour,
Techniquement non : la transparence s'applique à tous les objets de la fenêtre.
@+
Bonsoir wiztricks,
Un exemple ?
J'ai beau jouer avec alpha sur un toplevel mais rien n'y fait : La transparence reste égale. Ce qui est normal.
Elle est ou l'idée ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 import Tkinter as tk # import tkinter as tk > pour Python 3.x root = tk.Tk() root.withdraw() top = tk.Toplevel(root) can = tk.Canvas(top) im = tk.PhotoImage(file="image.gif") # image.gif a remplacer can.create_image(0, 0, image=im) can.pack() top.bind('<Button-1>', lambda e: root.destroy()) top.overrideredirect(1) top.attributes("-alpha", 0.5) root.mainloop()
Merci d'avance
Bonjour,
A vrais dire la seul moyen que je vois c'est de faire un grab de l'écran (Le sujet est déjà débattu plusieurs fois : faire une recherche sur le forum.) et d’insérer l'image dans un canvas.
Le but ensuite et de dimensionner la fenêtre, sans bordure, aux dimensions de l'animation et de se déplacer dans le Canvas (scroll) et même temps que l'on déplace la fenêtre.
Le tout est de faire un grab à intervalle régulier pour avoir quelque chose de proche de ce qui est à l'écran.
La difficulté est qu'un grab prend du temps : Il vas falloir en prendre compte et le traiter 'à part'.
C'est sans doute 'du bricolage' mais je ne vois pas comment appliquer un alpha de 1.0 sur un objet (d'un Canvas ou autre) alors que le reste de l'application a un alpha de 0.0.
@+
C'est peut-être là le problèmeJe viens de faire le test sous Windows
Envoyé par doc
Ce n'est pas ce que j'ai compris dans
La méthode wm_attributes/attributes des toplevels (Toplevel/Instance Tk et exclusivement eux puisque l'on touche au WM) s'applique à la totalité des objets de celui-ci. En passant par PIL.ImageTk l'image en deviens un.
La transparence (alpha) est aussi dépendante du matériel: Cela m'étonnerais que sur une station de travail Xéon à propulsion turbonucléaire mais sur une carte mère chipset serveur et donc une 'matrox 32 Mo' en carte graphique cela tourne... De même si la carte n'est pas bien reconnue.
alpha est dans ce cas ignoré.
A noter que
Cela fonctionne sous Tux avec compiz/beryl.alpha=
(Windows, Mac)
Ma proposition est elle si 'bricolage' que personne ne la commente ?
@+
Ben en fait l'idée (rapidement) est celle ci:
La code de capture est un copier/coller du forum.
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159 #!/usr/bin/env python # -*- coding: UTF-8 -*- # # import sys import os import Tkinter as tk import Image, ImageTk IMDATA = """R0lGODlhIAAgAOfVAAoKCgsLCwwMDA8PDxAQEBERERISEhcXFxgYGBkZGRoaGhwcHB0dHR8fHyEh ISIiIiMjIyQkJCUlJSYmJicnJyoqKisrKywsLC8vLzExMTIyMjQ0NDU1NTg4ODo6Ojs7Ozw8PD09 PT4+Pj8/P0BAQEFBQUNDQ0VFRUZGRkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVNT U1RUVFVVVVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZm ZmdnZ2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNzc3R0dHV1dXZ2dnd3d3h4eHl5 eXp6ent7e3x8fH19fX5+fn9/f4CAgIGBgYKCgoODg4SEhIWFhYaGhoeHh4iIiImJiYqKiouLi4yM jI2NjY6Ojo+Pj5CQkJGRkZKSkpOTk5SUlJWVlZaWlpeXl5iYmJmZmZqampubm5ycnJ2dnZ6enp+f n6CgoKGhoaKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq6ysrK2tra6urq+vr7CwsLGxsbKy srOzs7S0tLW1tba2tre3t7i4uLm5ubq6uru7u7y8vL29vb6+vr+/v8DAwMHBwcLCwsPDw8TExMXF xcbGxsfHx8jIyMnJycrKysvLy8zMzM3Nzc7Ozs/Pz9DQ0NHR0dLS0tTU1NXV1dbW1tjY2NnZ2dra 2tvb29zc3N3d3eDg4OHh4eLi4uPj4+Xl5ebm5ujo6Onp6erq6uvr6+zs7O3t7e7u7u/v7/Dw8PLy 8vPz8/X19fb29vf39/n5+fr6+vv7+/7+/v////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////yH+EUNyZWF0ZWQgd2l0aCBH SU1QACH5BAEKAP8ALAAAAAAgACAAAAj+AP8JHEjw3wENMWzUqGFjRocHBSNKFGhiRhMyjDSVStWJ UhooN1ZEmDiRxhMzh0Qhi1at2rRmqh69uUIiA0mCIqqAqVVNGrRnQINCk1atGBkpLg7cVLEETCdn zJRJnUpVmbNYcaD0IKmhipNex4QNG0u27FhhxYh9mVJC4ggeUsoE++WLbl1geIHZ9dWrV7BDVZrk iMhESxdStBLTssW4sWNbil3doZKlAkEQXLC4IdXKFazPskKLDv358ytVf7BkKQFAIAUbWbrIyRQq FKnbo0yVMsW7VKlRt0OB6vTnCxcjKASiKLLli5tJmzh1+vTJU+3rwj1R57TJkp4wXqj++BDoY0sY M2j4RIpUqb2lS/Djw28/KZIhN2fMeIEikEmYMmiwEYcijDzyyHqSTKKggutF8ogjjezxhhpmgFHF PwU0d4aAdQByiCIEMsLIIiKSKOKIhghCxxxtqDFGFwYY8AUYaLhBRx5+DIJIIomA6KMiiyjCIyKD /JGHHW+sIYYXMYpRxhty6MHHIIb0mAgjjWSpJSNWGjIIH3nQEQcaZMQ4Bhpx0OGHIIV8KKIjcMYJ p4iKHFJIIHzYEUcaZRjwzxhpzKFHIIUo4ggk7FUyCSXtVULJo5FA0ogid+oxxxpo+OmFGnbwQcgh j0jy6CWZYIJJJqhmYoklkDZyCCH+ebpRBgH/UCFHHoEk8oglmUgHCnbYgcIJJ5hQ4qqRcIghEA9t 7BHIIo9gsgko1IoyyrXYUguKJ5hU0kgif+gBRxYCjfBEHoAsEokmnYgiSimnxCvvKaWQIkoo3TmC CB94iLHDQE/o4YcikWziCXCnpKLwwqmcYsoo+F7yiCF61NGECANNgKMij2hy8CmoqLJKKyS3sgoq qIwCSrGJEHKHHVsRxIUghzSSSSekgLwKKzyz0ooqqJhCSiiXTGLIH3fAIUBBFuxAiCGWbAJcKqh4 9pkrQJsCyiaRMAKIHkSwIFEHexQCiSWgjKJwK6+48srPqJDSSSb68ksCSRBcYchdIlFPjQorCpsi SieVQDIIIGOocJNAdSBqiXWmLHwKKZ5kAskihPixweIDoUCGI5tookl0nIhuSSWLvIED5wXxIIQc glhiKiaXVFJIHE1MwTpJHNwQRBA7pBAA5wEBADs= """ SENSE = "DOWN" class ScreenCap(object): def __init__(self): """Screenshot class""" if sys.platform == 'linux2': self.grab = self._GarbLinux elif sys.platform == 'win32': import Image, ImageGrab self.grab = self._GrabWin elif sys.platform == 'darwin': self.grab = self._GrabMac else: sys.exit(1) self._currentf = None def _FicNormalyze(self, name): """Internal Function for generate temp file. Use home user directory for rights. """ if name: if os.path.basename(name) == name: _grabfile = os.path.join(os.path.expanduser('~'), name) else: _grabfile = name else: # default name _grabfile = os.path.join(os.path.expanduser('~'), 'scrcap.jpg') self._currentf = _grabfile return _grabfile def _GarbLinux(self, name=None): """Internal function for screen capture under Linux Use ImageMagick import utility """ _grabfile = self._FicNormalyze(name) _grabcommand = "import -silent -window root " + _grabfile os.system(_grabcommand) return _grabfile def _GrabWin(self, name=None): """Internal function for screen capture under Windows. Use PIL ImageGrab. """ try: import ImageGrab except: # Experimental import for PIL under Python 3. from PIL import ImageGrab _grabfile = self._FicNormalyze(name) ImageGrab.grab().save(_grabfile, "JPEG") return _grabfile def _GrabMac(self, name=None): """Internal function for screen capture under Mac. Use screencapture command. """ _grabfile = self._FicNormalyze(name) _grabcommand = "screencapture -m -x -t jpg " + _grabfile os.system(_grabcommand) return _grabfile def delete(self): """Internal function. Delete temp file.""" if os.path.isfile(self._currentf): os.remove(self._currentf) def anime(): global SENSE for i in range(top.winfo_screenwidth()-H): imcoords = canvas.coords(ball) if not i % 3: canvas.xview("scroll", 1, "units") if SENSE == "DOWN": canvas.coords(ball, (imcoords[0]+1, imcoords[1]+1)) # canvas.move() ? if int(canvas.coords(ball)[1]) >= H*4: SENSE = "UP" else: canvas.coords(ball, (imcoords[0]+1, imcoords[1]-1)) if int(canvas.coords(ball)[1]) <= 0: SENSE = "DOWN" top.geometry("%dx%d+%d+0" % (W, H*5, i)) top.update() top.after(5) top.destroy() sys.exit() root = tk.Tk() root.title('Ball') tk.Button(root, text='Done', command=root.destroy).pack() root.iconify() root.update() top = tk.Toplevel(master=root) top.withdraw() Sccap = ScreenCap() canvas = tk.Canvas(top, width=top.winfo_screenwidth(), height=top.winfo_screenheight(), bd=0, highlightthickness=0) screencapture = Image.open(Sccap.grab(name='scrcap.jpg')) photo = ImageTk.PhotoImage(screencapture) fond = canvas.create_image(0, 0, image=photo, anchor='nw') Sccap.delete() canvas.config(scrollregion=canvas.bbox('all'), yscrollincrement='1') anim = tk.PhotoImage(data=IMDATA) W = anim.width() H = anim.height() ball = canvas.create_image(0, 0, image=anim, anchor='nw') canvas.pack(fill='both') top.geometry("%dx%d+0+0" % (W, H*5)) top.update() top.overrideredirect(1) top.deiconify() top.attributes("-topmost", 1) root.after(1, anime) root.mainloop()
A noter que sous Windows/Linux il est possible d'utiliser bbox/des coordonnées pour limiter la capture à une zone. Je ne pense pas, dans la limite de mes connaissances, que cela soit possible avec screencapture sous mac.
Les difficultés ici sont :
Synchroniser le scroll du Canvas avec la position sur l'écran. Soit remplacer if not i % 3 dans le code par la correspondance des coordonnées écran/Canvas.
Déplacer le Toplevel sans .update() ou réduire les effets de bordure produits dans le cadre d'un overrideredirect.
Faire une mise à jour de l'image 'fond' (l'item 1 du Canvas) en arrière plan sans ralentir l'animation. Et ce avec un canvas.tag_lower(ball)/canvas.tag_raise(ball) lors de la 'capture' pour ne pas avoir une 'persistance'/'traînée' de l'image gif.
Ici j'ai choisi un gif mais dans ce cas n'importe quelle animation dans le Canvas fonctionne.
@+
Une autre application (sans animation) de la 'chose' au passage.
Il est bien sur possible de ne pas utiliser create_image mais un create_oval par exemple : Cela ouvre la perspective d'avoir des fenêtres non rectangle et ce quelque soit le système et ses possibilités.
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266 #!/usr/bin/env python # -*- coding: UTF-8 -*- # # import sys import os import Tkinter as tk import Image, ImageTk IMDATA = """R0lGODlhrwNqA6ECAAAAAPb3+P///////yH5BAEAAAMALAAAAACvA2oDAAL+nI+py+0Po5y02ouz 3rz7D4biSJbmiabqyrbuC8fyTNf2jef6zvf+DwwKh8Si8YhMKpfMpvMJjUqn1Kr1is1qt9yu9wsO i8fksvmMTqvX7Lb7DY/L5/S6/Y7P6/f8vv8PGCg4SFhoeIiYqLjI2Oj4CBkpOUlZaXmJmam5ydnp +QkaKjpKWmp6ipqqusra6voKGys7S1tre4v7CrALtcubCxwsDOhbDNBr7Du8zNx8lgyNDG3sXG19 3TStffy0rY0NHi4u413O7WRePr7O3n6RDi8Nr+5eby8+n3+erT9//w/wVr9+8gbGC4gwoSmDAwsy PKgwokRLDw06rAhxosb+jYYwWpTisSHHkSTzhMzX5aS/kixbqlFp7hlMby5r2uQyc9ubnN9u+vzJ hOe0OkKjAT2KtEfRZHuWUksKNaoLp8UCUVUmNavWD1exDur6a6vYsQ/A7jtklqxasmkhgV0LF+pb ilfj2rXZtVPdu3w35gW1t69ggH9HBR6MeNzhU1QTO762WFXjx5SDRW41ubLmWIVndd4MeuFlWqND m9b0GVjp06wjpR62urVsRK+bxZ6N+09ta7dz+7azG1zv38TbzLUXvLhyNMcJD18OPWXydtOjW8fS PGL169wv8iz5vLv4I9k5bh+PPsh5hevTu79RvmX79/RhzJcYv75+cvf+NfbfDyBX4bGUX4AGjvAf eAMeyCAFCRL4YIMSGhChSxVOaOCFFmqI4XsFrsVhh+N9CBeJIh5ool0pnljfiiqGyGJubYE2Y4z7 1UijizYuZ9ZZofW4o3tAzjZkkN3hSKSORrKGJG5NLunbk04qCSVlRfIoZZU5UmnalVp2mSVxXn6p WZhYwkgmUGOKt2aafLXJpplujgXniHLOmVWd6OmJp1R87nlnnz/16COAhAq61aETKoqoXH/SR2ih jeLF6KKVTlpTpJIyqCmmmUZqY6eeKnjpiaKO6heoRp6KqnaqLslqq869CqWmm8qqWKy16oprrrR+ aWuv1PFapa23Csv+jLF9K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VPLMNqyw0LfPJSPMMzew0HwKPVDMJ+6w1z7LpYBMZGm02h5CKbJMWOi03WRDpePMkPe03UQ0t hZMfXa04FXLokLMrTW05zzGAnLPpJY8zOgsRK6hT6artOrHTebSTHYutO+eRLsHTDqdzPN8QK6OT 5caTV4oT56iTKnlT6JDTP0iT6eKTL1TT6mAzLUKT7OpzMB5z7iRTNTQS8gqUOO5x8hJ0PZpx9RqU JNfy90YxSPSw/CoUTHZSADP0ULLSA2fyHQ0QCqcyHMdPDFVy+Zix9kz0CnOvGCtvRZWS7WAR8GBU K0EOG7GuRrXv5SjxRnX01v4RgfDxRz9Nzb7QSInUTQ4TnI4xSZVUwawSEZ00h/ZQsVBzSrmyL+us KrEUMrazS8E0TMV0TMm0TM30TNE0TVe0AAAAOw== """ class ScreenCap(object): def __init__(self): if sys.platform == 'linux2': self.grab = self._GarbLinux elif sys.platform == 'win32': import Image, ImageGrab self.grab = self._GrabWin elif sys.platform == 'darwin': self.grab = self._GrabMac else: sys.exit(1) self._currentf = None def _FicNormalyze(self, name): if name: if os.path.basename(name) == name: _grabfile = os.path.join(os.path.expanduser('~'), name) else: _grabfile = name else: # default name _grabfile = os.path.join(os.path.expanduser('~'), 'scrcap.jpg') self._currentf = _grabfile return _grabfile def _GarbLinux(self, name=None, bbox=None): _grabfile = self._FicNormalyze(name) _crop = "" if bbox: _crop = "-crop %dx%d+%d+%d " % (bbox[2]-bbox[0], bbox[3]-bbox[1], bbox[0], bbox[1]) _grabcommand = "import -silent -window root %s%s" % (_crop, _grabfile) os.system(_grabcommand) return _grabfile def _GrabWin(self, name=None, bbox=None): try: import ImageGrab except: from PIL import ImageGrab _grabfile = self._FicNormalyze(name) ImageGrab.grab(bbox).save(_grabfile, "JPEG") return _grabfile def _GrabMac(self, name=None, bbox=None): _crop = "" if bbox: pass # :/ _grabfile = self._FicNormalyze(name) _grabcommand = "screencapture -m -x %s-t jpg %s" % (_crop, _grabfile) os.system(_grabcommand) return _grabfile def delete(self): if os.path.isfile(self._currentf): os.remove(self._currentf) root = tk.Tk() root.title('App') im = tk.PhotoImage(data=IMDATA) imw = im.width() imh = im.height() box = ((root.winfo_screenwidth()-imw)/2, (root.winfo_screenheight()-imh)/2, imw+(root.winfo_screenwidth()-imw)/2, imh+(root.winfo_screenheight()-imh)/2) tk.Button(root, text='Done', command=root.destroy).pack() root.iconify() splash = tk.Toplevel(master=root) splash.withdraw() Sccap = ScreenCap() canvas = tk.Canvas(splash, width=imw, height=imh, bd=0, highlightthickness=0) screencapture = Image.open(Sccap.grab(name='scrcap.jpg', bbox=box)) photo = ImageTk.PhotoImage(screencapture) fond = canvas.create_image(0, 0, image=photo, anchor='nw') Sccap.delete() bhzd = canvas.create_image(0, 0, image=im, anchor='nw') canvas.pack(fill='both') splash.geometry("%dx%d+%d+%d" % (imw, imh, box[0], box[1])) texte = canvas.create_text(imw/2, imh/2+50, anchor='center', fill="yellow", text="ENTER", width=100, activefill="red", font="Helvetica") canvas.tag_bind(texte, "<Button-1>", lambda e: splash.destroy() or root.deiconify()) splash.update() splash.overrideredirect(1) splash.deiconify() splash.attributes("-topmost", 1) root.mainloop()
Bonsoir,
Une animation pour le po quand même...
@+
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230 #!/usr/bin/env python # -*- coding: UTF-8 -*- # # import sys import os import Tkinter as tk import Image, ImageTk import base64 ANIGIF = """R0lGODlhyABkAPMAAAAAAACAuff396GhoV1dXf+ZmallVvqZZmY0Mx0bGAAAAAAAAAAAAAAAAAAA AAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJDwAAACwAAAAAyABkAEME/xDISau9OOvNu/9gKI5k aZ5oaBTHURRIKs90vSGGgSRA4ho2y27iY70OOl4vwWR+CISBVBoVCKBNqNTK7XaVwXAogXMdeSuw aNU6W8g/AMHrJQACATnX3szuJXNWUwNqEjxQRASFYowlCC4tkZKTbZVMkG1ARW0FmnRWfHoChpiR nRVsan1OFFFKCQOCA1WgNLBchABeF7BSPLGKKGyVRpTElaZxbDAAw5C/n3R2yzFvpSyHs4eCSrRd uUGB0eNcizMJzizGL6fD6sjrnZfFkOwsOTlmLAAI7/pHZjwJCkbhloABjTpE8SWKG6MVL3aUgvds EyV6FesdeBVN0apFUf+w9BBnpRu0LnYSqvSwCuJFY+sMoPHnb+IzAxsTkNvJ06ETJbEEmFtJ9CE7 ZDRf8kAX0ODBYAmgLOw5RaShoH+Kat3aqF/SJG+YaBlUtQnXs2jTql3Ltq3bt3DXPtoYt65dGZtY DAk7dAzJngP73k2BA6CLaiaKMBOiDlvDnikNfWxS7vHBLdJ6YD04OCEZnP+OIinkLE4Pl5m2fbIj LhdOw0ex6eQjOCpKzZcJtv07Cq9NSTVfKmsMpB9wILwF9ZAghV8xNcZ1PFIHJupmQj8dYgVnQyc5 jystUpxUMzh5U0BKn/I+bqnGQugaM3sVC+ESIkEFyyA5C3AtMaXB5Jj/c+sk8ww/mOi1VH1S8UFH Qa8dJRNus+RXkEOdCQObPATCpJF8dKn322GKMZMcOb5g4c1TQWlxxVW46JfhCEwdUd4RMrlkxAsT xufhS43RxYp1uMwi1WRmYWBdN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2jTznodmYi3G gGk/LUIpUMGGVjPlBAUE5h5xYkpfBrKVR5mIAhkBBaAgGAwMdBjOB4FvPgyrxDVb4bVpzYgMbjTV 34jZsE+FJAtYCMlIPVkCx9h0TwECVgYyt56WbO89nBjGDGrivK0Z0BqTmE1Yg9q4WIyhh4wCQiVp kLn5rWIpCEssTKG4MF3ObkZ8wysFFDSd/6iPNcAgKSLMoY/paVYF6FEoW2IIH+ZEzYCeyJkXuCHT vPYHNn7NmGbAKjK+6AqLQnhWLPfTjVdCJKrsCAXDIlGfqgBxVmAjy8gmJDcW7IKLcv+sTkhXgCWj jet7T0XZWkhWH7JVM1p8oOeP4tcKCokyf2mt7RKNIrK3wpUtbjrauJyWrAhKsljeDNdG63q9Cgzl KNvsb27jWRHLyRdsU0GhYamBB8teyg1t/aCN8mA1DCGFdmf8rBBKWeAgTcQlelXpa+2ZIf4GcBCr oNtvWFmE20B3BZRtKTL4RrnX/pFqTcMlVfhByEKqUo0vHmpf38LhxKbWay9d2GsphOLLjm9E6CWO qlpZ0Nza7S/oMVgBs/xQJWjPxFcFQk4WCIbrCZXB03iUgP8Cu+6Bs7DQUMtxJJYAYohgFv8cKfXK aFPVFtKWvEKsh98EvLbOtUF/RELZNNbbpXMaAc3kDCIBG+phL9vjOO25j4g36tEfkC/PoKahZxWB Tj6CUB1Qfalbw1u8Z4gzK0rqyWNCnRvICcVS6b0hS6gZ3ImeTTuoVkXvguKYPC5RthrJNaBlVcTL 3QMsm4goTAGIsy2NulKeXgJ5TG3LC9ZP1ZZeDzRubJC9eJp8GaCiQKvc7Q+kRtyTis3x7qrVn9q2 Qv1b1Zrb3UOTlWbXQ3S3FhnNbn6noJm7JHdure2Tn6jb4P2+9KzqF2SIo6UTQ4Miqy1+Q4pzPIhy rvjHdfStkWMgAgA7 """ class ScreenCap(object): def __init__(self): if sys.platform == 'linux2': self.grab = self._GarbLinux elif sys.platform == 'win32': import Image, ImageGrab self.grab = self._GrabWin elif sys.platform == 'darwin': self.grab = self._GrabMac else: sys.exit(1) self._currentf = None def _FicNormalyze(self, name): if name: if os.path.basename(name) == name: _grabfile = os.path.join(os.path.expanduser('~'), name) else: _grabfile = name else: # default name _grabfile = os.path.join(os.path.expanduser('~'), 'scrcap.jpg') self._currentf = _grabfile return _grabfile def _GarbLinux(self, name=None, bbox=None): _grabfile = self._FicNormalyze(name) _crop = "" if bbox: _crop = "-crop %dx%d+%d+%d " % (bbox[2]-bbox[0], bbox[3]-bbox[1], bbox[0], bbox[1]) _grabcommand = "import -silent -window root %s%s" % (_crop, _grabfile) os.system(_grabcommand) return _grabfile def _GrabWin(self, name=None, bbox=None): try: import ImageGrab except: from PIL import ImageGrab _grabfile = self._FicNormalyze(name) ImageGrab.grab(bbox).save(_grabfile, "JPEG") return _grabfile def _GrabMac(self, name=None, bbox=None): _crop = "" if bbox: pass # :/ _grabfile = self._FicNormalyze(name) _grabcommand = "screencapture -m -x %s-t jpg %s" % (_crop, _grabfile) os.system(_grabcommand) return _grabfile def delete(self): if os.path.isfile(self._currentf): os.remove(self._currentf) def anim(): global index, afterevent imcoords = canvas.coords(cochon) imcoords[0] += 10 canvas.coords(cochon, (imcoords[0], imcoords[1])) canvas.itemconfig(cochon, image=frames[index]) index += 1 if index == len(frames): index = 0 afterevent = root.after(delay, anim) if imcoords[0] >= imw: onexit() def onexit(e=None): root.after_cancel(afterevent) splash.destroy() if os.path.isfile('anim.gif'): os.remove('anim.gif') root.deiconify() root = tk.Tk() root.title('Demo') with open('anim.gif', 'wb') as f: f.write(base64.decodestring(ANIGIF)) with open('anim.gif', 'rb') as f: im = Image.open(f) seq = [] try: while 1: seq.append(im.copy()) im.seek(len(seq)) except EOFError: pass try: delay = im.info['duration'] except KeyError: delay = 100 first = seq[0].convert('RGBA') frames = [ImageTk.PhotoImage(first)] imw = root.winfo_screenwidth() imh = frames[0].height() temp = seq[0] for image in seq[1:]: temp.paste(image) frame = temp.convert('RGBA') frames.append(ImageTk.PhotoImage(frame)) index = 0 box = (0, 0, imw, imh) tk.Button(root, text='Done', command=root.destroy).pack(fill='both', padx=10, pady=10) root.iconify() splash = tk.Toplevel(master=root) splash.withdraw() Sccap = ScreenCap() canvas = tk.Canvas(splash, width=imw, height=imh, bd=0, highlightthickness=0) screencapture = Image.open(Sccap.grab(name='scrcap.jpg', bbox=box)) photo = ImageTk.PhotoImage(screencapture) fond = canvas.create_image(0, 0, image=photo, anchor='nw') Sccap.delete() cochon = canvas.create_image(0, 0, image=frames[0], anchor='nw') canvas.pack(fill='both') splash.geometry("%dx%d+%d+%d" % (imw, imh, box[0], box[1])) splash.bind('<Button-1>', onexit) splash.update() splash.overrideredirect(1) splash.deiconify() splash.attributes("-topmost", 1) root.protocol("WM_DELETE_WINDOW", onexit) root.after(1, anim) root.mainloop()
Edit : Par contre si vous trouvez comment faire avec alpha je prend.
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager