本文整理汇总了Python中PyQt4.QtGui.QTabBar.setFocusPolicy方法的典型用法代码示例。如果您正苦于以下问题:Python QTabBar.setFocusPolicy方法的具体用法?Python QTabBar.setFocusPolicy怎么用?Python QTabBar.setFocusPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QTabBar
的用法示例。
在下文中一共展示了QTabBar.setFocusPolicy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addWidgets
# 需要导入模块: from PyQt4.QtGui import QTabBar [as 别名]
# 或者: from PyQt4.QtGui.QTabBar import setFocusPolicy [as 别名]
def addWidgets(self):
"""Create main layout."""
logger = self.logger
logger.debug('adding widgets')
layout = QVBoxLayout()
self.setLayout(layout)
layout.setSpacing(0)
layout.setContentsMargins(0, 0, 0, 0)
tabbar = QTabBar(self)
tabbar.setFocusPolicy(Qt.NoFocus)
tabbar.setVisible(False)
tabbar.currentChanged.connect(self.changeVault)
layout.addWidget(tabbar)
self.tabbar = tabbar
stack = QStackedWidget(self)
layout.addWidget(stack)
novault = NoVaultWidget(stack)
stack.addWidget(novault)
self.stack = stack
示例2: SideBar
# 需要导入模块: from PyQt4.QtGui import QTabBar [as 别名]
# 或者: from PyQt4.QtGui.QTabBar import setFocusPolicy [as 别名]
class SideBar( QWidget ):
""" Sidebar with a widget area which is hidden or shown.
On by clicking any tab, off by clicking the current tab.
"""
North = 0
East = 1
South = 2
West = 3
def __init__( self, orientation = 2, parent = None ):
QWidget.__init__( self, parent )
self.__tabBar = QTabBar()
self.__tabBar.setDrawBase( True )
self.__tabBar.setShape( QTabBar.RoundedNorth )
self.__tabBar.setFocusPolicy( Qt.NoFocus )
self.__tabBar.setUsesScrollButtons( True )
self.__tabBar.setElideMode( 1 )
self.__stackedWidget = QStackedWidget( self )
self.__stackedWidget.setContentsMargins( 0, 0, 0, 0 )
self.barLayout = QBoxLayout( QBoxLayout.LeftToRight )
self.barLayout.setMargin( 0 )
self.layout = QBoxLayout( QBoxLayout.TopToBottom )
self.layout.setMargin( 0 )
self.layout.setSpacing( 0 )
self.barLayout.addWidget( self.__tabBar )
self.layout.addLayout( self.barLayout )
self.layout.addWidget( self.__stackedWidget )
self.setLayout( self.layout )
self.__minimized = False
self.__minSize = 0
self.__maxSize = 0
self.__bigSize = QSize()
self.splitter = None
self.__tabBar.installEventFilter( self )
self.__orientation = orientation
self.setOrientation( orientation )
self.__tabBar.currentChanged.connect(
self.__stackedWidget.setCurrentIndex )
return
def setSplitter( self, splitter ):
""" Set the splitter managing the sidebar """
self.splitter = splitter
return
def __getIndex( self ):
" Provides the widget index in splitters "
if self.__orientation == SideBar.West:
return 0
if self.__orientation == SideBar.East:
return 2
if self.__orientation == SideBar.South:
return 1
return 0
def __getWidget( self ):
" Provides a reference to the widget "
return self.splitter.widget( self.__getIndex() )
def shrink( self ):
""" Shrink the sidebar """
if self.__minimized:
return
self.__minimized = True
self.__bigSize = self.size()
if self.__orientation in [ SideBar.North, SideBar.South ]:
self.__minSize = self.minimumHeight()
self.__maxSize = self.maximumHeight()
else:
self.__minSize = self.minimumWidth()
self.__maxSize = self.maximumWidth()
self.__stackedWidget.hide()
sizes = self.splitter.sizes()
selfIndex = self.__getIndex()
if self.__orientation in [ SideBar.North, SideBar.South ]:
newHeight = self.__tabBar.minimumSizeHint().height()
self.setFixedHeight( newHeight )
diff = sizes[ selfIndex ] - newHeight
sizes[ selfIndex ] = newHeight
else:
newWidth = self.__tabBar.minimumSizeHint().width()
self.setFixedWidth( newWidth )
diff = sizes[ selfIndex ] - newWidth
sizes[ selfIndex ] = newWidth
if selfIndex == 0:
sizes[ 1 ] += diff
#.........这里部分代码省略.........