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


Python QCheckBox.checkState方法代码示例

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


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

示例1: RenderSlicerParamWidget

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import checkState [as 别名]
class RenderSlicerParamWidget(QWidget):
	"""
	RenderSlicerParamWidget shows parameters with which slicers can be
	manipulated.
	"""
	def __init__(self, renderController, parent=None):
		super(RenderSlicerParamWidget, self).__init__(parent=parent)

		self.renderController = renderController
		self.renderController.slicesChanged.connect(self.setSlices)
		self.renderController.clippingBoxChanged.connect(self.showsClippingBox)
		self.renderController.clippingPlanesChanged.connect(self.showsClippingPlanes)

		self.sliceLabelTexts = ["Axial:", "Coronal:", "Sagittal:"]
		self.sliceLabels = [QLabel(text) for text in self.sliceLabelTexts]
		self.sliceCheckBoxes = [QCheckBox() for i in range(3)]
		for index in range(3):
			self.sliceCheckBoxes[index].clicked.connect(self.checkBoxChanged)
			self.sliceLabels[index].setAlignment(Qt.AlignRight | Qt.AlignVCenter)
			self.sliceCheckBoxes[index].setEnabled(True)

		slicesLayout = QGridLayout()
		slicesLayout.setAlignment(Qt.AlignTop)
		for index in range(3):
			slicesLayout.addWidget(self.sliceLabels[index], index+1, 0)
			slicesLayout.addWidget(self.sliceCheckBoxes[index], index+1, 1)

		self.slicesGroupBox = QGroupBox()
		self.slicesGroupBox.setTitle("Visible slices")
		self.slicesGroupBox.setLayout(slicesLayout)

		# Create option to show clipping box
		self.clippingCheckBox = QCheckBox()
		self.clippingCheckBox.setChecked(self.renderController.clippingBox)
		self.clippingCheckBox.clicked.connect(self.clippingCheckBoxChanged)
		self.clippingPlanesCheckBox = QCheckBox()
		self.clippingPlanesCheckBox.setChecked(self.renderController.clippingPlanes)
		self.clippingPlanesCheckBox.clicked.connect(self.clippingPlanesCheckBoxChanged)
		self.resetButton = QPushButton("Reset")
		self.resetButton.clicked.connect(self.resetClippingBox)

		clippingLabel = QLabel("Clipping box:")
		clippingLabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
		clippingPlanesLabel = QLabel("Clipping planes:")
		clippingPlanesLabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter)

		clipLayout = QGridLayout()
		clipLayout.addWidget(clippingLabel, 0, 0)
		clipLayout.addWidget(self.clippingCheckBox, 0, 1)
		clipLayout.addWidget(clippingPlanesLabel, 1, 0)
		clipLayout.addWidget(self.clippingPlanesCheckBox, 1, 1)
		clipLayout.addWidget(self.resetButton, 2, 0)

		self.clippingGroupBox = QGroupBox()
		self.clippingGroupBox.setTitle("Clipping box")
		self.clippingGroupBox.setLayout(clipLayout)

		# Create a nice layout for the labels
		layout = QGridLayout()
		layout.setAlignment(Qt.AlignTop)
		layout.addWidget(self.slicesGroupBox, 0, 0)
		layout.addWidget(self.clippingGroupBox, 0, 1)
		self.setLayout(layout)

	@Slot()
	def checkBoxChanged(self):
		"""
		Callback function for the check boxes.
		"""
		for index in range(3):
			showCheckBox = self.sliceCheckBoxes[index].checkState() == Qt.Checked
			self.renderController.setSliceVisibility(index, showCheckBox)

	@Slot(object)
	def setSlices(self, slices):
		for index in range(len(slices)):
			checkBox = self.sliceCheckBoxes[index]
			checkBox.setChecked(slices[index])

	@Slot()
	def clippingCheckBoxChanged(self):
		"""
		Callback function for the clipping check box.
		"""
		self.renderController.showClippingBox(self.clippingCheckBox.checkState() == Qt.Checked)

	@Slot()
	def clippingPlanesCheckBoxChanged(self):
		"""
		Callback function for the clipping check box.
		"""
		self.renderController.showClippingPlanes(self.clippingPlanesCheckBox.checkState() == Qt.Checked)

	@Slot()
	def resetClippingBox(self):
		self.renderController.resetClippingBox()

	@Slot(bool)
	def showsClippingBox(self, show):
		self.clippingCheckBox.setChecked(show)
#.........这里部分代码省略.........
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:103,代码来源:RenderSlicerParamWidget.py

示例2: ColorMapWidget

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

