当前位置: 首页>>代码示例>>Python>>正文


Python Label.setCaption方法代码示例

本文整理汇总了Python中label.Label.setCaption方法的典型用法代码示例。如果您正苦于以下问题:Python Label.setCaption方法的具体用法?Python Label.setCaption怎么用?Python Label.setCaption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在label.Label的用法示例。


在下文中一共展示了Label.setCaption方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Tab

# 需要导入模块: from label import Label [as 别名]
# 或者: from label.Label import setCaption [as 别名]
class Tab(BasicContainer,MouseListener):
    def __init__(self,caption=""):
        BasicContainer.__init__(self)
        self.mHasMouse=False
        self.mTabbedArea=None
        self.mLabel=Label()
        self.mLabel.setPosition(4,4)
        self.setCaption(caption)
        self.add(self.mLabel)
        
        self.addMouseListener(self)
        self.addFocusListener(self)
        
    def adjustSize(self):
        self.setSize(self.mLabel.getWidth()+8, self.mLabel.getHeight()+8)
        
        if self.mTabbedArea != None:
            self.mTabbedArea.adjustTabPositions()
            
        self.addDirtyRect()
            
    def setTabbedArea(self,tabbedArea):
        self.mTabbedArea=tabbedArea
        
    def getTabbedArea(self):
        return self.mTabbedArea
    
    def setCaption(self,caption):
        self.mLabel.setCaption(caption)
        self.mLabel.adjustSize()
        self.adjustSize()
        
    def getCaption(self):
        return self.mLabel.getCaption()
    
    def draw(self,graphics):
        faceColor = self.getBaseColor()
        alpha=faceColor.a
        highlightColor=faceColor+0x303030
        highlightColor.a=alpha
        shadowColor=faceColor-0x303030
        shadowColor.a=alpha
        
        borderColor, baseColor = None, None
        
        if (self.mTabbedArea != None and self.mTabbedArea.isTabSelected(self) == True) or self.mHasMouse:
            #Draw a border.
            graphics.setColor(highlightColor)
            graphics.drawLine(0, 0, self.getWidth()-1, 0)
            graphics.drawLine(0, 1, 0, self.getHeight()-1)
            
            graphics.setColor(shadowColor)
            graphics.drawLine(self.getWidth()-1, 1, self.getWidth()-1, self.getHeight()-1)
            
            borderColor=Color(highlightColor)
            baseColor=Color(self.getBaseColor())
        else:
            #draw a border
            graphics.setColor(shadowColor)
            graphics.drawLine(0, 0, self.getWidth()-1, 0)
            graphics.drawLine(0, 1, 0, self.getHeight()-1)
            graphics.drawLine(self.getWidth()-1, 1, self.getWidth()-1, self.getHeight()-1)
            
            baseColor=self.getBaseColor() - 0x151515
            baseColor.a=alpha
            
        #Push a clip area so the other drawings don't need to worry
        #about the border.
        graphics.pushClipArea( Rectangle(1, 1, self.getWidth() - 2, self.getHeight() - 1) )
        currentClipArea=Rectangle( graphics.getCurrentClipArea() )
        
        graphics.setColor(baseColor)
        graphics.fillRectangle( Rectangle(0,0,self.getWidth(), self.getHeight()) )
        
        self.drawChildren(graphics)
        
        if self.mTabbedArea != None and self.mTabbedArea.isFocused() == True and self.mTabbedArea.isTabSelected(self) == True:
            graphics.setColor( self.getForegroundColor() )
            graphics.drawRectangle( Rectangle(2,2,currentClipArea.width-4,currentClipArea.height-4) )
            
        graphics.popClipArea()
        
    def mouseEntered(self,mouseEvent):
        self.mHasMouse=True
        self.addDirtyRect()
        
    def mouseExited(self,mouseEvent):
        self.mHasMouse=False
        self.addDirtyRect()
开发者ID:rolph-recto,项目名称:Guichan,代码行数:91,代码来源:tab.py


注:本文中的label.Label.setCaption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。