Mercurial > hg > pub > prymula > scripts
comparison bing4desktop/bing4desktop.py @ 19:e7a6488c02b7
bing4desktop-0.240207-3
author | prymula <prymula76@outlook.com> |
---|---|
date | Wed, 07 Feb 2024 14:35:01 +0100 |
parents | 3b8fd6a7f2d0 |
children | 7f02682ff5ed |
comparison
equal
deleted
inserted
replaced
18:a1a885c59d88 | 19:e7a6488c02b7 |
---|---|
20 import json | 20 import json |
21 import tempfile | 21 import tempfile |
22 import shutil | 22 import shutil |
23 import glob | 23 import glob |
24 | 24 |
25 ver = "0.240207-2" | 25 ver = "0.240207-3" |
26 | 26 |
27 BING_URI_BASE = "http://www.bing.com" | 27 BING_URI_BASE = "http://www.bing.com" |
28 BING_WALLPAPER_PATH = "/HPImageArchive.aspx?format=js&idx=1&n=1&mkt=en-US" | 28 BING_WALLPAPER_PATH = "/HPImageArchive.aspx?format=js&idx=1&n=1&mkt=en-US" |
29 full_path="" | 29 full_path="" |
30 actualImage = 1 | 30 actualImage = 1 |
195 break | 195 break |
196 | 196 |
197 self.tmp = None | 197 self.tmp = None |
198 self.menu = ( | 198 self.menu = ( |
199 item("Ustaw Tapetę", lambda icon, item: wp.set(full_path, True)), | 199 item("Ustaw Tapetę", lambda icon, item: wp.set(full_path, True)), |
200 item('Tapeta poprzednia', lambda icon, item: self.change_pic(1)), | 200 item('Tapeta poprzednia', lambda icon, item: self.change_pic(1, icon)), |
201 item('Tapeta następna', lambda icon, item: self.change_pic(-1)), | 201 item('Tapeta następna', lambda icon, item: self.change_pic(-1, icon)), |
202 item('Opis zdjęcia', lambda icon, item: icon.notify(TMP_TITLE + ' --- ' + TMP_COPYRIGHT)), | 202 item('Opis zdjęcia', lambda icon, item: icon.notify(TMP_TITLE + ' --- ' + TMP_COPYRIGHT)), |
203 item('O Programie', lambda icon, item: self.about()), | 203 item('O Programie', lambda icon, item: self.about()), |
204 | 204 |
205 item('Wyjdź', self.quit_window) | 205 item('Wyjdź', self.quit_window) |
206 ) | 206 ) |
219 messagebox.showinfo("Bing4Desktop","Inspiracja:\npystray.readthedocs.io/en/latest/usage.html\n\nNapisał: Prymula\n\nLuty 2024\n\nLicencja:\nPublic Domain\n\nWersja: "+ver) | 219 messagebox.showinfo("Bing4Desktop","Inspiracja:\npystray.readthedocs.io/en/latest/usage.html\n\nNapisał: Prymula\n\nLuty 2024\n\nLicencja:\nPublic Domain\n\nWersja: "+ver) |
220 # możliwe że nieprawidlowe po wyjściu z aplikacji zwróci bląd :( | 220 # możliwe że nieprawidlowe po wyjściu z aplikacji zwróci bląd :( |
221 self.window.destroy() | 221 self.window.destroy() |
222 self.window.update() | 222 self.window.update() |
223 | 223 |
224 def change_pic(self, n): | 224 def change_pic(self, n, icon): |
225 global actualImage, BING_WALLPAPER_PATH | 225 global actualImage, BING_WALLPAPER_PATH, TITLE, COPYRIGHT_TXT |
226 BASE = "/HPImageArchive.aspx?format=js&idx=" | 226 BASE = "/HPImageArchive.aspx?format=js&idx=" |
227 OFF = "&n=1&mkt=en-US" | 227 OFF = "&n=1&mkt=en-US" |
228 | 228 |
229 actualImage = actualImage + n; | 229 actualImage = actualImage + n; |
230 if (actualImage < 0): | 230 if (actualImage < 0): |
249 viewer.kill() # make sure the viewer is gone; not needed on Windows | 249 viewer.kill() # make sure the viewer is gone; not needed on Windows |
250 | 250 |
251 img = Image.open(full_path) #.convert('RGBA') # PIL solution | 251 img = Image.open(full_path) #.convert('RGBA') # PIL solution |
252 self.tmp = img.resize((600, 400), None, None, 3.0) | 252 self.tmp = img.resize((600, 400), None, None, 3.0) |
253 self.tmp.show() | 253 self.tmp.show() |
254 | 254 icon.notify(TITLE + ' --- ' + COPYRIGHT_TXT) |
255 | |
255 def quit_window(self): | 256 def quit_window(self): |
256 self.icon.stop() | 257 self.icon.stop() |
257 self.window.destroy() | 258 self.window.destroy() |
258 | 259 |
259 def show_window(self): | 260 def show_window(self): |