本文整理汇总了Python中qtpy.QtWidgets.QTabWidget.setTabsClosable方法的典型用法代码示例。如果您正苦于以下问题:Python QTabWidget.setTabsClosable方法的具体用法?Python QTabWidget.setTabsClosable怎么用?Python QTabWidget.setTabsClosable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QTabWidget
的用法示例。
在下文中一共展示了QTabWidget.setTabsClosable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _build_view
# 需要导入模块: from qtpy.QtWidgets import QTabWidget [as 别名]
# 或者: from qtpy.QtWidgets.QTabWidget import setTabsClosable [as 别名]
def _build_view(self, line_list, index, waverange=(None, None)):
if self.wave_range[0] and self.wave_range[1]:
line_list = line_list.extract_range(waverange)
table_model = LineListTableModel(line_list)
if table_model.rowCount() > 0:
# here we add the first pane (the one with the entire
# original line list), to the tabbed pane that contains
# the line sets corresponding to the current line list.
lineset_tabbed_pane = QTabWidget()
lineset_tabbed_pane.setTabsClosable(True)
pane, table_view = _create_line_list_pane(line_list, table_model, self)
lineset_tabbed_pane.addTab(pane, "Original")
pane._set_line_sets_tabbed_pane(lineset_tabbed_pane)
table_view.selectionModel().selectionChanged.connect(pane._handle_button_activation)
# internal signals do not use Hub infrastructure.
table_view.selectionModel().selectionChanged.connect(self._count_selections)
# now we add this "line set tabbed pane" to the main tabbed
# pane, with name taken from the list model.
self.tab_widget.insertTab(index, lineset_tabbed_pane, table_model.get_name())
self.tab_widget.setCurrentIndex(index)
# store for use down stream.
# self.table_views.append(table_view)
# self.set_tabbed_panes.append(set_tabbed_pane)
# self.tab_count.append(0)
# self.panes.append(pane)
return line_list
示例2: create_tabwidget
# 需要导入模块: from qtpy.QtWidgets import QTabWidget [as 别名]
# 或者: from qtpy.QtWidgets.QTabWidget import setTabsClosable [as 别名]
def create_tabwidget(self):
"""Create a new QTabWidget with a button to add new tabs"""
tabs = QTabWidget(self)
tabs.setMovable(True)
tabs.setTabsClosable(True)
# create a button to add new tabs
plus_btn = QToolButton(tabs)
plus_btn.setText('+')
plus_btn.clicked.connect(self.plus_button_clicked)
tabs.setCornerWidget(plus_btn, Qt.TopLeftCorner)
tabs.tabCloseRequested.connect(self.close_tab)
return tabs
示例3: set_close_function
# 需要导入模块: from qtpy.QtWidgets import QTabWidget [as 别名]
# 或者: from qtpy.QtWidgets.QTabWidget import setTabsClosable [as 别名]
def set_close_function(self, func):
"""Setting Tabs close function
None -> tabs are not closable"""
state = func is not None
if state:
self.sig_close_tab.connect(func)
try:
# Assuming Qt >= 4.5
QTabWidget.setTabsClosable(self, state)
self.tabCloseRequested.connect(func)
except AttributeError:
# Workaround for Qt < 4.5
close_button = create_toolbutton(self, triggered=func,
icon=ima.icon('fileclose'),
tip=_("Close current tab"))
self.setCornerWidget(close_button if state else None)