From 204da6fd10bb2fb637c581a35bc3c6ed75727e04 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sun, 14 Jun 2020 11:20:44 +0100 Subject: [PATCH] Centerize icons --- labelme/widgets/tool_bar.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/labelme/widgets/tool_bar.py b/labelme/widgets/tool_bar.py index 965c8f7..d5dcefc 100644 --- a/labelme/widgets/tool_bar.py +++ b/labelme/widgets/tool_bar.py @@ -15,21 +15,14 @@ class ToolBar(QtWidgets.QToolBar): def addAction(self, action): if isinstance(action, QtWidgets.QWidgetAction): return super(ToolBar, self).addAction(action) - btn = ToolButton() + btn = QtWidgets.QToolButton() btn.setDefaultAction(action) btn.setToolButtonStyle(self.toolButtonStyle()) self.addWidget(btn) - -class ToolButton(QtWidgets.QToolButton): - - """ToolBar companion class which ensures all buttons have the same size.""" - - minSize = (60, 60) - - def minimumSizeHint(self): - ms = super(ToolButton, self).minimumSizeHint() - w1, h1 = ms.width(), ms.height() - w2, h2 = self.minSize - self.minSize = max(w1, w2), max(h1, h2) - return QtCore.QSize(*self.minSize) + # center align + for i in range(self.layout().count()): + if isinstance( + self.layout().itemAt(i).widget(), QtWidgets.QToolButton + ): + self.layout().itemAt(i).setAlignment(QtCore.Qt.AlignCenter) -- GitLab