本文整理汇总了Python中PyQt5.Qt.QStackedWidget.count方法的典型用法代码示例。如果您正苦于以下问题:Python QStackedWidget.count方法的具体用法?Python QStackedWidget.count怎么用?Python QStackedWidget.count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QStackedWidget
的用法示例。
在下文中一共展示了QStackedWidget.count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Preferences
# 需要导入模块: from PyQt5.Qt import QStackedWidget [as 别名]
# 或者: from PyQt5.Qt.QStackedWidget import count [as 别名]
class Preferences(QDialog):
def __init__(self, gui, initial_panel=None):
QDialog.__init__(self, gui)
self.l = l = QGridLayout(self)
self.setLayout(l)
self.setWindowTitle(_('Preferences for Edit Book'))
self.setWindowIcon(QIcon(I('config.png')))
self.stacks = QStackedWidget(self)
l.addWidget(self.stacks, 0, 1, 1, 1)
self.categories_list = cl = QListWidget(self)
cl.currentRowChanged.connect(self.stacks.setCurrentIndex)
cl.clearPropertyFlags()
cl.setViewMode(cl.IconMode)
cl.setFlow(cl.TopToBottom)
cl.setMovement(cl.Static)
cl.setWrapping(False)
cl.setSpacing(15)
cl.setWordWrap(True)
l.addWidget(cl, 0, 0, 1, 1)
self.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
bb.accepted.connect(self.accept)
bb.rejected.connect(self.reject)
self.rdb = b = bb.addButton(_('Restore all defaults'), bb.ResetRole)
b.setToolTip(_('Restore defaults for all preferences'))
b.clicked.connect(self.restore_all_defaults)
self.rcdb = b = bb.addButton(_('Restore current defaults'), bb.ResetRole)
b.setToolTip(_('Restore defaults for currently displayed preferences'))
b.clicked.connect(self.restore_current_defaults)
self.rconfs = b = bb.addButton(_('Restore confirmations'), bb.ResetRole)
b.setToolTip(_('Restore all disabled confirmation prompts'))
b.clicked.connect(self.restore_confirmations)
l.addWidget(bb, 1, 0, 1, 2)
self.resize(800, 600)
geom = tprefs.get('preferences_geom', None)
if geom is not None:
self.restoreGeometry(geom)
self.keyboard_panel = ShortcutConfig(self)
self.keyboard_panel.initialize(gui.keyboard)
self.editor_panel = EditorSettings(self)
self.integration_panel = IntegrationSettings(self)
self.main_window_panel = MainWindowSettings(self)
self.preview_panel = PreviewSettings(self)
self.toolbars_panel = ToolbarSettings(self)
for name, icon, panel in [
(_('Main window'), 'page.png', 'main_window'),
(_('Editor settings'), 'modified.png', 'editor'),
(_('Preview settings'), 'viewer.png', 'preview'),
(_('Keyboard shortcuts'), 'keyboard-prefs.png', 'keyboard'),
(_('Toolbars'), 'wizard.png', 'toolbars'),
(_('Integration with calibre'), 'lt.png', 'integration'),
]:
i = QListWidgetItem(QIcon(I(icon)), name, cl)
cl.addItem(i)
self.stacks.addWidget(getattr(self, panel + '_panel'))
cl.setCurrentRow(0)
cl.item(0).setSelected(True)
w, h = cl.sizeHintForColumn(0), 0
for i in xrange(cl.count()):
h = max(h, cl.sizeHintForRow(i))
cl.item(i).setSizeHint(QSize(w, h))
cl.setMaximumWidth(cl.sizeHintForColumn(0) + 35)
cl.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
@property
def dictionaries_changed(self):
return self.editor_panel.dictionaries_changed
@property
def snippets_changed(self):
return self.editor_panel.snippets_changed
@property
def toolbars_changed(self):
return self.toolbars_panel.changed
def restore_all_defaults(self):
for i in xrange(self.stacks.count()):
w = self.stacks.widget(i)
w.restore_defaults()
def restore_current_defaults(self):
self.stacks.currentWidget().restore_defaults()
def restore_confirmations(self):
changed = 0
for key in tuple(tprefs):
if key.endswith('_again') and tprefs.get(key) is False:
del tprefs[key]
changed += 1
msg = _('There are no disabled confirmation prompts')
#.........这里部分代码省略.........