# -*- coding: utf-8 -*-  

from PyQt4.QtCore import QRect
from PyQt4.QtGui  import QBrush
from PyQt4.QtGui  import QColor
from PyQt4.QtGui  import QPainter
from PyQt4.QtGui  import QLinearGradient
from PyQt4.QtGui  import QTabBar
from PyQt4.QtGui import QFont
from PyQt4.QtGui import QTabWidget


class TabBar(QTabBar):
       
    def __init__(self,parent = None):
        super(TabBar,self).__init__(parent)
        self.setMouseTracking(True)
        self.setFont(QFont("wenquanyi", 10))
        
        
class TabWidget(QTabWidget):
       
    def __init__(self,parent = None):
        super(TabWidget,self).__init__(parent)
        
  
        self.setTabBar(TabBar(self))
   
    def paintEvent(self,event):
        painter = QPainter(self)
        linearGradient = QLinearGradient(0, 0,0,30)
        linearGradient.setColorAt(0, QColor(80,150,255))
        linearGradient.setColorAt(0.1, QColor(6,88,200))
        linearGradient.setColorAt(1, QColor(60,150,255))
        painter.setBrush(QBrush(linearGradient))
        self.menuRect = QRect(0, 0, self.frameGeometry().width(), self.tabBar().height() - 1)#菜单矩形
#         painter.fillRect(self.menuRect, QBrush(linearGradient))#填充
        
       
        painter2 = QPainter(self)#画
        brush2 = QBrush(QColor(255,255,255))#笔刷
        painter2.setBrush(brush2)#为画定义笔刷
        self.contenRect2 = QRect(0,self.tabBar().height(),self.frameGeometry().width(),self.frameGeometry().height())
        painter2.fillRect(self.contenRect2, brush2)
        painter.fillRect(self.menuRect, brush2)#填充
    
    
    
    
    
    
    
    
    
    
    