#.........这里部分代码省略.........
        self.color_map_name = initial_map.color_map_name
        self.color_step = initial_map.color_step
        self.step_size = initial_map.step_size
        self.tag = tag

        self.color_map_label = "Color Map"
        self.color_step_label = "Cycle Color Map"
        self.number_steps_label = "Colors"

        self.color_step_tooltip = "Use the given number of evenly spaced " \
            + " colors from the map and assign to discrete values in cycled " \
            + " sequence."

        layout = QVBoxLayout()

        layout.addWidget(self.buildColorBarControl())
        layout.addItem(QSpacerItem(5,5))
        layout.addWidget(self.buildColorStepsControl())

        self.setLayout(layout)

    def buildColorBarControl(self):
        """Builds the portion of this widget for color map selection."""
        widget = QWidget()
        layout = QHBoxLayout()

        label = QLabel(self.color_map_label)
        self.colorbar = QLabel(self)
        self.colorbar.setPixmap(QPixmap.fromImage(ColorBarImage(
            self.color_map, 180, 15)))

        self.mapCombo = QComboBox(self)
        self.mapCombo.addItems(map_names)
        self.mapCombo.setCurrentIndex(map_names.index(self.color_map_name))
        self.mapCombo.currentIndexChanged.connect(self.colorbarChange)

        layout.addWidget(label)
        layout.addItem(QSpacerItem(5,5))
        layout.addWidget(self.mapCombo)
        layout.addItem(QSpacerItem(5,5))
        layout.addWidget(self.colorbar)

        widget.setLayout(layout)
        return widget

    @Slot(int)
    def colorbarChange(self, ind):
        """Handles a selection of a different colormap."""
        indx = self.mapCombo.currentIndex()
        self.color_map_name = map_names[indx]
        self.color_map = getMap(self.color_map_name)
        self.colorbar.setPixmap(QPixmap.fromImage(ColorBarImage(
            self.color_map, 180, 12)))
        self.changeSignal.emit(ColorMap(self.color_map_name, self.color_step,
            self.step_size), self.tag)

    def buildColorStepsControl(self):
        """Builds the portion of this widget for color cycling options."""
        widget = QWidget()
        layout = QHBoxLayout()

        self.stepBox = QCheckBox(self.color_step_label)
        self.stepBox.stateChanged.connect(self.colorstepsChange)

        self.stepEdit = QLineEdit("8", self)
        # Setting max to sys.maxint in the validator causes an overflow! D:
        self.stepEdit.setValidator(QIntValidator(1, 65536, self.stepEdit))
        self.stepEdit.setEnabled(False)
        self.stepEdit.editingFinished.connect(self.colorstepsChange)

        if self.color_step > 0:
            self.stepBox.setCheckState(Qt.Checked)
            self.stepEdit.setEnabled(True)

        layout.addWidget(self.stepBox)
        layout.addItem(QSpacerItem(5,5))
        layout.addWidget(QLabel("with"))
        layout.addItem(QSpacerItem(5,5))
        layout.addWidget(self.stepEdit)
        layout.addItem(QSpacerItem(5,5))
        layout.addWidget(QLabel(self.number_steps_label))

        widget.setLayout(layout)
        return widget


    def colorstepsChange(self):
        """Handles a change in the state of the color cycling for this
           colormap.
        """
        if self.stepBox.checkState() == Qt.Checked:
            self.stepEdit.setEnabled(True)
            self.color_step = int(self.stepEdit.text())
            self.changeSignal.emit(ColorMap(self.color_map_name,
                self.color_step, self.step_size), self.tag)
        else:
            self.stepEdit.setEnabled(False)
            self.color_step = 0
            self.changeSignal.emit(ColorMap(self.color_map_name,
                self.color_step, self.step_size), self.tag)
开发者ID:Schizo,项目名称:boxfish,代码行数:104,代码来源:ColorMaps.py

示例3: RenderSlicerParamWidget

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import checkState [as 别名]
class RenderSlicerParamWidget(QWidget):
	"""
	RenderSlicerParamWidget shows parameters with which slicers can be
	manipulated.
	"""
	def __init__(self, renderController, parent=None):
		super(RenderSlicerParamWidget, self).__init__(parent=parent)

		self.renderController = renderController
		self.renderController.slicesChanged.connect(self.setSlices)
		self.renderController.clippingBoxChanged.connect(self.showsClippingBox)

		self.slicesLabel = QLabel("Show slices for directions:")
		self.sliceLabelTexts = ["x:", "y:", "z:"]
		self.sliceLabels = [QLabel(text) for text in self.sliceLabelTexts]
		self.sliceCheckBoxes = [QCheckBox() for i in range(3)]
		for index in range(3):
			self.sliceCheckBoxes[index].clicked.connect(self.checkBoxChanged)
			self.sliceLabels[index].setAlignment(Qt.AlignRight | Qt.AlignVCenter)
			self.sliceCheckBoxes[index].setEnabled(True)

		# Create a nice layout for the labels
		layout = QGridLayout()
		layout.setAlignment(Qt.AlignTop)
		layout.setColumnStretch(0, 1)
		layout.setColumnStretch(1, 3)
		layout.addWidget(self.slicesLabel, 0, 0, 1, -1)
		for index in range(3):
			layout.addWidget(self.sliceLabels[index], index+1, 0)
			layout.addWidget(self.sliceCheckBoxes[index], index+1, 1)

		# Create option to show clipping box
		self.clippingCheckBox = QCheckBox()
		self.clippingCheckBox.clicked.connect(self.clippingCheckBoxChanged)
		self.clippingLabel = QLabel("Clipping box:")
		self.clippingLabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter)

		layout.addWidget(self.clippingLabel, 5, 0)
		layout.addWidget(self.clippingCheckBox, 5, 1)
		self.setLayout(layout)

	@Slot()
	def checkBoxChanged(self):
		"""
		Callback function for the check boxes.
		"""
		for index in range(3):
			showCheckBox = self.sliceCheckBoxes[index].checkState() == Qt.Checked
			self.renderController.setSliceVisibility(index, showCheckBox)

	@Slot(object)
	def setSlices(self, slices):
		for index in range(len(slices)):
			checkBox = self.sliceCheckBoxes[index]
			checkBox.setChecked(slices[index])

	@Slot()
	def clippingCheckBoxChanged(self):
		"""
		Callback function for the clipping check box.
		"""
		self.renderController.showClippingBox(self.clippingCheckBox.checkState() == Qt.Checked)

	@Slot(bool)
	def showsClippingBox(self, show):
		self.clippingCheckBox.setChecked(show)
开发者ID:rcockbur,项目名称:3DMedicalVisualizationTool,代码行数:68,代码来源:RenderSlicerParamWidget.py


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