本文整理匯總了Python中template.Template方法的典型用法代碼示例。如果您正苦於以下問題:Python template.Template方法的具體用法?Python template.Template怎麽用?Python template.Template使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類template
的用法示例。
在下文中一共展示了template.Template方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: save_app_as
# 需要導入模塊: import template [as 別名]
# 或者: from template import Template [as 別名]
def save_app_as(self):
"saves a wxGlade project onto an xml file chosen by the user"
# both flags occurs several times
fn = wx.FileSelector( _("Save project as..."),
wildcard="wxGlade files (*.wxg)|*.wxg|wxGlade Template files (*.wgt) |*.wgt|"
"XML files (*.xml)|*.xml|All files|*",
flags=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT,
default_filename=common.root.filename or (self.cur_dir+os.sep+"wxglade.wxg"))
if not fn: return
# check for file extension and add default extension if missing
ext = os.path.splitext(fn)[1].lower()
if not ext:
fn = "%s.wxg" % fn
common.root.filename = fn
#remove the template flag so we can save the file.
common.root.properties["is_template"].set(False)
self.save_app()
self.cur_dir = os.path.dirname(fn)
self.file_history.AddFileToHistory(fn)
示例2: open_app
# 需要導入模塊: import template [as 別名]
# 或者: from template import Template [as 別名]
def open_app(self, event=None):
"""loads a wxGlade project from an xml file
NOTE: this is very slow and needs optimisation efforts
NOTE2: the note above should not be True anymore :) """
if not self.ask_save():
return
default_path = os.path.dirname(common.root.filename or "") or self.cur_dir
infile = wx.FileSelector(_("Open file"),
wildcard="wxGlade files (*.wxg)|*.wxg|wxGlade Template files (*.wgt)|*.wgt|"
"XML files (*.xml)|*.xml|All files|*",
flags=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST, default_path=default_path)
if not infile: return
self._open(infile)
示例3: manage_templates
# 需要導入模塊: import template [as 別名]
# 或者: from template import Template [as 別名]
def manage_templates(self):
to_edit = template.manage_templates()
if to_edit is not None and self.ask_save():
# edit the template
# TODO, you still need to save it manually...
self._open_app(to_edit, add_to_history=False)
wx.MessageBox( _("To save the changes to the template, edit the GUI as usual,\n"
"and then click File->Save As Template..."),
_("Information"), style=wx.OK|wx.ICON_INFORMATION )
####################################################################################################################
# user interface helpers