本文整理汇总了Python中calibre.gui2.dialogs.template_dialog.TemplateDialog类的典型用法代码示例。如果您正苦于以下问题:Python TemplateDialog类的具体用法?Python TemplateDialog怎么用?Python TemplateDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TemplateDialog类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_template_editor
def show_template_editor(self, *args):
view = self.gui.current_view()
if view is not self.gui.library_view:
return error_dialog(self.gui, _('No template tester available'),
_('Template tester is not available for books '
'on the device.')).exec_()
rows = view.selectionModel().selectedRows()
if not rows:
return error_dialog(self.gui, _('No books selected'),
_('One book must be selected'), show=True)
if len(rows) > 1:
return error_dialog(self.gui, _('Selected multiple books'),
_('Only one book can be selected'), show=True)
index = rows[0]
if index.isValid():
db = view.model().db
t = TemplateDialog(self.gui, self.previous_text,
mi=db.get_metadata(index.row(), index_is_id=False, get_cover=False),
text_is_placeholder=self.first_time)
t.setWindowTitle(_('Template tester'))
if t.exec_() == t.Accepted:
self.previous_text = t.rule[1]
self.first_time = False
示例2: createEditor
def createEditor(self, parent, option, index):
m = index.model()
mi = m.db.get_metadata(index.row(), index_is_id=False)
text = m.custom_columns[m.column_map[index.column()]]['display']['composite_template']
editor = TemplateDialog(parent, text, mi)
editor.setWindowTitle(_("Edit template"))
editor.textbox.setTabChangesFocus(False)
editor.textbox.setTabStopWidth(20)
d = editor.exec_()
if d:
m.setData(index, (editor.rule[1]), Qt.EditRole)
return None
示例3: change_template
def change_template(self, which):
from calibre.gui2.dialogs.template_dialog import TemplateDialog
from calibre.gui2.ui import get_gui
gui = get_gui()
if gui is None:
from calibre.ebooks.metadata.book.base import field_metadata
else:
field_metadata = gui.current_db.new_api.field_metadata
attr = which + '_template'
templ = getattr(self, attr).text()
d = TemplateDialog(self, templ, mi=self.mi, fm=field_metadata)
if d.exec_() == d.Accepted:
templ = d.rule[1]
getattr(self, attr).setText(templ)
self.emit_changed()
示例4: add_advanced
def add_advanced(self):
if self.pref_name == 'column_color_rules':
td = TemplateDialog(self, '', mi=self.mi, fm=self.fm, color_field='')
if td.exec_() == td.Accepted:
col, r = td.rule
if r and col:
idx = self.model.add_rule('color', col, r)
self.rules_view.scrollTo(idx)
self.changed.emit()
else:
td = TemplateDialog(self, '', mi=self.mi, fm=self.fm, icon_field_key='')
if td.exec_() == td.Accepted:
print(td.rule)
typ, col, r = td.rule
if typ and r and col:
idx = self.model.add_rule(typ, col, r)
self.rules_view.scrollTo(idx)
self.changed.emit()
示例5: show_template_editor
def show_template_editor(self, *args):
view = self.gui.current_view()
if view is not self.gui.library_view:
return error_dialog(self.gui, _('No template tester available'),
_('Template tester is not available for books '
'on the device.')).exec_()
rows = view.selectionModel().selectedRows()
if not rows:
return error_dialog(self.gui, _('No books selected'),
_('One book must be selected'), show=True)
if len(rows) > 1:
return error_dialog(self.gui, _('Selected multiple books'),
_('Only one book can be selected'), show=True)
index = rows[0]
if index.isValid():
db = view.model().db
t = TemplateDialog(self.gui,
_('Enter a template to test using data from the selected book'),
mi=db.get_metadata(index.row(), index_is_id=False, get_cover=False))
t.setWindowTitle(_('Template tester'))
t.exec_()
示例6: edit_template
def edit_template(self):
t = TemplateDialog(self, self.template)
t.setWindowTitle(_("Edit template"))
if t.exec_():
self.t.setText(t.rule[1])
示例7: open_editor
def open_editor(self):
t = TemplateDialog(self, self.text(), mi=self.mi)
t.setWindowTitle(_('Edit template'))
if t.exec_():
self.setText(t.rule[1])
示例8: edit_cb_title_template
def edit_cb_title_template(self):
t = TemplateDialog(self, self.opt_cover_browser_title_template.text(), fm=self.gui.current_db.field_metadata)
t.setWindowTitle(_('Edit template for caption'))
if t.exec_():
self.opt_cover_browser_title_template.setText(t.rule[1])
示例9: do_open_editor
def do_open_editor(self):
t = TemplateDialog(self, self.opt_template.text(), fm=self.field_metadata)
t.setWindowTitle(_('Edit template'))
if t.exec_():
self.opt_template.set_value(t.rule[1])