Handle non existing icon

main
Micke Nordin 4 years ago
parent d82b3d254e
commit 2cc964aa07

@ -68,11 +68,15 @@ class SwaySwitch(wx.Frame): # pylint: disable=no-member
size = wx.Window.GetFont(self).GetPointSize() * label_len # pylint: disable=no-member size = wx.Window.GetFont(self).GetPointSize() * label_len # pylint: disable=no-member
command = get_command(window['pid']) command = get_command(window['pid'])
desktop_file = self.get_desktop_file(command) desktop_file = self.get_desktop_file(command)
unscaled_bitmap = wx.Bitmap(self.get_icon(desktop_file)) # pylint: disable=no-member icon = self.get_icon(desktop_file) # pylint: disable=no-member
image = unscaled_bitmap.ConvertToImage() if icon:
image = image.Scale(self.icon_size, self.icon_size, unscaled_bitmap = wx.Bitmap(self.get_icon(desktop_file)) # pylint: disable=no-member
wx.IMAGE_QUALITY_HIGH) # pylint: disable=no-member image = unscaled_bitmap.ConvertToImage()
bitmap = wx.Bitmap(image) # pylint: disable=no-member image = image.Scale(self.icon_size, self.icon_size,
wx.IMAGE_QUALITY_HIGH) # pylint: disable=no-member
bitmap = wx.Bitmap(image) # pylint: disable=no-member
else:
bitmap = wx.Bitmap()
btn = wx.BitmapButton( # pylint: disable=no-member btn = wx.BitmapButton( # pylint: disable=no-member
self.pnl, self.pnl,
id=winid, id=winid,
@ -149,7 +153,10 @@ class SwaySwitch(wx.Frame): # pylint: disable=no-member
icon = pos_icon icon = pos_icon
break break
if not icon: if not icon:
icon = sorted(possible_icons)[0] try:
icon = sorted(possible_icons)[0]
except IndexError:
icon = ""
return icon return icon
def on_key_press(self, event): def on_key_press(self, event):

Loading…
Cancel
Save