本文整理汇总了Python中PyQt5.Qt.QStringListModel.beginResetModel方法的典型用法代码示例。如果您正苦于以下问题:Python QStringListModel.beginResetModel方法的具体用法?Python QStringListModel.beginResetModel怎么用?Python QStringListModel.beginResetModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QStringListModel
的用法示例。
在下文中一共展示了QStringListModel.beginResetModel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FontFamilyDialog
# 需要导入模块: from PyQt5.Qt import QStringListModel [as 别名]
# 或者: from PyQt5.Qt.QStringListModel import beginResetModel [as 别名]
#.........这里部分代码省略.........
self.bb.accepted.connect(self.accept)
self.bb.rejected.connect(self.reject)
self.add_fonts_button = afb = self.bb.addButton(_('Add &fonts'),
self.bb.ActionRole)
afb.setIcon(QIcon(I('plus.png')))
afb.clicked.connect(self.add_fonts)
self.ml = QLabel(_('Choose a font family from the list below:'))
self.search = QLineEdit(self)
self.search.setPlaceholderText(_('Search'))
self.search.returnPressed.connect(self.find)
self.nb = QToolButton(self)
self.nb.setIcon(QIcon(I('arrow-down.png')))
self.nb.setToolTip(_('Find next'))
self.pb = QToolButton(self)
self.pb.setIcon(QIcon(I('arrow-up.png')))
self.pb.setToolTip(_('Find previous'))
self.nb.clicked.connect(self.find_next)
self.pb.clicked.connect(self.find_previous)
l.addWidget(self.ml, 0, 0, 1, 4)
l.addWidget(self.search, 1, 0, 1, 1)
l.addWidget(self.nb, 1, 1, 1, 1)
l.addWidget(self.pb, 1, 2, 1, 1)
l.addWidget(self.view, 2, 0, 1, 3)
l.addWidget(self.faces, 1, 3, 2, 1)
l.addWidget(self.bb, 3, 0, 1, 4)
l.setAlignment(self.faces, Qt.AlignTop)
self.resize(800, 600)
def set_current(self, i):
self.view.setCurrentIndex(self.m.index(i))
def keyPressEvent(self, e):
if e.key() == Qt.Key_Return:
return
return QDialog.keyPressEvent(self, e)
def find(self, backwards=False):
i = self.view.currentIndex().row()
if i < 0:
i = 0
q = icu_lower(unicode(self.search.text())).strip()
if not q:
return
r = (xrange(i-1, -1, -1) if backwards else xrange(i+1,
len(self.families)))
for j in r:
f = self.families[j]
if q in icu_lower(f):
self.set_current(j)
return
def find_next(self):
self.find()
def find_previous(self):
self.find(backwards=True)
def build_font_list(self):
try:
self.families = list(self.font_scanner.find_font_families())
except:
self.families = []
print ('WARNING: Could not load fonts')
import traceback
traceback.print_exc()
self.families.insert(0, _('None'))
self.m.setStringList(self.families)
def add_fonts(self):
families = add_fonts(self)
if not families:
return
self.font_scanner.do_scan()
self.m.beginResetModel()
self.build_font_list()
self.m.endResetModel()
self.view.setCurrentIndex(self.m.index(0))
if families:
for i, val in enumerate(self.families):
if icu_lower(val) == icu_lower(families[0]):
self.view.setCurrentIndex(self.m.index(i))
break
info_dialog(self, _('Added fonts'),
_('Added font families: %s')%(
', '.join(families)), show=True)
@property
def font_family(self):
idx = self.view.currentIndex().row()
if idx == 0:
return None
return self.families[idx]
def current_changed(self):
fam = self.font_family
self.faces.show_family(fam, self.font_scanner.fonts_for_family(fam)
if fam else None)