本文整理汇总了Python中AnyQt.QtWidgets.QComboBox.itemData方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.itemData方法的具体用法?Python QComboBox.itemData怎么用?Python QComboBox.itemData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QComboBox
的用法示例。
在下文中一共展示了QComboBox.itemData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OWImportImages
# 需要导入模块: from AnyQt.QtWidgets import QComboBox [as 别名]
# 或者: from AnyQt.QtWidgets.QComboBox import itemData [as 别名]
#.........这里部分代码省略.........
def __runOpenDialog(self):
startdir = os.path.expanduser("~/")
if self.recent_paths:
startdir = os.path.dirname(self.recent_paths[0].abspath)
if OWImportImages.Modality == Qt.WindowModal:
dlg = QFileDialog(
self, "Select Top Level Directory", startdir,
acceptMode=QFileDialog.AcceptOpen,
modal=True,
)
dlg.setFileMode(QFileDialog.Directory)
dlg.setOption(QFileDialog.ShowDirsOnly)
dlg.setDirectory(startdir)
dlg.setAttribute(Qt.WA_DeleteOnClose)
@dlg.accepted.connect
def on_accepted():
dirpath = dlg.selectedFiles()
if dirpath:
self.setCurrentPath(dirpath[0])
self.start()
dlg.open()
else:
dirpath = QFileDialog.getExistingDirectory(
self, "Select Top Level Directory", startdir
)
if dirpath:
self.setCurrentPath(dirpath)
self.start()
def __onRecentActivated(self, index):
item = self.recent_cb.itemData(index)
if item is None:
return
assert isinstance(item, RecentPath)
self.setCurrentPath(item.abspath)
self.start()
def __updateInfo(self):
if self.__state == State.NoState:
text = "No image set selected"
elif self.__state == State.Processing:
text = "Processing"
elif self.__state == State.Done:
nvalid = self._n_image_data
ncategories = self._n_image_categories
n_skipped = self._n_skipped
if ncategories < 2:
text = "{} image{}".format(nvalid, "s" if nvalid != 1 else "")
else:
text = "{} images / {} categories".format(nvalid, ncategories)
if n_skipped > 0:
text = text + ", {} skipped".format(n_skipped)
elif self.__state == State.Cancelled:
text = "Cancelled"
elif self.__state == State.Error:
text = "Error state"
else:
assert False
self.info_area.setText(text)
if self.__state == State.Processing:
self.infostack.setCurrentIndex(1)