本文整理汇总了Python中AnyQt.QtGui.QStandardItemModel.moveToThread方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItemModel.moveToThread方法的具体用法?Python QStandardItemModel.moveToThread怎么用?Python QStandardItemModel.moveToThread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QStandardItemModel
的用法示例。
在下文中一共展示了QStandardItemModel.moveToThread方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_gds_model
# 需要导入模块: from AnyQt.QtGui import QStandardItemModel [as 别名]
# 或者: from AnyQt.QtGui.QStandardItemModel import moveToThread [as 别名]
def get_gds_model(progress=lambda val: None):
"""
Initialize and return a GDS datasets model.
:param progress: A progress callback.
:rval tuple:
A tuple of (QStandardItemModel, geo.GDSInfo, [geo.GDS])
.. note::
The returned QStandardItemModel's thread affinity is set to
the GUI thread.
"""
progress(1)
info = geo.GDSInfo()
search_keys = ["dataset_id", "title", "platform_organism", "description"]
cache_dir = serverfiles.localpath(geo.DOMAIN)
gds_link = "http://www.ncbi.nlm.nih.gov/sites/GDSbrowser?acc={0}"
pm_link = "http://www.ncbi.nlm.nih.gov/pubmed/{0}"
gds_list = []
def is_cached(gds):
return os.path.exists(os.path.join(cache_dir, gds["dataset_id"]) +
".soft.gz")
def item(displayvalue, item_values={}):
item = QStandardItem()
item.setData(displayvalue, Qt.DisplayRole)
for role, value in item_values.items():
item.setData(value, role)
return item
def gds_to_row(gds):
#: Text for easier full search.
search_text = " | ".join([gds.get(key, "").lower()
for key in search_keys])
row = [
item(" " if is_cached(gds) else "",
{TextFilterRole: search_text}),
item(gds["dataset_id"],
{LinkRole: gds_link.format(gds["dataset_id"])}),
item(gds["title"]),
item(gds["platform_organism"]),
item(len(gds["samples"])),
item(gds["feature_count"]),
item(gds["gene_count"]),
item(len(gds["subsets"])),
item(gds.get("pubmed_id", ""),
{LinkRole: pm_link.format(gds["pubmed_id"])
if gds.get("pubmed_id")
else None})
]
return row
model = QStandardItemModel()
model.setHorizontalHeaderLabels(
["", "ID", "Title", "Organism", "Samples", "Features",
"Genes", "Subsets", "PubMedID"]
)
progress(20)
for gds in info.values():
model.appendRow(gds_to_row(gds))
gds_list.append(gds)
progress(50)
if QThread.currentThread() is not QCoreApplication.instance().thread():
model.moveToThread(QCoreApplication.instance().thread())
return model, info, gds_list