我们从Python开源项目中,提取了以下18个代码示例,用于说明如何使用wx.FD_OVERWRITE_PROMPT。
def saveCap(self): cap = self.src.getEEGSecs(self.getSessionTime(), filter=False) saveDialog = wx.FileDialog(self, message='Save EEG data.', wildcard='Pickle (*.pkl)|*.pkl|All Files|*', style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) try: if saveDialog.ShowModal() == wx.ID_CANCEL: return cap.saveFile(saveDialog.GetPath()) except Exception: wx.LogError('Save failed!') raise finally: saveDialog.Destroy()
def saveMessages(self, event=None): """Save the message log to file. """ saveDialog = wx.FileDialog(self.scrolledPanel, message='Save Message Log', wildcard='Text Files (*.txt)|*.txt|All Files|*', style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) try: if saveDialog.ShowModal() == wx.ID_CANCEL: return with open(saveDialog.GetPath(), 'w') as fileHandle: fileHandle.write(self.messageArea.GetValue()) except Exception as e: wx.LogError('Save failed!') raise finally: saveDialog.Destroy()
def stopRecording(self): if self.recordingTime is not None: secsToSave = time.time() - self.recordingTime wx.LogMessage('Page %s saving %f secs of EEG' % (self.name, secsToSave)) cap = self.src.getEEGSecs(secsToSave, filter=False) saveDialog = wx.FileDialog(self, message='Save EEG data.', wildcard='Pickle (*.pkl)|*.pkl|All Files|*', style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) try: if saveDialog.ShowModal() != wx.ID_CANCEL: cap.saveFile(saveDialog.GetPath()) except Exception as e: wx.LogError('Save failed!') raise finally: saveDialog.Destroy() self.recordButton.SetLabel('Start Recording') self.recordingTime = None
def on_save_as(self): if self.get_project_filename(): dir_name, file_name = os.path.split(self.get_project_filename()) style = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT wildcard = "Arquivo de projeto do GRIPy (*.pgg)|*.pgg" fdlg = wx.FileDialog(self.GetTopWindow(), 'Escolha o arquivo PGG', #dir_name, file_name, wildcard=wildcard, style=style ) if fdlg.ShowModal() == wx.ID_OK: file_name = fdlg.GetFilename() dir_name = fdlg.GetDirectory() if not file_name.endswith('.pgg'): file_name += '.pgg' disableAll = wx.WindowDisabler() wait = wx.BusyInfo("Saving GriPy project. Wait...") self.save_project_data(os.path.join(dir_name, file_name)) del wait del disableAll fdlg.Destroy()
def OnButtonSaveAs(self, msg): if not self.model.status: wx.MessageBox('No export file has been successfully loaded yet!') return dialog = wx.FileDialog( self, 'Save As ...', style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) result = dialog.ShowModal() if result != wx.ID_OK: return # Show filedialog and get value self.model.save(dialog.GetPath())
def saveResultText(self, resultText): saveDialog = wx.FileDialog(self, message='Save Result Text.', wildcard='Text (*.txt)|*.txt|All Files|*', style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) try: if saveDialog.ShowModal() == wx.ID_CANCEL: return with open(saveDialog.GetPath(), 'w') as fd: fd.write(resultText) except Exception: wx.LogError('Save failed!') raise finally: saveDialog.Destroy()
def saveCap(self): cap = self.src.getEEGSecs(self.getSessionTime(), filter=False) saveDialog = wx.FileDialog(self, message='Save EEG data.', wildcard='Pickle (*.pkl)|*.pkl|All Files|*', style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) try: if saveDialog.ShowModal() == wx.ID_CANCEL: return cap.saveFile(saveDialog.GetPath()) except Exception: wx.LogError('Save failed!') raise finally: saveDialog.Destroy() ##def decimate(self, cap): ## #cap = cap.demean().bandpass(0.5, 10.0, order=3) ## cap = cap.copy().demean().bandpass(0.5, 12.0, order=3) ## # kind of a hack XXX - idfah ## if cap.getSampRate() > 32.0: ## decimationFactor = int(np.round(cap.getSampRate()/32.0)) ## cap = cap.downsample(decimationFactor) ## return cap
def saveResultText(self, resultText): saveDialog = wx.FileDialog(self, message='Save Result Text.', wildcard='Text (*.txt)|*.txt|All Files|*', style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) try: if saveDialog.ShowModal() == wx.ID_CANCEL: return with open(saveDialog.GetPath(), 'w') as fd: fd.write(resultText) except Exception: wx.LogError('Save failed!') raise finally: saveDialog.Destroy() #def decimate(self, cap): # #cap = cap.demean().bandpass(0.5, 20.0, order=3) # # original # #cap = cap.copy().demean().bandpass(0.5, 12.0, order=3) # # biosemi hack XXX - idfah # cap = cap.copy().demean().reference((36,37)).deleteChans(range(32,40)) # cap.keepChans(('Fz', 'Cz', 'P3', 'Pz', 'P4', 'P7', 'Oz', 'P8')) # # kind of a hack XXX - idfah # if cap.getSampRate() > 32.0: # decimationFactor = int(np.round(cap.getSampRate()/32.0)) # cap = cap.downsample(decimationFactor) # return cap
def OnSave(self,e): panelphase = self.GetChildren()[1].GetPage(0) if panelphase.pipeline_started == False: cwd = self.CurrentWD() if IsNotWX4(): dlg = wx.FileDialog(self, "Choose a file", cwd, "", "fin files (*.fin)|*.fin|All files (*.*)|*.*", wx.SAVE | wx.OVERWRITE_PROMPT) else: dlg = wx.FileDialog(self, "Choose a file", cwd, "", "fin files (*.fin)|*.fin|All files (*.*)|*.*", wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) if dlg.ShowModal() == wx.ID_OK: self.filename=dlg.GetFilename() self.dirname=dlg.GetDirectory() SaveInstance(self) dlg.Destroy()
def save(self, e): if not hasattr(self, "brackets"): errortext = "Make bracket before doing that" w = wx.MessageDialog(self.parent, errortext, "Error", wx.ICON_ERROR) w.ShowModal() w.Destroy() return dia = wx.FileDialog(self, "Save Bracket", "", self.sname, "bp5000 bracket|*.bp5", wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) if dia.ShowModal() == wx.ID_CANCEL: return bracketio.write_bracket(dia.GetPath(), self.brackets)
def save_file(self, event): '''??????????? ''' wildcard = "Text Files (*.txt)|*.txt|" "All files (*.*)|*.*" dlg = wx.FileDialog(None, u"???????", os.getcwd(), defaultFile="", style=wx.FD_SAVE, # |wx.FD_OVERWRITE_PROMPT wildcard=wildcard ) if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetPath() with open(filename, 'w', encoding='utf-8') as f: f.write(self.t1.GetValue()) # ??????????????
def get_con_xml_path(self): style = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT dialog = wx.FileDialog(self, message='Save connections.xml',defaultFile='connections.xml', wildcard='connections.xml|connections.xml', style=style) if dialog.ShowModal() == wx.ID_OK: path = dialog.GetPath() else: path = None dialog.Destroy() return path
def onSaveFileAs(self, evt): style = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT wildcard = "Arquivo de console GRIPy (*.gripy_console)|*.gripy_console" fdlg = wx.FileDialog(self, 'Escolha o arquivo gripy_console', defaultDir=self.dir_name, wildcard=wildcard, style=style ) if fdlg.ShowModal() == wx.ID_OK: self.file_name = fdlg.GetFilename() self.dir_name = fdlg.GetDirectory() self._do_save() fdlg.Destroy()
def OnCreateSnippet(self,event): openFileDialog = wx.FileDialog(self, "Save i3 Colour snippet file", os.path.expanduser("~/.i3/"), "","i3 Colour snippet file |*", wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) if openFileDialog.ShowModal() == wx.ID_CANCEL: return open(openFileDialog.GetPath(), 'w').close() self.config.updateConfig(openFileDialog.GetPath()) os.system("rm '"+openFileDialog.GetPath()+"'") os.system("mv '/tmp/i3tmpconf' '"+openFileDialog.GetPath()+"'")