本文整理汇总了Python中PyQt4.QtGui.QTabBar.setTabIcon方法的典型用法代码示例。如果您正苦于以下问题:Python QTabBar.setTabIcon方法的具体用法?Python QTabBar.setTabIcon怎么用?Python QTabBar.setTabIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QTabBar
的用法示例。
在下文中一共展示了QTabBar.setTabIcon方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: E4SideBar
# 需要导入模块: from PyQt4.QtGui import QTabBar [as 别名]
# 或者: from PyQt4.QtGui.QTabBar import setTabIcon [as 别名]
#.........这里部分代码省略.........
self.__tabBar.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
self.barLayout.setDirection(QBoxLayout.LeftToRight)
self.layout.setDirection(QBoxLayout.TopToBottom)
self.layout.setAlignment(self.barLayout, Qt.AlignLeft)
elif orient == E4SideBar.East:
self.__tabBar.setShape(QTabBar.RoundedEast)
self.__tabBar.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
self.barLayout.setDirection(QBoxLayout.TopToBottom)
self.layout.setDirection(QBoxLayout.RightToLeft)
self.layout.setAlignment(self.barLayout, Qt.AlignTop)
elif orient == E4SideBar.South:
self.__tabBar.setShape(QTabBar.RoundedSouth)
self.__tabBar.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
self.barLayout.setDirection(QBoxLayout.LeftToRight)
self.layout.setDirection(QBoxLayout.BottomToTop)
self.layout.setAlignment(self.barLayout, Qt.AlignLeft)
elif orient == E4SideBar.West:
self.__tabBar.setShape(QTabBar.RoundedWest)
self.__tabBar.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
self.barLayout.setDirection(QBoxLayout.TopToBottom)
self.layout.setDirection(QBoxLayout.LeftToRight)
self.layout.setAlignment(self.barLayout, Qt.AlignTop)
self.__orientation = orient
def tabIcon(self, index):
"""
Public method to get the icon of a tab.
@param index index of the tab (integer)
@return icon of the tab (QIcon)
"""
return self.__tabBar.tabIcon(index)
def setTabIcon(self, index, icon):
"""
Public method to set the icon of a tab.
@param index index of the tab (integer)
@param icon icon to be set (QIcon)
"""
self.__tabBar.setTabIcon(index, icon)
def tabText(self, index):
"""
Public method to get the text of a tab.
@param index index of the tab (integer)
@return text of the tab (QString)
"""
return self.__tabBar.tabText(index)
def setTabText(self, index, text):
"""
Public method to set the text of a tab.
@param index index of the tab (integer)
@param text text to set (QString)
"""
self.__tabBar.setTabText(index, text)
def tabToolTip(self, index):
"""
Public method to get the tooltip text of a tab.
@param index index of the tab (integer)
@return tooltip text of the tab (QString)
示例2: MainWindow
# 需要导入模块: from PyQt4.QtGui import QTabBar [as 别名]
# 或者: from PyQt4.QtGui.QTabBar import setTabIcon [as 别名]
#.........这里部分代码省略.........
button = self.columnsVisibilityButton
menu.popup(button.parentWidget().mapToGlobal(button.geometry().topLeft()))
def columnsMenuItemWasClicked(self):
action = self.sender()
if action is not None:
index = action.data()
self.model.toggle_column_menu_item(index)
def checkForUpdateTriggered(self):
QProcess.execute('updater.exe', ['/checknow'])
def aboutTriggered(self):
self.app.showAboutBox()
def openDebugLogTriggered(self):
debugLogPath = op.join(getAppData(), 'debug.log')
url = QUrl.fromLocalFile(debugLogPath)
QDesktopServices.openUrl(url)
#--- Other Signals
def currentTabChanged(self, index):
self.model.current_pane_index = index
self._setTabIndex(index)
def documentPathChanged(self):
if self.doc.documentPath:
title = "moneyGuru ({})".format(self.doc.documentPath)
else:
title = "moneyGuru"
self.setWindowTitle(title)
def tabCloseRequested(self, index):
self.model.close_pane(index)
def tabMoved(self, fromIndex, toIndex):
self.model.move_pane(fromIndex, toIndex)
#--- model --> view
def change_current_pane(self):
self._setTabIndex(self.model.current_pane_index)
def refresh_panes(self):
while self.tabBar.count() < self.model.pane_count:
self.tabBar.addTab('')
for i in range(self.model.pane_count):
pane_label = self.model.pane_label(i)
pane_label = escapeamp(pane_label)
self.tabBar.setTabText(i, pane_label)
pane_type = self.model.pane_type(i)
pane_view = self.model.pane_view(i)
# Ensure that the view's "view" has been created and bound
self._getViewforPane(pane_type, pane_view)
iconname = PANETYPE2ICON.get(pane_type)
icon = QIcon(QPixmap(':/{0}'.format(iconname))) if iconname else QIcon()
self.tabBar.setTabIcon(i, icon)
# It's important that we proceed with tab removal *after* we've completed tab initialization.
# We're walking on eggshells here. refresh_panes() can be called in multiple situations, one
# of them is during the opening of a document. When that happens when another document was
# previously opened, all views' model are uninitalized and don't have their "view" attribute
# set yet. If we proceed with the setCurrentIndex() call below before _getViewforPane()
# could be called above, we get a crash.
if self.tabBar.currentIndex() < self.model.pane_count:
# Normally, we don't touch the tabBar index here and wait for change_current_pane,
# but when we remove tabs, it's possible that currentTabChanged end up being called and
# then the tab selection is bugged. I tried disconnecting/reconnecting the signal, but
# this is buggy. So when a selected tab is about to be removed, we change the selection
# to the model's one immediately.
self.tabBar.setCurrentIndex(self.model.current_pane_index)
while self.tabBar.count() > self.model.pane_count:
self.tabBar.removeTab(self.tabBar.count()-1)
self.tabBar.setTabsClosable(self.model.pane_count > 1)
def refresh_status_line(self):
self.statusLabel.setText(self.model.status_line)
def refresh_undo_actions(self):
self._updateUndoActions()
def restore_window_frame(self, frame):
self.setGeometry(*frame)
def save_window_frame(self):
r = self.geometry()
return (r.x(), r.y(), r.width(), r.height())
def show_message(self, msg):
title = tr("Warning")
QMessageBox.warning(self, title, msg)
def update_area_visibility(self):
hidden = self.model.hidden_areas
graphimg = ':/graph_visibility_{}_16'.format('off' if PaneArea.BottomGraph in hidden else 'on')
pieimg = ':/piechart_visibility_{}_16'.format('off' if PaneArea.RightChart in hidden else 'on')
self.graphVisibilityButton.setIcon(QIcon(QPixmap(graphimg)))
self.piechartVisibilityButton.setIcon(QIcon(QPixmap(pieimg)))
def view_closed(self, index):
self.tabBar.removeTab(index)
self.tabBar.setTabsClosable(self.model.pane_count > 1)
示例3: SideBar
# 需要导入模块: from PyQt4.QtGui import QTabBar [as 别名]
# 或者: from PyQt4.QtGui.QTabBar import setTabIcon [as 别名]
#.........这里部分代码省略.........
self.expand()
return
def indexOf( self, widget ):
""" Provides the index of the given widget """
return self.__stackedWidget.indexOf( widget )
def isTabEnabled( self, index ):
""" Check if the tab is enabled """
return self.__tabBar.isTabEnabled( index )
def setTabEnabled( self, index, enabled ):
""" Set the enabled state of the tab """
self.__tabBar.setTabEnabled( index, enabled )
return
def orientation( self ):
""" Provides the orientation of the sidebar """
return self.__orientation
def setOrientation( self, orient ):
""" Set the orientation of the sidebar """
if orient == SideBar.North:
self.__tabBar.setShape( QTabBar.RoundedNorth )
self.barLayout.setDirection( QBoxLayout.LeftToRight )
self.layout.setDirection( QBoxLayout.TopToBottom )
self.layout.setAlignment( self.barLayout, Qt.AlignLeft )
elif orient == SideBar.East:
self.__tabBar.setShape( QTabBar.RoundedEast )
self.barLayout.setDirection( QBoxLayout.TopToBottom )
self.layout.setDirection( QBoxLayout.RightToLeft )
self.layout.setAlignment( self.barLayout, Qt.AlignTop )
elif orient == SideBar.South:
self.__tabBar.setShape( QTabBar.RoundedSouth )
self.barLayout.setDirection( QBoxLayout.LeftToRight )
self.layout.setDirection( QBoxLayout.BottomToTop )
self.layout.setAlignment( self.barLayout, Qt.AlignLeft )
else:
# default
orient = SideBar.West
self.__tabBar.setShape( QTabBar.RoundedWest )
self.barLayout.setDirection( QBoxLayout.TopToBottom )
self.layout.setDirection( QBoxLayout.LeftToRight )
self.layout.setAlignment( self.barLayout, Qt.AlignTop )
self.__orientation = orient
return
def tabIcon( self, index ):
""" Provide the icon of the tab """
return self.__tabBar.tabIcon( index )
def setTabIcon( self, index, icon ):
""" Set the icon of the tab """
self.__tabBar.setTabIcon( index, icon )
return
def tabText( self, index ):
""" Provide the text of the tab """
return self.__tabBar.tabText( index )
def setTabText( self, index, text ):
""" Set the text of the tab """
self.__tabBar.setTabText( index, text )
return
def tabToolTip( self, index ):
""" Provide the tooltip text of the tab """
return self.__tabBar.tabToolTip( index )
def setTabToolTip( self, index, tip ):
""" Set the tooltip text of the tab """
self.__tabBar.setTabToolTip( index, tip )
return
def tabWhatsThis( self, index ):
""" Provide the WhatsThis text of the tab """
return self.__tabBar.tabWhatsThis( index )
def setTabWhatsThis( self, index, text ):
""" Set the WhatsThis text for the tab """
self.__tabBar.setTabWhatsThis( index, text )
return
def widget( self, index ):
""" Provides the reference to the widget (QWidget) """
return self.__stackedWidget.widget( index )