try except in likely to break places
This commit is contained in:
parent
d3089ffa8c
commit
a03e83e21d
|
@ -24,7 +24,8 @@
|
||||||
|
|
||||||
|
|
||||||
import win32gui
|
import win32gui
|
||||||
import win32con # winapi contants
|
import pywintypes
|
||||||
|
import win32con # winapi constants
|
||||||
import systray
|
import systray
|
||||||
import gtk
|
import gtk
|
||||||
import os
|
import os
|
||||||
|
@ -145,7 +146,10 @@ class NotifyIcon:
|
||||||
self._callbackmessage = WM_TRAYMESSAGE
|
self._callbackmessage = WM_TRAYMESSAGE
|
||||||
self._hicon = hicon
|
self._hicon = hicon
|
||||||
|
|
||||||
|
try:
|
||||||
win32gui.Shell_NotifyIcon(win32gui.NIM_ADD, self._get_nid())
|
win32gui.Shell_NotifyIcon(win32gui.NIM_ADD, self._get_nid())
|
||||||
|
except pywintypes.error:
|
||||||
|
pass
|
||||||
if tooltip: self.set_tooltip(tooltip)
|
if tooltip: self.set_tooltip(tooltip)
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,7 +178,7 @@ class NotifyIcon:
|
||||||
""" Removes the tray icon. """
|
""" Removes the tray icon. """
|
||||||
try:
|
try:
|
||||||
win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, self._get_nid())
|
win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, self._get_nid())
|
||||||
except: # maybe except just pywintypes.error ? anyways..
|
except pywintypes.error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -182,7 +186,10 @@ class NotifyIcon:
|
||||||
""" Sets the tray icon tooltip. """
|
""" Sets the tray icon tooltip. """
|
||||||
self._flags = self._flags | win32gui.NIF_TIP
|
self._flags = self._flags | win32gui.NIF_TIP
|
||||||
self._tip = tooltip
|
self._tip = tooltip
|
||||||
|
try:
|
||||||
win32gui.Shell_NotifyIcon(win32gui.NIM_MODIFY, self._get_nid())
|
win32gui.Shell_NotifyIcon(win32gui.NIM_MODIFY, self._get_nid())
|
||||||
|
except pywintypes.error:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def show_balloon(self, title, text, timeout=10, icon=win32gui.NIIF_NONE):
|
def show_balloon(self, title, text, timeout=10, icon=win32gui.NIIF_NONE):
|
||||||
|
@ -192,12 +199,18 @@ class NotifyIcon:
|
||||||
self._info = text
|
self._info = text
|
||||||
self._timeout = timeout * 1000
|
self._timeout = timeout * 1000
|
||||||
self._infoflags = icon
|
self._infoflags = icon
|
||||||
|
try:
|
||||||
win32gui.Shell_NotifyIcon(win32gui.NIM_MODIFY, self._get_nid())
|
win32gui.Shell_NotifyIcon(win32gui.NIM_MODIFY, self._get_nid())
|
||||||
|
except pywintypes.error:
|
||||||
|
pass
|
||||||
|
|
||||||
def _redraw(self, *args):
|
def _redraw(self, *args):
|
||||||
""" Redraws the tray icon. """
|
""" Redraws the tray icon. """
|
||||||
self.remove()
|
self.remove()
|
||||||
|
try:
|
||||||
win32gui.Shell_NotifyIcon(win32gui.NIM_ADD, self._get_nid())
|
win32gui.Shell_NotifyIcon(win32gui.NIM_ADD, self._get_nid())
|
||||||
|
except pywintypes.error:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SystrayWin32(systray.Systray):
|
class SystrayWin32(systray.Systray):
|
||||||
|
|
Loading…
Reference in New Issue