36 lines
980 B
Python
36 lines
980 B
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
Created on 2018年12月27日
|
|
@author: Irony
|
|
@site: https://pyqt5.com https://github.com/892768447
|
|
@email: 892768447@qq.com
|
|
@file: TabBarStyle
|
|
@description:
|
|
"""
|
|
from PyQt5.QtCore import Qt
|
|
from PyQt5.QtWidgets import QProxyStyle
|
|
|
|
|
|
__Author__ = """By: Irony
|
|
QQ: 892768447
|
|
Email: 892768447@qq.com"""
|
|
__Copyright__ = "Copyright (c) 2018 Irony"
|
|
__Version__ = "Version 1.0"
|
|
|
|
|
|
class TabBarStyle(QProxyStyle):
|
|
|
|
def sizeFromContents(self, types, option, size, widget):
|
|
size = super(TabBarStyle, self).sizeFromContents(
|
|
types, option, size, widget)
|
|
if types == self.CT_TabBarTab:
|
|
size.transpose()
|
|
return size
|
|
|
|
def drawControl(self, element, option, painter, widget):
|
|
if element == self.CE_TabBarTabLabel:
|
|
painter.drawText(option.rect, Qt.AlignCenter, option.text)
|
|
return
|
|
super(TabBarStyle, self).drawControl(element, option, painter, widget)
|