当前位置: 首页>>代码示例>>Python>>正文


Python QTabWidget.setCurrentWidget方法代码示例

本文整理汇总了Python中PySide.QtGui.QTabWidget.setCurrentWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QTabWidget.setCurrentWidget方法的具体用法?Python QTabWidget.setCurrentWidget怎么用?Python QTabWidget.setCurrentWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtGui.QTabWidget的用法示例。


在下文中一共展示了QTabWidget.setCurrentWidget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MultiRenderPropWidget

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import setCurrentWidget [as 别名]
class MultiRenderPropWidget(QWidget):
	"""
	MultiRenderPropWidget is a widget that is displayed under the multi render
	widget. It contains tabs with some controls for interaction and
	visualization of the combined / multi-volume render widget.
	"""
	def __init__(self, multiRenderController, parent=None):
		super(MultiRenderPropWidget, self).__init__(parent=parent)

		# Two tabs: Visualization and Data info
		self.mixParamWidget = RenderParameterWidget(multiRenderController)
		self.transformParamWidget = TransformationParameterWidget()
		self.registrationHistoryWidget = TransformationHistoryWidget()
		self.slicesTabWidget = RenderSlicerParamWidget(multiRenderController)

		# Create the tab widget
		self.tabWidget = QTabWidget()
		self.tabWidget.addTab(self.mixParamWidget, "Visualization")
		self.tabWidget.addTab(self.registrationHistoryWidget, "History")
		self.tabWidget.addTab(self.slicesTabWidget, "Slices")

		self.currentTabIndex = 0
		self.tabWidget.currentChanged.connect(self.tabIndexChanged)

		layout = QVBoxLayout()
		self.setLayout(layout)
		layout.addWidget(self.tabWidget)

		self.registrationHistoryWidget.setMultiRenderWidget(multiRenderController.multiRenderWidget)

	def setTransformTool(self, transformTool):
		if self.tabWidget.indexOf(self.transformParamWidget) < 0:
			self.tabWidget.addTab(self.transformParamWidget, "Transformation")
		
		self.tabWidget.setCurrentWidget(self.transformParamWidget)
		self.transformParamWidget.setTransformationTool(transformTool)

	def transformToolFinished(self):
		index = self.tabWidget.indexOf(self.transformParamWidget)
		if index >= 0:
			# Restore the last tab index that wasn't the transform tab
			self.tabWidget.setCurrentIndex(self.currentTabIndex)
			self.tabWidget.removeTab(index)

	@Slot(int)
	def tabIndexChanged(self, index):
		transformIndex = self.tabWidget.indexOf(self.transformParamWidget)
		if index != transformIndex:
			self.currentTabIndex = index
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:51,代码来源:MultiRenderPropWidget.py

示例2: window

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import setCurrentWidget [as 别名]

