コード例 #1
0
	def createWidgets(self):

		vlayout = QVBoxLayout()

		lbl = QLabel(
			"A column labeled 'ID' with unique increasing numbers for every row will be "\
			"added to the output table automatically. In addition to this column it is also "\
			"possible to copy one of the columns of the source table to the output table "\
			"(tip: if a row identifying column is copied this can later be used for transferring "\
			"more data from source table to the new table if necessary).")
		lbl.setWordWrap(True);
		vlayout.addWidget(lbl)

		vlayout.addSpacing(20)

		self._copyCheck = WidgetEnableCheckBox("Copy column from source table")
		self.regProp("copy_column_enabled", WizProp(self._copyCheck, False))
		vlayout.addWidget(self._copyCheck)

		glayout = QGridLayout()
		glayout.setColumnMinimumWidth(0, 20)

		lbl = QLabel(
			"The selected column of the source table will be added to the output table "\
			"(possibly with a new name). For every object in the output table the value of "\
			"its source object will be copied to this column.")
		lbl.setWordWrap(True);
		self._copyCheck.addWidget(lbl)
		glayout.addWidget(lbl, 0, 1, 1, 3)

		lbl = QLabel("Column in source table")
		self._copyCheck.addWidget(lbl)
		glayout.addWidget(lbl, 1, 1)
		self._sourceCombo = QComboBox()
		self.regProp("copy_column_in", WizProp(self._sourceCombo, ""))
		self._copyCheck.addWidget(self._sourceCombo)
		glayout.addWidget(self._sourceCombo, 1, 2)

		lbl = QLabel("Column in output table")
		self._copyCheck.addWidget(lbl)
		glayout.addWidget(lbl, 2, 1)
		self._outputEdit = QLineEdit()
		self.regProp("copy_column_out", WizProp(self._outputEdit, ""))
		self._copyCheck.addWidget(self._outputEdit)
		glayout.addWidget(self._outputEdit, 2, 2)

		vlayout.addLayout(glayout)

		vlayout.addStretch(1)

		self.setLayout(vlayout)
コード例 #2
0
ファイル: propertysheet.py プロジェクト: e-kotov/PST
class PropertySheetWidget(QWidget):
    def __init__(self, wizard_page):
        QWidget.__init__(self)
        self._page = wizard_page
        self._glayout = QGridLayout()
        self._glayout.setContentsMargins(0, 0, 0, 0)
        self._glayout.setVerticalSpacing(4)
        self._glayout.setColumnStretch(4, 1)
        self._row_count = 0
        self.setDefaultIndent()
        self.setLayout(self._glayout)

    def setDefaultIndent(self):
        self.setIndent(10)

    def setIndent(self, indent):
        self._glayout.setColumnMinimumWidth(0, indent)

    def newSection(self, title=None):
        if self._row_count > 0:
            self._glayout.setRowMinimumHeight(self._row_count, 10)
            self._row_count = self._row_count + 1
        if title is not None:
            self._glayout.addWidget(QLabel(title), self._row_count, 0, 1, 4)
            self._row_count = self._row_count + 1

    def add(self, label, ctrl=None, unit=None):
        label_col_span = 1
        if ctrl is None:
            label_col_span = 3 if unit is None else 2
        self._glayout.addWidget(label, self._row_count, 1, 1, label_col_span)
        if ctrl is not None:
            self._glayout.addWidget(ctrl, self._row_count, 2)
        if unit is not None:
            self._glayout.addWidget(unit, self._row_count, 3)
        self._row_count = self._row_count + 1

    def addBoolProp(self,
                    title,
                    default_value,
                    prop_name,
                    style=PropertyStyle.CHECK):
        widget = None
        if style == PropertyStyle.CHECK:
            widget = QCheckBox(title)
        elif style == PropertyStyle.RADIO:
            widget = QRadioButton(title)
        else:
            raise Exception("Unsupported bool property style (#%d)!" % (style))
        self._page.regProp(prop_name, WizProp(widget, default_value))
        self.add(widget)
        return widget

    def addNumberProp(self,
                      title,
                      default_value,
                      decimals,
                      unit,
                      prop_name,
                      style=PropertyStyle.LABEL,
                      default_state=PropertyState.CHECKED):
        edit = QLineEdit()
        edit.setAlignment(Qt.AlignRight)
        unit_label = QLabel(unit)
        self._page.regProp(prop_name,
                           WizPropFloat(edit, default_value, decimals))
        widget = None
        if PropertyStyle.LABEL == style:
            widget = QLabel(title)
        elif PropertyStyle.CHECK == style:
            widget = WidgetEnableCheckBox(title, [edit, unit_label])
            self._page.regProp(prop_name + "_enabled",
                               WizProp(widget, default_state))
        elif PropertyStyle.RADIO == style:
            widget = WidgetEnableRadioButton(title, [edit, unit_label])
            self._page.regProp(prop_name + "_enabled",
                               WizProp(widget, default_state))
        else:
            raise Exception("Unsupported number property style (#%d)!" %
                            (style))
        self.add(widget, edit, unit_label)
        return (widget, edit, unit_label)

    def addComboProp(self, title, options, default_value, prop_name):
        combo = QComboBox()
        for text, value in options:
            combo.addItem(text, value)
        self._page.regProp(prop_name, WizPropCombo(combo, default_value))
        label = QLabel(title)
        self.add(label, combo)
        return (label, combo)

    def addStretch(self, amount):
        self._glayout.setRowStretch(self._row_count, amount)
        self._row_count = self._row_count + 1