Skip to content

Commit

Permalink
rescale icon before setting it for a Button
Browse files Browse the repository at this point in the history
  • Loading branch information
jborbely committed May 16, 2020
1 parent 7fbe008 commit 81bd680
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions msl/qt/widgets/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,15 @@ def _create_menu(self):
self.setPopupMode(QtWidgets.QToolButton.MenuButtonPopup)

def _set_icon(self, icon, icon_size):
icon = io.get_icon(icon)
self.setIcon(icon)
if icon_size is not None:
pixmap = io.rescale_icon(icon, icon_size)
self.setIconSize(pixmap.size())
icon = io.rescale_icon(icon, icon_size)
self.setIconSize(icon.size())
elif icon.availableSizes():
available = icon.availableSizes()[-1]
if self.iconSize().width() < available.width() or \
self.iconSize().height() < available.height():
self.setIconSize(available)
self.setIcon(io.get_icon(icon))


class ButtonMenu(QtWidgets.QMenu):
Expand Down

0 comments on commit 81bd680

Please sign in to comment.