本文整理汇总了Python中PyQt4.QtGui.QTabBar.setUsesScrollButtons方法的典型用法代码示例。如果您正苦于以下问题:Python QTabBar.setUsesScrollButtons方法的具体用法?Python QTabBar.setUsesScrollButtons怎么用?Python QTabBar.setUsesScrollButtons使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QTabBar
的用法示例。
在下文中一共展示了QTabBar.setUsesScrollButtons方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: E4SideBar
# 需要导入模块: from PyQt4.QtGui import QTabBar [as 别名]
# 或者: from PyQt4.QtGui.QTabBar import setUsesScrollButtons [as 别名]
class E4SideBar(QWidget):
"""
Class implementing a sidebar with a widget area, that is hidden or shown, if the
current tab is clicked again.
"""
Version = 1
North = 0
East = 1
South = 2
West = 3
def __init__(self, orientation = None, delay = 200, parent = None):
"""
Constructor
@param orientation orientation of the sidebar widget (North, East, South, West)
@param delay value for the expand/shrink delay in milliseconds (integer)
@param parent parent widget (QWidget)
"""
QWidget.__init__(self, parent)
self.__tabBar = QTabBar()
self.__tabBar.setDrawBase(True)
self.__tabBar.setShape(QTabBar.RoundedNorth)
self.__tabBar.setUsesScrollButtons(True)
self.__tabBar.setDrawBase(False)
self.__stackedWidget = QStackedWidget(self)
self.__stackedWidget.setContentsMargins(0, 0, 0, 0)
self.__autoHideButton = QToolButton()
self.__autoHideButton.setCheckable(True)
self.__autoHideButton.setIcon(UI.PixmapCache.getIcon("autoHideOff.png"))
self.__autoHideButton.setChecked(True)
self.__autoHideButton.setToolTip(
self.trUtf8("Deselect to activate automatic collapsing"))
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.__autoHideButton)
self.barLayout.addWidget(self.__tabBar)
self.layout.addLayout(self.barLayout)
self.layout.addWidget(self.__stackedWidget)
self.setLayout(self.layout)
# initialize the delay timer
self.__actionMethod = None
self.__delayTimer = QTimer(self)
self.__delayTimer.setSingleShot(True)
self.__delayTimer.setInterval(delay)
self.connect(self.__delayTimer, SIGNAL("timeout()"), self.__delayedAction)
self.__minimized = False
self.__minSize = 0
self.__maxSize = 0
self.__bigSize = QSize()
self.splitter = None
self.splitterSizes = []
self.__hasFocus = False # flag storing if this widget or any child has the focus
self.__autoHide = False
self.__tabBar.installEventFilter(self)
self.__orientation = E4SideBar.North
if orientation is None:
orientation = E4SideBar.North
self.setOrientation(orientation)
self.connect(self.__tabBar, SIGNAL("currentChanged(int)"),
self.__stackedWidget, SLOT("setCurrentIndex(int)"))
self.connect(e4App(), SIGNAL("focusChanged(QWidget*, QWidget*)"),
self.__appFocusChanged)
self.connect(self.__autoHideButton, SIGNAL("toggled(bool)"),
self.__autoHideToggled)
def setSplitter(self, splitter):
"""
Public method to set the splitter managing the sidebar.
@param splitter reference to the splitter (QSplitter)
"""
self.splitter = splitter
self.connect(self.splitter, SIGNAL("splitterMoved(int, int)"),
self.__splitterMoved)
self.splitter.setChildrenCollapsible(False)
index = self.splitter.indexOf(self)
self.splitter.setCollapsible(index, False)
def __splitterMoved(self, pos, index):
"""
Private slot to react on splitter moves.
@param pos new position of the splitter handle (integer)
@param index index of the splitter handle (integer)
"""
if self.splitter:
self.splitterSizes = self.splitter.sizes()
#.........这里部分代码省略.........
示例2: ImportWindow
# 需要导入模块: from PyQt4.QtGui import QTabBar [as 别名]
# 或者: from PyQt4.QtGui.QTabBar import setUsesScrollButtons [as 别名]
class ImportWindow(QWidget):
def __init__(self, parent, doc):
QWidget.__init__(self, parent, Qt.Window)
self._setupUi()
self.doc = doc
self.model = ImportWindowModel(document=doc.model)
self.swapOptionsComboBox = ComboboxModel(model=self.model.swap_type_list, view=self.swapOptionsComboBoxView)
self.table = ImportTable(model=self.model.import_table, view=self.tableView)
self.model.view = self
self._setupColumns() # Can only be done after the model has been connected
self.tabView.tabCloseRequested.connect(self.tabCloseRequested)
self.tabView.currentChanged.connect(self.currentTabChanged)
self.targetAccountComboBox.currentIndexChanged.connect(self.targetAccountChanged)
self.importButton.clicked.connect(self.importClicked)
self.swapButton.clicked.connect(self.swapClicked)
def _setupUi(self):
self.setWindowTitle(tr("Import"))
self.resize(557, 407)
self.verticalLayout = QtGui.QVBoxLayout(self)
self.tabView = QTabBar(self)
self.tabView.setMinimumSize(QtCore.QSize(0, 20))
self.verticalLayout.addWidget(self.tabView)
self.targetAccountLayout = QtGui.QHBoxLayout()
self.targetAccountLabel = QtGui.QLabel(tr("Target Account:"))
self.targetAccountLayout.addWidget(self.targetAccountLabel)
self.targetAccountComboBox = QComboBox(self)
self.targetAccountComboBox.setMinimumSize(QtCore.QSize(150, 0))
self.targetAccountLayout.addWidget(self.targetAccountComboBox)
spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.targetAccountLayout.addItem(spacerItem)
self.groupBox = QGroupBox(tr("Are some fields wrong? Fix them!"))
self.gridLayout = QtGui.QGridLayout(self.groupBox)
self.swapOptionsComboBoxView = QComboBox(self.groupBox)
self.gridLayout.addWidget(self.swapOptionsComboBoxView, 0, 0, 1, 2)
self.applyToAllCheckBox = QtGui.QCheckBox(tr("Apply to all accounts"))
self.gridLayout.addWidget(self.applyToAllCheckBox, 1, 0, 1, 1)
self.swapButton = QPushButton(tr("Fix"))
self.gridLayout.addWidget(self.swapButton, 1, 1, 1, 1)
self.targetAccountLayout.addWidget(self.groupBox)
self.verticalLayout.addLayout(self.targetAccountLayout)
self.tableView = TableView(self)
self.tableView.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
self.tableView.setDragEnabled(True)
self.tableView.setDragDropMode(QtGui.QAbstractItemView.InternalMove)
self.tableView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
self.tableView.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
self.tableView.horizontalHeader().setHighlightSections(False)
self.tableView.horizontalHeader().setMinimumSectionSize(18)
self.tableView.verticalHeader().setVisible(False)
self.tableView.verticalHeader().setDefaultSectionSize(18)
self.verticalLayout.addWidget(self.tableView)
self.horizontalLayout = QtGui.QHBoxLayout()
spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem1)
self.importButton = QPushButton(tr("Import"))
self.horizontalLayout.addWidget(self.importButton)
self.verticalLayout.addLayout(self.horizontalLayout)
self.tabView.setTabsClosable(True)
self.tabView.setDrawBase(False)
self.tabView.setDocumentMode(True)
self.tabView.setUsesScrollButtons(True)
def _setupColumns(self):
# Can't set widget alignment in a layout in the Designer
l = self.targetAccountLayout
l.setAlignment(self.targetAccountLabel, Qt.AlignTop)
l.setAlignment(self.targetAccountComboBox, Qt.AlignTop)
#--- Event Handlers
def currentTabChanged(self, index):
self.model.selected_pane_index = index
def importClicked(self):
self.model.import_selected_pane()
def swapClicked(self):
applyToAll = self.applyToAllCheckBox.isChecked()
self.model.perform_swap(applyToAll)
def tabCloseRequested(self, index):
self.model.close_pane(index)
self.tabView.removeTab(index)
def targetAccountChanged(self, index):
self.model.selected_target_account_index = index
self.table.updateColumnsVisibility()
#--- model --> view
def close(self):
self.hide()
def close_selected_tab(self):
self.tabView.removeTab(self.tabView.currentIndex())
def refresh_target_accounts(self):
# We disconnect the combobox because we don't want the clear() call to set the selected
# target index in the model.
self.targetAccountComboBox.currentIndexChanged.disconnect(self.targetAccountChanged)
#.........这里部分代码省略.........
示例3: SideBar
# 需要导入模块: from PyQt4.QtGui import QTabBar [as 别名]
# 或者: from PyQt4.QtGui.QTabBar import setUsesScrollButtons [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
#.........这里部分代码省略.........