本文整理汇总了Python中PyQt5.QtGui.QStandardItem.setText方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItem.setText方法的具体用法?Python QStandardItem.setText怎么用?Python QStandardItem.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QStandardItem
的用法示例。
在下文中一共展示了QStandardItem.setText方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prev_track
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setText [as 别名]
def prev_track(self):
previous_track = self.recentTrackListModel.takeItem(0)
if previous_track is not None or previous_track is not "":
try:
location = previous_track.data(1)
try:
self.player.stop_item()
print(self.player.get_item())
playing_track = self.player.get_item()
playing_meta = self.meta_info(playing_track)
item = QStandardItem(playing_track)
item.setFlags(item.flags() & ~QtCore.Qt.ItemIsDropEnabled) # This is necessary to drag'n'drop within QueueList
item.setText(playing_meta)
item.setData(playing_track, 1)
self.queueTrackListModel.insertRow(0, item)
print("goes back one step..")
except FileNotFoundError:
print("no current track..")
self.player.set_item(location)
print("loaded: " + self.player.get_item())
self.meta_info(location, active=True)
self.recentTrackListModel.removeRow(0)
print(previous_track.data(0) + " taken back from recent.")
self.play_track()
except AttributeError:
print("nope")
elif previous_track is None or previous_track is "":
print("there's no track - cannot go backwards")
示例2: current_to_recent
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setText [as 别名]
def current_to_recent(self):
track = self.player.get_item()
if track is not "":
item = QStandardItem(track)
track_meta = self.meta_info(track)
item.setText(track_meta)
item.setData(track, 1)
self.recentTrackListModel.insertRow(0, item)
示例3: _show_list
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setText [as 别名]
def _show_list(self, parent, mylist, vtype):
for idx, val in enumerate(mylist):
name_item = QStandardItem(str(idx))
vitem = QStandardItem()
vitem.setText(val_to_string(val))
vitem.setData(ListData(mylist, idx, val, vtype), Qt.UserRole)
row = [name_item, vitem, QStandardItem(vtype.name)]
parent.appendRow(row)
if vtype == ua.VariantType.ExtensionObject:
self._show_ext_obj(name_item, val)
示例4: process_track
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setText [as 别名]
def process_track(self, track):
with lock:
start_single = time.time()
item = QStandardItem(track)
item.setFlags(item.flags() & ~QtCore.Qt.ItemIsDropEnabled) # This is necessary to drag'n'drop within QueueList
track_info = self.meta_info(track)
item.setText(track_info)
item.setData(track, 1)
self.queueTrackListModel.appendRow(item)
stop_single = time.time() - start_single
print("queued:", os.path.basename(item.data(0)), "(" + str(stop_single.__round__(5)) + ")" + " --- " + threading.current_thread().name)
if self.player.status is None:
self.get_next_track()
示例5: setup_table
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setText [as 别名]
def setup_table(self, rela):
# Table model
model = QStandardItemModel()
self.table.setModel(model)
# Set header
model.setHorizontalHeaderLabels(rela.header)
# Populate table
for row_count, row in enumerate(rela.content):
for col_count, data in enumerate(row):
item = QStandardItem()
item.setText(data)
item.setToolTip(data)
model.setItem(row_count, col_count, item)
示例6: _show_val
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setText [as 别名]
def _show_val(self, parent, obj, name, val, vtype):
name_item = QStandardItem(name)
vitem = QStandardItem()
vitem.setText(val_to_string(val))
vitem.setData(MemberData(obj, name, val, vtype), Qt.UserRole)
row = [name_item, vitem, QStandardItem(vtype.name)]
# if we have a list or extension object we display children
if isinstance(val, list):
row[2].setText("List of " + vtype.name)
self._show_list(name_item, val, vtype)
elif vtype == ua.VariantType.ExtensionObject:
self._show_ext_obj(name_item, val)
parent.appendRow(row)
return row
示例7: getPhotos
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setText [as 别名]
def getPhotos(self):
if not self.logged_in:
self.login()
photos = []
tphotos = []
bar = QProgressDialog("Getting Photos", "Stop", 0, 10)
bar.setWindowTitle("Downloading from Flickr")
bar.setWindowModality(Qt.WindowModal)
bar.setValue(0)
photos = self.flickr.get_recent_photos(self.current_page)
bar.show()
if DEBUG:
print(photos)
prg = 0
for pid, title in photos:
if bar.wasCanceled():
return
turl = self.flickr.get_thumbnail_url(pid)
murl = self.flickr.get_medium_url(pid)
lurl = self.flickr.get_link_url(pid)
if DEBUG: print(turl)
p = Photo()
p.thumb_url = turl
p.medium_url = murl
p.link = lurl
p.thumb = urllib.request.urlopen(turl).read()
p.title = title
tphotos.append(p)
prg += 1
bar.setValue(prg)
self.current_page += 1
for p in tphotos:
self.photos.append(p)
item = QStandardItem()
item.setText(p.title)
self.photos_model.appendRow(item)
示例8: expand
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setText [as 别名]
def expand(parent_item, name, dw):
QApplication.processEvents()
if 'c' in dw:
if name == None:
name_item = parent_item
size_item = None
else:
name_item = QStandardItem(name)
name_item.setData(folder_icon, Qt.DecorationRole)
name_item.setData(ITEM_TYPE_DIRECTORY, USER_ROLE_ITEM_TYPE)
name_item.setData(int(dw['p']), USER_ROLE_PERMISSIONS)
size_item = QStandardItem('')
last_modified_item = create_last_modified_item(int(dw['l']))
parent_item.appendRow([name_item, size_item, last_modified_item])
size = 0
for child_name, child_dw in dw['c'].items():
size += expand(name_item, child_name, child_dw)
if size_item != None:
size_item.setText(get_file_display_size(size))
size_item.setData(size, USER_ROLE_SIZE)
return size
else:
name_item = QStandardItem(name)
name_item.setData(file_icon, Qt.DecorationRole)
name_item.setData(ITEM_TYPE_FILE, USER_ROLE_ITEM_TYPE)
name_item.setData(int(dw['p']), USER_ROLE_PERMISSIONS)
size = int(dw['s'])
size_item = QStandardItem(get_file_display_size(size))
size_item.setData(size, USER_ROLE_SIZE)
last_modified_item = create_last_modified_item(int(dw['l']))
parent_item.appendRow([name_item, size_item, last_modified_item])
return size
示例9: loadItem
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setText [as 别名]
def loadItem(root, mdl, parent=QModelIndex()):
for row in root:
r = int(row.attrib["row"])
for col in row:
c = int(col.attrib["col"])
item = mdl.itemFromIndex(mdl.index(r, c, parent))
if not item:
item = QStandardItem()
mdl.itemFromIndex(parent).setChild(r, c, item)
if col.text:
#mdl.setData(mdl.index(r, c, parent), col.text)
item.setText(col.text)
if "color" in col.attrib:
#mdl.itemFromIndex(mdl.index(r, c, parent)).setIcon(iconFromColorString(col.attrib["color"]))
item.setIcon(iconFromColorString(col.attrib["color"]))
if len(col) != 0:
#loadItem(col, mdl, mdl.index(r, c, parent))
loadItem(col, mdl, mdl.indexFromItem(item))
示例10: __init__
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setText [as 别名]
def __init__(self, font, parent=None):
super().__init__(parent, name="OS/2")
# OS2Group = QGroupBox("OS/2 table", self)
# OS2Group.setFlat(True)
OS2Layout = QGridLayout(self)
usWidthClassLabel = QLabel("usWidthClass:", self)
self.usWidthClassDrop = QComboBox(self)
items = [
"None", "Ultra-condensed", "Extra-condensed", "Condensed",
"Semi-Condensed", "Medium (normal)", "Semi-expanded", "Expanded",
"Extra-expanded", "Ultra-expanded"]
self.usWidthClassDrop.insertItems(0, items)
if font.info.openTypeOS2WidthClass is not None:
self.usWidthClassDrop.setCurrentIndex(
font.info.openTypeOS2WidthClass)
fsSelectionLabel = QLabel("fsSelection:", self)
fsSelection = font.info.openTypeOS2Selection
self.fsSelectionList = QListView(self)
items = [
"1 UNDERSCORE", "2 NEGATIVE", "3 OUTLINED", "4 STRIKEOUT",
"7 USE_TYPO_METRICS", "8 WWS", "9 OBLIQUE"]
# http://stackoverflow.com/a/26613163
model = QStandardItemModel(7, 1)
for index, elem in enumerate(items):
item = QStandardItem()
item.setText(elem)
item.setCheckable(True)
bit = index + 1
if fsSelection is not None and bit in fsSelection:
# maybe default setting? if so, unneeded
item.setCheckState(Qt.Checked)
else:
item.setCheckState(Qt.Unchecked)
model.setItem(index, item)
self.fsSelectionList.setModel(model)
achVendorIDLabel = QLabel("achVendorID:", self)
self.achVendorIDEdit = QLineEdit(font.info.openTypeOS2VendorID, self)
self.achVendorIDEdit.setMaxLength(4)
fsTypeLabel = QLabel("fsType:", self)
fsType = font.info.openTypeOS2Type
self.fsTypeDrop = QComboBox(self)
items = [
"No embedding restrictions", "Restricted embedding",
"Preview and print embedding allowed",
"Editable embedding allowed"]
self.allowSubsettingBox = QCheckBox("Allow subsetting", self)
self.allowBitmapEmbeddingBox = QCheckBox(
"Allow only bitmap embedding", self)
self.fsTypeDrop.currentIndexChanged[int].connect(
self._updateFsTypeVisibility)
self.fsTypeDrop.insertItems(0, items)
if fsType is not None:
for i in range(1, 4):
if i in fsType:
self.fsTypeDrop.setCurrentIndex(i)
break
self.allowSubsettingBox.setChecked(8 not in fsType)
self.allowBitmapEmbeddingBox.setChecked(9 in fsType)
# XXX: ulUnicodeRange
# XXX: ulCodePageRange
sTypoAscenderLabel = QLabel("sTypoAscender:", self)
sTypoDescenderLabel = QLabel("sTypoDescender:", self)
sTypoLineGapLabel = QLabel("sTypoLineGap:", self)
usWeightClassLabel = QLabel("usWeightClass:", self)
usWinAscentLabel = QLabel("usWinAscent:", self)
usWinDescentLabel = QLabel("usWinDescent:", self)
ySubscriptXSizeLabel = QLabel("ySubscriptXSize:", self)
ySubscriptYSizeLabel = QLabel("ySubscriptYSize:", self)
ySubscriptXOffsetLabel = QLabel("ySubscriptXOffset:", self)
ySubscriptYOffsetLabel = QLabel("ySubscriptYOffset:", self)
ySuperscriptXSizeLabel = QLabel("ySuperscriptXSize:", self)
ySuperscriptYSizeLabel = QLabel("ySuperscriptYSize:", self)
ySuperscriptXOffsetLabel = QLabel("ySuperscriptXOffset:", self)
ySuperscriptYOffsetLabel = QLabel("ySuperscriptYOffset:", self)
yStrikeoutSizeLabel = QLabel("yStrikeoutSize:", self)
yStrikeoutPositionLabel = QLabel("yStrikeoutPosition:", self)
self.loadPositiveInteger(
font, "openTypeOS2WeightClass", "usWeightClass")
self.loadInteger(font, "openTypeOS2TypoAscender", "sTypoAscender")
self.loadInteger(font, "openTypeOS2TypoDescender", "sTypoDescender")
self.loadInteger(font, "openTypeOS2TypoLineGap", "sTypoLineGap")
self.loadPositiveInteger(font, "openTypeOS2WinAscent", "usWinAscent")
self.loadPositiveInteger(font, "openTypeOS2WinDescent", "usWinDescent")
self.loadInteger(font, "openTypeOS2SubscriptXSize", "ySubscriptXSize")
self.loadInteger(font, "openTypeOS2SubscriptYSize", "ySubscriptYSize")
self.loadInteger(
font, "openTypeOS2SubscriptXOffset", "ySubscriptXOffset")
self.loadInteger(
font, "openTypeOS2SubscriptYOffset", "ySubscriptYOffset")
self.loadInteger(
font, "openTypeOS2SuperscriptXSize", "ySuperscriptXSize")
self.loadInteger(
#.........这里部分代码省略.........
示例11: populate
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setText [as 别名]
def populate(self):
"""Populate the tree view with data from the installed extensions.
"""
# TODO/Question:
# Would it make sense to move this to a dedicated model class
# complementing the FailedModel?
root = self.tree.model().invisibleRootItem()
extensions = app.extensions()
for ext in extensions.installed_extensions():
ext_infos = extensions.infos(ext)
display_name = ext_infos.get(ext, ext) if ext_infos else ext.name()
loaded_extension = extensions.get(ext)
if loaded_extension:
display_name += ' ({})'.format(loaded_extension.load_time())
name_item = QStandardItem(display_name)
name_item.extension_name = ext
name_item.setCheckable(True)
self.name_items[ext] = name_item
icon = extensions.icon(ext)
if icon:
name_item.setIcon(icon)
root.appendRow([name_item])
for entry in [
'extension-name',
'short-description',
'description',
'version',
'api-version',
'dependencies',
'maintainers',
'repository',
'website',
'license'
]:
label_item = QStandardItem('{}:'.format(
self.config_labels[entry]))
label_item.setTextAlignment(Qt.AlignTop)
bold = QFont()
bold.setWeight(QFont.Bold)
label_item.setFont(bold)
details = ext_infos.get(entry, "") if ext_infos else ""
if type(details) == list:
details = '\n'.join(details)
details_item = QStandardItem(details)
details_item.setTextAlignment(Qt.AlignTop)
if entry == 'api-version':
# Check for correct(ly formatted) api-version entry
# and highlight it in case of mismatch
api_version = appinfo.extension_api
if not details:
details_item.setFont(bold)
details_item.setText(
_("Misformat: {api}").format(details))
elif not details == api_version:
details_item.setFont(bold)
details_item.setText('{} ({}: {})'.format(
details,
appinfo.appname,
api_version))
name_item.appendRow([label_item, details_item])
示例12: create_new_list_item
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setText [as 别名]
def create_new_list_item(text):
item = QStandardItem()
item.setText(text)
item.setCheckable(True)
item.setEditable(False)
return item
示例13: populate
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setText [as 别名]
def populate(self, data):
"""Populate the data model using the data passed
from the extensions object.
The data model has up to three root-level items:
- Invalid metadata
- Failed to load
- Failed dependencies
"""
# font for use in various Items
bold = QFont()
bold.setWeight(QFont.Bold)
root = self.invisibleRootItem()
infos = data['infos']
if infos:
# Handle extensions with metadata errors
infos_item = QStandardItem()
infos_item.setFont(bold)
infos_item.setText(_("Invalid metadata:"))
infos_tooltip = (
_("Extensions whose extension.cnf file has errors.\n"
"They will be loaded nevertheless."))
infos_item.setToolTip(infos_tooltip)
root.appendRow(infos_item)
for info in infos:
name_item = QStandardItem(info)
name_item.setToolTip(infos_tooltip)
icon = self.extensions.icon(info)
if icon:
name_item.setIcon(icon)
details_item = QStandardItem(infos[info])
details_item.setToolTip(infos_tooltip)
infos_item.appendRow([name_item, details_item])
exceptions = data['exceptions']
if exceptions:
# Handle extensions that failed to load properly
import traceback
exceptions_item = self.exceptions_item = QStandardItem()
exceptions_item.setFont(bold)
exceptions_item.setText(_("Failed to load:"))
extensions_tooltip = (
_("Extensions that failed to load properly.\n"
"Double click on name to show the stacktrace.\n"
"Please contact the extension maintainer."))
exceptions_item.setToolTip(extensions_tooltip)
root.appendRow(exceptions_item)
for ext in exceptions:
extension_info = self.extensions.infos(ext)
name = (extension_info.get('extension-name', ext)
if extension_info
else ext)
name_item = QStandardItem(name)
name_item.setToolTip(extensions_tooltip)
icon = self.extensions.icon(ext)
if icon:
name_item.setIcon(icon)
exc_info = exceptions[ext]
# store exception information in the first item
name_item.exception_info = exc_info
message = '{}: {}'.format(exc_info[0].__name__, exc_info[1])
details_item = QStandardItem(message)
details_item.setToolTip(extensions_tooltip)
exceptions_item.appendRow([name_item, details_item])
dependencies = data['dependencies']
if dependencies:
# Handle extensions with dependency issues
dep_item = QStandardItem(_("Failed dependencies:"))
dep_item.setFont(bold)
dep_tooltip = (
_("Extensions with failed or circular dependencies.\n"
"They are not loaded."))
dep_item.setToolTip(dep_tooltip)
root.appendRow(dep_item)
missing = dependencies.get('missing', None)
if missing:
missing_item = QStandardItem(_("Missing:"))
missing_item.setFont(bold)
missing_item.setToolTip(dep_tooltip)
dep_item.appendRow(missing_item)
for m in missing:
item = QStandardItem(m)
item.setToolTip(dep_item)
missing_item.appendRow(item)
inactive = dependencies.get('inactive', None)
if inactive:
inactive_item = QStandardItem(_("Inactive:"))
inactive_item.setFont(bold)
inactive_item.setToolTip(dep_tooltip)
dep_item.appendRow(inactive_item)
for i in inactive:
item = QStandardItem(i)
item.setToolTip(dep_tooltip)
inactive_item.appendRow(item)
#.........这里部分代码省略.........