本文整理汇总了Python中guidata.qt.QtGui.QGroupBox.setToolTip方法的典型用法代码示例。如果您正苦于以下问题:Python QGroupBox.setToolTip方法的具体用法?Python QGroupBox.setToolTip怎么用?Python QGroupBox.setToolTip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类guidata.qt.QtGui.QGroupBox
的用法示例。
在下文中一共展示了QGroupBox.setToolTip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ChoiceWidget
# 需要导入模块: from guidata.qt.QtGui import QGroupBox [as 别名]
# 或者: from guidata.qt.QtGui.QGroupBox import setToolTip [as 别名]
class ChoiceWidget(AbstractDataSetWidget):
"""
Choice item widget
"""
def __init__(self, item, parent_layout):
super(ChoiceWidget, self).__init__(item, parent_layout)
self._first_call = True
self.is_radio = item.get_prop_value("display", "radio")
self.store = self.item.get_prop("display", "store", None)
if self.is_radio:
self.group = QGroupBox()
self.group.setToolTip(item.get_help())
self.vbox = QVBoxLayout()
self.group.setLayout(self.vbox)
self._buttons = []
else:
self.combobox = self.group = QComboBox()
self.combobox.setToolTip(item.get_help())
self.combobox.currentIndexChanged.connect(self.index_changed)
def index_changed(self, index):
if self.store:
self.store.set(self.item.instance, self.item.item, self.value())
self.parent_layout.refresh_widgets()
cb = self.item.get_prop_value("display", "callback", None)
if cb is not None:
if self.build_mode:
self.set()
else:
self.parent_layout.update_dataitems()
cb(self.item.instance, self.item.item, self.value())
self.parent_layout.update_widgets(except_this_one=self)
def initialize_widget(self):
if self.is_radio:
for button in self._buttons:
button.toggled.disconnect(self.index_changed)
self.vbox.removeWidget(button)
button.deleteLater()
self._buttons = []
else:
self.combobox.blockSignals(True)
while self.combobox.count():
self.combobox.removeItem(0)
_choices = self.item.get_prop_value("data", "choices")
for key, lbl, img in _choices:
if self.is_radio:
button = QRadioButton(lbl, self.group)
if img:
if is_text_string(img):
if not osp.isfile(img):
img = get_image_file_path(img)
img = QIcon(img)
elif isinstance(img, collections.Callable):
img = img(key)
if self.is_radio:
button.setIcon(img)
else:
self.combobox.addItem(img, lbl)
elif not self.is_radio:
self.combobox.addItem(lbl)
if self.is_radio:
self._buttons.append(button)
self.vbox.addWidget(button)
button.toggled.connect(self.index_changed)
if not self.is_radio:
self.combobox.blockSignals(False)
def set_widget_value(self, idx):
if self.is_radio:
for button in self._buttons:
button.blockSignals(True)
self._buttons[idx].setChecked(True)
for button in self._buttons:
button.blockSignals(False)
else:
self.combobox.blockSignals(True)
self.combobox.setCurrentIndex(idx)
self.combobox.blockSignals(False)
def get_widget_value(self):
if self.is_radio:
for index, widget in enumerate(self._buttons):
if widget.isChecked():
return index
else:
return self.combobox.currentIndex()
def get(self):
"""Override AbstractDataSetWidget method"""
self.initialize_widget()
value = self.item.get()
if value is not None:
idx = 0
_choices = self.item.get_prop_value("data", "choices")
for key, _val, _img in _choices:
if key == value:
break
idx += 1
self.set_widget_value(idx)
#.........这里部分代码省略.........