2021-03-25 05:01:12 +13:00
|
|
|
from PyQt5.QtCore import QSize
|
|
|
|
from PyQt5.QtGui import QFont
|
2021-04-09 07:00:18 +12:00
|
|
|
from PyQt5.QtWidgets import QTabBar, QToolButton
|
2021-03-25 05:01:12 +13:00
|
|
|
from qtawesome import icon
|
|
|
|
|
|
|
|
|
|
|
|
class TabBar(QTabBar):
|
|
|
|
def __init__(self, expanded):
|
|
|
|
super(TabBar, self).__init__()
|
|
|
|
self._expanded = expanded
|
|
|
|
self.setObjectName("main_tab_bar")
|
|
|
|
self.setFont(QFont("Arial", 13))
|
|
|
|
# self.setContentsMargins(0,10,0,10)
|
|
|
|
|
|
|
|
def tabSizeHint(self, index):
|
|
|
|
size = super(TabBar, self).tabSizeHint(index)
|
|
|
|
if index == self._expanded:
|
|
|
|
offset = self.width()
|
|
|
|
for index in range(self.count()):
|
|
|
|
offset -= super(TabBar, self).tabSizeHint(index).width()
|
|
|
|
size.setWidth(max(size.width(), size.width() + offset))
|
|
|
|
return size
|
|
|
|
|
|
|
|
|
|
|
|
class TabButtonWidget(QToolButton):
|
2021-04-09 07:00:18 +12:00
|
|
|
def __init__(self, core, button_icon: str, tool_tip: str):
|
2021-03-25 05:01:12 +13:00
|
|
|
super(TabButtonWidget, self).__init__()
|
|
|
|
self.setText("Icon")
|
|
|
|
self.setPopupMode(QToolButton.InstantPopup)
|
2021-08-29 06:03:25 +12:00
|
|
|
self.setIcon(icon(button_icon, scale_factor=1.25))
|
2021-04-09 07:00:18 +12:00
|
|
|
self.setToolTip(tool_tip)
|
2021-03-25 05:01:12 +13:00
|
|
|
self.setIconSize(QSize(25, 25))
|