本文整理匯總了Python中Project.Project.needSave方法的典型用法代碼示例。如果您正苦於以下問題:Python Project.needSave方法的具體用法?Python Project.needSave怎麽用?Python Project.needSave使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Project.Project
的用法示例。
在下文中一共展示了Project.needSave方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: MyFrame
# 需要導入模塊: from Project import Project [as 別名]
# 或者: from Project.Project import needSave [as 別名]
#.........這裏部分代碼省略.........
grid_sizer_3.Add(self.search_outpath, 0, 0, 0)
grid_sizer_3.Add(self.label_temppath, 0, wx.ALIGN_CENTER_VERTICAL, 0)
grid_sizer_3.Add(self.input_temppath, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL, 0)
grid_sizer_3.Add(self.search_temppath, 0, 0, 0)
grid_sizer_3.AddGrowableCol(1)
grid_sizer_2.Add(grid_sizer_3, 1, wx.EXPAND, 0)
grid_sizer_2.Add(self.sl2, 0, wx.EXPAND, 0)
grid_sizer_2.Add(self.radiobox_saveas, 0, 0, 0)
grid_sizer_4.Add(self.checkbox_debug, 0, 0, 0)
grid_sizer_4.Add(self.checkbox_unicode, 0, 0, 0)
grid_sizer_2.Add(grid_sizer_4, 1, wx.EXPAND, 0)
grid_sizer_2.Add(self.sl3, 0, wx.EXPAND, 0)
grid_sizer_2.Add(self.bitmap_start, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
grid_sizer_2.Add(self.sl4, 0, wx.EXPAND, 0)
grid_sizer_2.Add(self.label_log, 0, 0, 0)
grid_sizer_2.Add(self.list_log, 0, wx.EXPAND, 0)
self.nb_pane_2.SetSizer(grid_sizer_2)
grid_sizer_2.AddGrowableRow(8)
grid_sizer_2.AddGrowableCol(0)
self.nb.AddPage(self.nb_panel_1, "Project")
self.nb.AddPage(self.nb_pane_2, "Build")
main_sizer.Add(self.nb, 1, wx.EXPAND, 0)
main_sizer.Add((20, 20), 0, 0, 0)
main_sizer.Add((20, 20), 0, 0, 0)
main_sizer.Add((20, 20), 0, 0, 0)
main_sizer.Add((20, 20), 0, 0, 0)
self.SetSizer(main_sizer)
main_sizer.Fit(self)
main_sizer.AddGrowableRow(1)
main_sizer.AddGrowableCol(1)
self.Layout()
def askForSavingIfNeed(self):
if (self.path == None or self.project.needSave(self)) and not self.project.isEmpty(self):
res = wx.MessageDialog(self, "Do you want to save this project?", "Save?", wx.ICON_QUESTION | wx.YES_NO | wx.CANCEL | wx.YES_DEFAULT).ShowModal()
if res == wx.ID_CANCEL:
return False
elif res == wx.ID_YES:
self.save(None)
return True
def new(self, event):
if self.askForSavingIfNeed():
self.project = Project()
self.project.loadAllhiddenmodules(self)
self.project.initialFrame(self)
self.path = None
def open(self, event=None, path=None):
if self.askForSavingIfNeed():
if path == None:
dia = wx.FileDialog(self, "Select a file to open", wildcard="PySaved-files (*.pysa)|*.pysa", style=wx.FD_OPEN)
if dia.ShowModal() == wx.ID_OK:
path = dia.GetPath()
else: return
try:
print(u"Loading project from: '{0}'".format(path))
p = Project()
p.load(self, path)
self.project = p
self.project.loadAllhiddenmodules(self)
self.path = path
except:
wx.MessageDialog(self, u"Cannot open file: '{0}'".format(path), "Cannot open file", wx.ICON_ERROR).ShowModal()