tab_view ======== .. py:module:: qfluentwidgets.components.widgets.tab_view Module Contents --------------- .. autoapisummary:: qfluentwidgets.components.widgets.tab_view.TabCloseButtonDisplayMode qfluentwidgets.components.widgets.tab_view.TabToolButton qfluentwidgets.components.widgets.tab_view.TabItem qfluentwidgets.components.widgets.tab_view.TabBar qfluentwidgets.components.widgets.tab_view.TabWidget .. autoapisummary:: qfluentwidgets.components.widgets.tab_view.checkIndex .. py:class:: TabCloseButtonDisplayMode Bases: :py:obj:`enum.Enum` Tab close button display mode .. py:attribute:: ALWAYS :value: 0 .. py:attribute:: ON_HOVER :value: 1 .. py:attribute:: NEVER :value: 2 .. py:function:: checkIndex(*default) decorator for index checking Parameters ---------- *default: the default value returned when an index overflow .. py:class:: TabToolButton(parent: PyQt5.QtWidgets.QWidget = None) Bases: :py:obj:`qfluentwidgets.components.widgets.button.TransparentToolButton` Tab tool button .. py:class:: TabItem(parent: PyQt5.QtWidgets.QWidget = None) Bases: :py:obj:`qfluentwidgets.components.widgets.button.PushButton` Tab item .. py:attribute:: closed .. py:attribute:: doubleClicked .. py:method:: slideTo(x: int, duration=250) .. py:method:: setShadowEnabled(isEnabled: bool) set whether the shadow is enabled .. py:method:: setRouteKey(key: str) .. py:method:: routeKey() .. py:method:: setBorderRadius(radius: int) .. py:method:: setSelected(isSelected: bool) .. py:method:: setCloseButtonDisplayMode(mode: TabCloseButtonDisplayMode) set close button display mode .. py:method:: setTextColor(color: PyQt5.QtGui.QColor) .. py:method:: setSelectedBackgroundColor(light: PyQt5.QtGui.QColor, dark: PyQt5.QtGui.QColor) set background color in selected state .. py:method:: resizeEvent(e) .. py:method:: enterEvent(e) .. py:method:: leaveEvent(e) .. py:method:: mousePressEvent(e) .. py:method:: mouseMoveEvent(e) .. py:method:: mouseReleaseEvent(e) .. py:method:: mouseDoubleClickEvent(e: PyQt5.QtGui.QMouseEvent) .. py:method:: sizeHint() .. py:method:: paintEvent(e) .. py:class:: TabBar(parent=None) Bases: :py:obj:`qfluentwidgets.components.widgets.scroll_area.SingleDirectionScrollArea` Tab bar .. py:attribute:: currentChanged .. py:attribute:: tabBarClicked .. py:attribute:: tabBarDoubleClicked .. py:attribute:: tabCloseRequested .. py:attribute:: tabAddRequested .. py:attribute:: tabMoved .. py:attribute:: items :type: List[TabItem] :value: [] .. py:attribute:: itemMap :type: Dict[str, TabItem] .. py:attribute:: dragPos .. py:attribute:: isDraging :value: False .. py:attribute:: lightSelectedBackgroundColor .. py:attribute:: darkSelectedBackgroundColor .. py:attribute:: closeButtonDisplayMode .. py:attribute:: view .. py:attribute:: hBoxLayout .. py:attribute:: itemLayout .. py:attribute:: widgetLayout .. py:attribute:: addButton .. py:method:: setAddButtonVisible(isVisible: bool) .. py:method:: addTab(routeKey: str, text: str, icon: Union[PyQt5.QtGui.QIcon, str, qfluentwidgets.common.icon.FluentIconBase] = None, onClick=None) add tab Parameters ---------- routeKey: str the unique name of tab item text: str the text of tab item text: str the icon of tab item onClick: callable the slot connected to item clicked signal .. py:method:: insertTab(index: int, routeKey: str, text: str, icon: Union[PyQt5.QtGui.QIcon, str, qfluentwidgets.common.icon.FluentIconBase] = None, onClick=None) insert tab Parameters ---------- index: int the insert position of tab item routeKey: str the unique name of tab item text: str the text of tab item text: str the icon of tab item onClick: callable the slot connected to item clicked signal .. py:method:: removeTab(index: int) .. py:method:: removeTabByKey(routeKey: str) .. py:method:: setCurrentIndex(index: int) set current index .. py:method:: setCurrentTab(routeKey: str) .. py:method:: currentIndex() .. py:method:: currentTab() .. py:method:: setCloseButtonDisplayMode(mode: TabCloseButtonDisplayMode) set close button display mode .. py:method:: tabItem(index: int) .. py:method:: tab(routeKey: str) .. py:method:: tabRegion() -> PyQt5.QtCore.QRect return the bounding rect of all tabs .. py:method:: tabRect(index: int) return the visual rectangle of the tab at position index .. py:method:: tabData(index: int) .. py:method:: setTabData(index: int, data) .. py:method:: tabText(index: int) .. py:method:: tabIcon(index: int) .. py:method:: tabToolTip(index: int) .. py:method:: isTabEnabled(index: int) .. py:method:: setTabEnabled(index: int, isEnabled: bool) .. py:method:: setTabsClosable(isClosable: bool) set whether the tab is closable .. py:method:: tabsClosable() .. py:method:: setTabIcon(index: int, icon: Union[PyQt5.QtGui.QIcon, qfluentwidgets.common.icon.FluentIconBase, str]) set tab icon .. py:method:: setTabText(index: int, text: str) set tab text .. py:method:: isTabVisible(index: int) .. py:method:: setTabVisible(index: int, isVisible: bool) set the visibility of tab .. py:method:: setTabTextColor(index: int, color: PyQt5.QtGui.QColor) set the text color of tab item .. py:method:: setTabToolTip(index: int, toolTip: str) set tool tip of tab .. py:method:: setTabSelectedBackgroundColor(light: PyQt5.QtGui.QColor, dark: PyQt5.QtGui.QColor) set the background in selected state .. py:method:: setTabShadowEnabled(isEnabled: bool) set whether the shadow of tab is enabled .. py:method:: isTabShadowEnabled() .. py:method:: paintEvent(e) .. py:method:: setMovable(movable: bool) .. py:method:: isMovable() .. py:method:: setScrollable(scrollable: bool) .. py:method:: setTabMaximumWidth(width: int) set the maximum width of tab .. py:method:: setTabMinimumWidth(width: int) set the minimum width of tab .. py:method:: tabMaximumWidth() .. py:method:: tabMinimumWidth() .. py:method:: isScrollable() .. py:method:: count() returns the number of tabs .. py:method:: clear() Remove all tabs .. py:method:: mousePressEvent(e: PyQt5.QtGui.QMouseEvent) .. py:method:: mouseMoveEvent(e: PyQt5.QtGui.QMouseEvent) .. py:method:: mouseReleaseEvent(e) .. py:attribute:: movable .. py:attribute:: scrollable .. py:attribute:: tabMaxWidth .. py:attribute:: tabMinWidth .. py:attribute:: tabShadowEnabled .. py:class:: TabWidget(parent=None) Bases: :py:obj:`PyQt5.QtWidgets.QWidget` .. py:attribute:: currentChanged .. py:attribute:: tabBarClicked .. py:attribute:: tabCloseRequested .. py:attribute:: tabAddRequested .. py:attribute:: tabBarDoubleClicked .. py:attribute:: tabBar .. py:attribute:: stackedWidget .. py:attribute:: vBoxLayout .. py:method:: addPage(widget: PyQt5.QtWidgets.QWidget, label: str, icon: Union[PyQt5.QtGui.QIcon, str, qfluentwidgets.common.icon.FluentIconBase] = None, routeKey=None) -> int Adds a tab with the given page, icon, and label to the tab widget, and returns the index of the tab in the tab bar. Parameters ---------- widget: QWidget the widget in the new tab label: str the title of tab icon: str | QIcon | FluentIconBase the icon of tab routeKey: str the route key of new tab, if not provided, an unique uuid will be generated as route key Returns ------- index: int the index of the tab .. py:method:: addTab(widget: PyQt5.QtWidgets.QWidget, label: str, icon: Union[PyQt5.QtGui.QIcon, str, qfluentwidgets.common.icon.FluentIconBase] = None, routeKey=None) -> int Adds a tab with the given page, icon, and label to the tab widget, and returns the index of the tab in the tab bar. Parameters ---------- widget: QWidget the widget in the new tab label: str the title of tab icon: str | QIcon | FluentIconBase the icon of tab routeKey: str the route key of new tab, if not provided, an unique uuid will be generated as route key Returns ------- index: int the index of the tab .. py:method:: insertTab(index: int, widget: PyQt5.QtWidgets.QWidget, label: str, icon: Union[PyQt5.QtGui.QIcon, str, qfluentwidgets.common.icon.FluentIconBase] = None, routeKey=None) -> int Inserts a tab with the given label and page into the tab widget at the specified index, and returns the index of the inserted tab in the tab bar. Parameters ---------- index: int the index of new tab to be inserted widget: QWidget the widget in the new tab label: str the title of tab icon: str | QIcon | FluentIconBase the icon of tab routeKey: str the route key of new tab, if not provided, an unique uuid will be generated as route key Returns ------- index: int the index of the tab .. py:method:: removeTab(index: int) Removes the tab at position index from this stack of widgets. The page widget itself is not deleted. Parameters ---------- index: int the index of removed widget .. py:method:: clear() Removes all the pages, but does not delete them. .. py:method:: widget(index: int) Returns the tab page at index position index or `None` if the index is out of range. .. py:method:: currentWidget() -> PyQt5.QtWidgets.QWidget Returns a pointer to the page currently being displayed. .. py:method:: currentIndex() Returns the index position of the current tab page, returns -1 if there is no current widget. .. py:method:: setTabBar(tabBar) Replaces the original tab bar with new one. Note that this must be called before any tabs have been added, or the behavior is undefined. .. py:method:: isMovable() Returns whether the user can move the tabs within the tabbar area. .. py:method:: setMovable(movable: bool) .. py:method:: isTabEnabled(index: int) .. py:method:: setTabEnabled(index: int, isEnabled: bool) .. py:method:: isTabVisible(index: int) .. py:method:: setTabVisible(index: int, isVisible: bool) .. py:method:: tabText(index: int) .. py:method:: tabIcon(index: int) .. py:method:: tabToolTip(index: int) .. py:method:: setTabsClosable(closable: bool) .. py:method:: tabsClosable() -> bool .. py:method:: setTabIcon(index: int, icon: Union[PyQt5.QtGui.QIcon, qfluentwidgets.common.icon.FluentIconBase, str]) .. py:method:: setTabText(index: int, text: str) .. py:method:: setTabToolTip(index: int, tip: str) .. py:method:: setTabTextColor(index: int, color) .. py:method:: setTabSelectedBackgroundColor(light, dark) .. py:method:: setTabShadowEnabled(enabled: bool) .. py:method:: setScrollable(scrollable: bool) .. py:method:: isScrollable() -> bool .. py:method:: setTabMaximumWidth(width: int) .. py:method:: setTabMinimumWidth(width: int) .. py:method:: tabMaximumWidth() -> int .. py:method:: tabMinimumWidth() -> int .. py:method:: tabData(index: int) .. py:method:: setTabData(index: int, data) .. py:method:: count() -> int Returns the number of tabs in the tab bar. .. py:method:: setCurrentIndex(index: int) the index of the tab bar's visible tab .. py:method:: setCurrentWidget(widget: PyQt5.QtWidgets.QWidget) Sets the current tab to the tab which contains the given widget. .. py:method:: setCloseButtonDisplayMode(mode: TabCloseButtonDisplayMode)