本文整理汇总了Python中AnyQt.QtWidgets.QComboBox.var_type方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.var_type方法的具体用法?Python QComboBox.var_type怎么用?Python QComboBox.var_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QComboBox
的用法示例。
在下文中一共展示了QComboBox.var_type方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_new_values
# 需要导入模块: from AnyQt.QtWidgets import QComboBox [as 别名]
# 或者: from AnyQt.QtWidgets.QComboBox import var_type [as 别名]
def set_new_values(self, oper_combo, adding_all, selected_values=None):
# def remove_children():
# for child in box.children()[1:]:
# box.layout().removeWidget(child)
# child.setParent(None)
def add_textual(contents):
le = gui.lineEdit(box, self, None,
sizePolicy=QSizePolicy(QSizePolicy.Expanding,
QSizePolicy.Expanding))
if contents:
le.setText(contents)
le.setAlignment(Qt.AlignRight)
le.editingFinished.connect(self.conditions_changed)
return le
def add_numeric(contents):
le = add_textual(contents)
le.setValidator(OWSelectRows.QDoubleValidatorEmpty())
return le
def add_datetime(contents):
le = add_textual(contents)
le.setValidator(QRegExpValidator(QRegExp(TimeVariable.REGEX)))
return le
var = self.data.domain[oper_combo.attr_combo.currentText()]
box = self.cond_list.cellWidget(oper_combo.row, 2)
if selected_values is not None:
lc = list(selected_values) + ["", ""]
lc = [str(x) for x in lc[:2]]
else:
lc = ["", ""]
if box and vartype(var) == box.var_type:
lc = self._get_lineedit_contents(box) + lc
oper = oper_combo.currentIndex()
if oper_combo.currentText() == "is defined":
label = QLabel()
label.var_type = vartype(var)
self.cond_list.setCellWidget(oper_combo.row, 2, label)
elif var.is_discrete:
if oper_combo.currentText() == "is one of":
if selected_values:
lc = [x for x in list(selected_values)]
button = DropDownToolButton(self, var, lc)
button.var_type = vartype(var)
self.cond_list.setCellWidget(oper_combo.row, 2, button)
else:
combo = QComboBox()
combo.addItems([""] + var.values)
if lc[0]:
combo.setCurrentIndex(int(lc[0]))
else:
combo.setCurrentIndex(0)
combo.var_type = vartype(var)
self.cond_list.setCellWidget(oper_combo.row, 2, combo)
combo.currentIndexChanged.connect(self.conditions_changed)
else:
box = gui.hBox(self, addToLayout=False)
box.var_type = vartype(var)
self.cond_list.setCellWidget(oper_combo.row, 2, box)
if var.is_continuous:
validator = add_datetime if isinstance(var, TimeVariable) else add_numeric
box.controls = [validator(lc[0])]
if oper > 5:
gui.widgetLabel(box, " and ")
box.controls.append(validator(lc[1]))
elif var.is_string:
box.controls = [add_textual(lc[0])]
if oper in [6, 7]:
gui.widgetLabel(box, " and ")
box.controls.append(add_textual(lc[1]))
else:
box.controls = []
if not adding_all:
self.conditions_changed()