提交 204da6fd 编写于 作者: K Kentaro Wada

Centerize icons

上级 5c980844
......@@ -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)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册