#.........这里部分代码省略.........
        tasklist.setMaximumWidth(250)

        new_tab = QWebView()
        new_tab.setObjectName('webView')

        inspector = QWebInspector(self)
        inspector.setObjectName('webInspector')
        inspector.hide()

        page_layout = QVBoxLayout()
        page_layout.setSpacing(0)
        page_layout.setContentsMargins(0, 0, 0, 0)
        page_layout.addWidget(new_tab)
        page_layout.addWidget(inspector)
        page_widget = QFrame()
        page_widget.setObjectName('pageWidget')
        page_widget.setLayout(page_layout)

        complete_tab_layout = QHBoxLayout()
        complete_tab_layout.setSpacing(0)
        complete_tab_layout.setContentsMargins(0, 0, 0, 0)
        complete_tab_layout.addWidget(tasklist)
        complete_tab_layout.addWidget(page_widget)
        complete_tab_widget = QFrame()
        complete_tab_widget.setLayout(complete_tab_layout)

        new_tab.load(QUrl(self.startpage))
        self.tabs.setUpdatesEnabled(False)
        if self.new_tab_behavior == "insert":
            self.tabs.insertTab(self.tabs.currentIndex()+1, complete_tab_widget,
                                    unicode(new_tab.title()))
        elif self.new_tab_behavior == "append":
            self.tabs.appendTab(complete_tab_widget, unicode(new_tab.title()))
        self.tabs.setCurrentWidget(complete_tab_widget)
        self.tabs.setTabText(self.tabs.currentIndex(),
                             unicode(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).title()))
        self.tabs.setUpdatesEnabled(True)
        # tab.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
        # tab.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
        new_tab.titleChanged.connect(self.change_tab)
        new_tab.urlChanged.connect(self.change_tab)
        new_tab.loadStarted.connect(self.load_start)
        new_tab.loadFinished.connect(self.load_finish)
        new_tab.loadProgress.connect(self.pbar.setValue)
        new_tab.page().linkHovered.connect(self.linkHover)
        inspector.setPage(new_tab.page())

    def change_tab(self):
        """Change active tab."""
        if self.tabs.count() <= 1:
            self.tabs.tabBar().hide()
        else:
            self.tabs.tabBar().show()

        try:
            self.edit.setText(str(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).url().toEncoded()))
            self.tabs.setTabText(self.tabs.currentIndex(),
                                 unicode(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).title()))
            self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).setFocus()
        except Exception:
            self.tabs.tabBar().hide()
            self.new_tab()

        #print (self.tabs.widget(self.tabs.currentIndex()).size().width()-10), self.tabs.count()
        self.tabs_widget.setStyleSheet(self.style_sheet +
                                       "QTabBar::tab { width:" + str(
开发者ID:eivind88,项目名称:raskolnikov-browser,代码行数:70,代码来源:main.py

示例3: RenderPropWidget

# 需要导入模块: from PySide.QtGui import QTabWidget [as 别名]
# 或者: from PySide.QtGui.QTabWidget import setCurrentWidget [as 别名]
class RenderPropWidget(QWidget):
	"""
	RenderPropWidget is a widget that is displayed under the render widgets. It
	contains a tabwidget in which information of the data can be displayed and
	in which visualization parameters can be shown. One of the tabs is a
	RenderParameterWidget object.
	"""
	def __init__(self, renderController, parent=None):
		super(RenderPropWidget, self).__init__(parent=parent)

		# Three tabs: Visualization, data info and slices
		self.visParamTabWidget = RenderParameterWidget(renderController)
		self.dataInfoTabWidget = RenderInfoWidget()
		self.slicesTabWidget = RenderSlicerParamWidget(renderController)

		# Create the load dataset widget
		self.loadDataWidget = QWidget()
		self.loadDataButton = QPushButton()
		self.loadDataButton.setText("Load a dataset")

		layout = QVBoxLayout()
		layout.setAlignment(Qt.AlignTop)
		layout.addWidget(self.loadDataButton)
		self.loadDataWidget.setLayout(layout)

		# Create the tab widget
		self.tabWidget = QTabWidget()
		self.tabWidget.addTab(self.visParamTabWidget, "Visualization")
		self.tabWidget.addTab(self.slicesTabWidget, "Slices")
		self.tabWidget.addTab(self.dataInfoTabWidget, "Data info")

		self.currentTabIndex = 0
		self.extraTabWidget = None
		self.tabWidget.currentChanged.connect(self.tabIndexChanged)

		layout = QVBoxLayout()
		layout.addWidget(self.loadDataWidget)
		self.setLayout(layout)

	def setFileChangedSignal(self, signal):
		"""
		:param signal: Signal that is connected to some file-loading slots.
		:type signal: SIGNAL
		"""
		self.signal = signal
		self.signal.connect(self.setFile)
		self.signal.connect(self.dataInfoTabWidget.setFile)

	def setLoadDataSlot(self, slot):
		"""
		The button is connected to the given slot. The slot action should load
		a dataset from disk.

		:type slot: Slot
		"""
		self.loadDataButton.clicked.connect(slot)

	@Slot(basestring)
	def setFile(self, fileName):
		"""
		When a file is loaded, the 'load data' button is removed from the widget
		and the actual tabs with parameters are put on screen.
		"""
		layout = self.layout()
		if fileName is None:
			if layout.indexOf(self.tabWidget) != -1:
				# Remove the parameter widgets
				layout.removeWidget(self.tabWidget)
				self.tabWidget.setParent(None)
				# Show the load data button
				layout.addWidget(self.loadDataWidget)
				self.setLayout(layout)
		else:
			if layout.indexOf(self.loadDataWidget) != -1:
				# Remove the load data button
				layout.removeWidget(self.loadDataWidget)
				self.loadDataWidget.setParent(None)
				# Add the parameter widgets
				layout.addWidget(self.tabWidget)
				self.setLayout(layout)

	@Slot(int)
	def tabIndexChanged(self, index):
		transformIndex = self.tabWidget.indexOf(self.extraTabWidget)
		if index != transformIndex:
			self.currentTabIndex = index

	def addTabWidget(self, widget, name):
		self.extraTabWidget = widget
		self.tabWidget.addTab(widget, name)
		self.tabWidget.setCurrentWidget(self.extraTabWidget)

	def removeTabWidget(self):
		if self.extraTabWidget is None:
			return

		index = self.tabWidget.indexOf(self.extraTabWidget)
		if index >= 0:
			# Restore the last tab index that wasn't the transform tab
			self.tabWidget.setCurrentIndex(self.currentTabIndex)
#.........这里部分代码省略.........
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:103,代码来源:RenderPropWidget.py


注:本文中的PySide.QtGui.QTabWidget.setCurrentWidget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。