def onHtml(self, event): content = f"""<html> <head> <meta charset='utf-8'> <title>{self.Parent.title}</title> </head> <body> """ description = self.contentBox.Strings url = re.compile(r"((?:\w+://|www\.)[^ ,.?!#%=+][^ ][^ \r]*)") for line in range(len(description)): match = url.search(description[line]) if match is not None: description[ line] = f'<a href="{match.group()}">{match.group()}</a>' description = "<br \>\n".join(description) content += f"""<h1>{self.Parent.title}</h1> <p>{description}</p> </body> </html>""" path = wx.SaveFileSelector("", ".html", self.Parent.title, parent=self) if not path == "": with open(path, "w", encoding="utf-8") as file: file.write(content) self.contentBox.SetFocus()
def SaveMedia(self, ID=False): busy = wx.BusyCursor() listboxid = self.listbox.GetSelection() mediaid = self.listbox.htmllist[listboxid][0] filename = self.listbox.htmllist[listboxid][3] action = "SELECT Content FROM media WHERE ID = " + str(mediaid) results = db.SendSQL(action, self.localsettings.dbconnection) output = base64.decodestring(str(results[0][0])) if filename.__contains__("."): fileextension = filename.split(".")[-1] else: fileextension = "" targetfile = wx.SaveFileSelector(fileextension.upper(), fileextension, filename) out = open(targetfile, "wb") out.write(output) out.close() del busy
def on_save_as_menu(self, event): active_child = self.get_active_child() if active_child is not None: file_path = wx.SaveFileSelector(u"Uložit jako", u"TXT formát (*.txt)|*.txt|Dummy formát text (*.html)|*.html") if file_path: active_child.m_text_editor.SaveFile(file_path) active_child.m_text_editor.SetFilename(file_path) active_child.SetTitle(os.path.basename(file_path))
def OnBSavePointsButton(self, event): fn = wx.SaveFileSelector('Save point positions to file', '.txt') if fn is None: print('No file selected') return #self.points = pylab.load(fn) pylab.save(fn, scipy.array(self.points))
def OnBSavePointsButton(self, event): fn = wx.SaveFileSelector('Save point positions to file', '.txt') if fn is None: logger.warning('No file selected, cancelling') return #self.points = pylab.load(fn) # pylab.save(fn, scipy.array(self.points)) np.savetxt(fn, scipy.array(self.points))
def OnExportChannels(self, event: wx.CommandEvent) -> None: """Save all channels to a file.""" filepath = wx.SaveFileSelector('Select file to export', '') if not filepath: return try: cockpit.interfaces.channels.SaveToFile(filepath, wx.GetApp().Channels) except: cockpit.gui.ExceptionBox('Failed to write to \'%s\'' % filepath)
def OnSave(self, event): filename = wx.SaveFileSelector("Annotations", "*", "", self) if filename: try: element = medipy.io.image_annotation.annotations_to_xml( self.image.annotations) with open(filename, "w") as f: f.write(xml.etree.ElementTree.tostring(element)) except medipy.base, e: wx.MessageBox("Cannot save file : {0}".format(e), "Cannot save annotations", wx.OK, self)
def OnExportChannels(self, event: wx.CommandEvent) -> None: """Save all channels to a file.""" filepath = wx.SaveFileSelector('Select file to export', '', parent=self) if not filepath: return try: with open(filepath, 'w') as fh: json.dump(self._channels, fh) except: cockpit.gui.ExceptionBox('Failed to write to \'%s\'' % filepath, parent=self)
def OnSave(self, event): filename = wx.SaveFileSelector( "Save data as ...", 'HDF (*.hdf)|*.hdf|Comma separated text (*.csv)|*.csv') if not filename == '': if isinstance(self.data, tabular.TabularBase): data = self.data else: data = tabular.RecArraySource(self.data) if filename.endswith('.hdf'): data.to_hdf(filename) else: data.to_csv(filename)
def on_save_data(self, event): file_path = wx.SaveFileSelector(what='Where to save', extension='.dat', default_name=self.param_panel.get_project_name(), parent=self) if not file_path: return file_dir = os.path.dirname(file_path) file_name = os.path.basename(file_path) name, ext = os.path.splitext(file_name) self.img_panel.save_data(file_dir, name) # todo: save temperature to file self.param_panel.set_project_name(name)
def _on_generate(self, event): """Generate a new keypair.""" # Some language-dependent text generate_saver_what = self._text['generate_saver_what'] overwrite_caption = self._text['overwrite_caption'] # Request a filename from the user to save the keypair to filename = None default_filename = os.path.join(self._keypairdb.my_keypairs_dir, self._text['generate_default_name']) while True: if filename is None: # Show a save file selector filename = wx.SaveFileSelector(generate_saver_what, ".key", default_name=default_filename) elif os.path.isfile(filename): # File already exists, get overwrite confirmation from the user basename = os.path.basename(filename) overwrite_message = self._text['overwrite_message'] overwrite_message = overwrite_message.format(basename) overwrite = wx.MessageDialog(self, overwrite_message, caption=overwrite_caption, style=wx.YES_NO | wx.ICON_WARNING | wx.NO_DEFAULT) overwrite = overwrite.ShowModal() if overwrite == wx.ID_YES: break elif overwrite == wx.ID_NO: filename = None elif filename == '': # User closed the selector return else: # A filename has successfully been selected break # Generate Generate(self._config, self._locale, self._keypairdb, self, filename, keypairlistctrl=self.keypairlistctrl)
def GenerateReport(self, event): # wxGlade: MyFrame.<event_handler> savelocation = wx.SaveFileSelector('Report', '.pptx', 'Report.pptx') print(savelocation) try: self.datafiltered = mdf.filtered_data(self.fileDir) print(self.datafiltered) # datafiltered.to_csv(os.path.join(dirname, 'sortedList.csv')) # print(self.dirname) except: print('Select correct file') try: rp = reportGen(self.datafiltered, 'IQR', savelocation) rp.pptGenerator() print('Successful!') except: print('Report gen unsuccessful') finally: event.Skip()
def onHtml(self, event): content = f"""<html> <head> <meta charset='utf-8'> <title>{self.Parent.title}</title> </head> <body> """ description = self.contentBox.Value.split("\n") for line in range(len(description)): match = url.search(description[line]) if match is not None: description[ line] = f'<a href="{match.group()}">{match.group()}</a>' description = "<br \>\n".join(description) content += f"""<h1>{self.Parent.title}</h1> <p>{description}</p> </body> </html>""" path = wx.SaveFileSelector(" ", ".html", parent=self) if path: with open(path, "w", encoding="utf-8") as file: file.write(content) self.contentBox.SetFocus()
def onSave(self, event): self.viewer.tf_interface.save_yaml( wx.SaveFileSelector("TF Snapshot", ".tf"))
def 组件_保存文件对话框(提示="", 后缀="*", 默认文件名="", 父窗口=None): "设置文件后返回完整文件路径,没选择返回空文本" return wx.SaveFileSelector(提示, 后缀, 默认文件名, 父窗口)
def get_file_to_save(win, oms='', extension='', start=''): """toon een dialoog waarmee een file geopend kan worden om te schrijven """ what = shared.get_open_title(win, 'C_SELFIL', oms) return wx.SaveFileSelector(what, extension, default_name=start, parent=win)
def OnSave(self, event): filename = wx.SaveFileSelector("Save pipeline output as ...", '.hdf') if not filename == '': self.pipeline.save_hdf(filename)
def GenerateCVSFile(self, ID=False): fromdate = self.fromdateentry.GetValue() fromdate = miscmethods.GetSQLDateFromWXDate(fromdate) todate = self.todateentry.GetValue() todate = miscmethods.GetSQLDateFromWXDate(todate) action = "SELECT client.ClientTitle, client.ClientSurname, client.ClientAddress, client.ClientPostcode, animal.Name, animal.Species, medication.Name, medicationout.NextDue AS NextDue FROM medicationout INNER JOIN appointment ON medicationout.AppointmentID = appointment.ID INNER JOIN animal ON appointment.AnimalID = animal.ID INNER JOIN client ON appointment.OwnerID = client.ID INNER JOIN medication ON medicationout.MedicationID = medication.ID WHERE medicationout.NextDue BETWEEN \"" + str( fromdate) + "\" AND \"" + str(todate) + "\"" if self.vaccinetickbox.GetValue() == False: if len(self.includedvaccinationslist) == 0: action = action + " AND medication.Name IS NULL" else: action = action + " AND (" for a in self.includedvaccinationslist: action = action + "medication.Name = \"" + a + "\" OR " action = action[:-4] action = action + ")" if self.speciestickbox.GetValue() == False: if len(self.includedspecieslist) == 0: action = action + " AND animal.Species IS NULL" else: action = action + " AND (" for a in self.includedspecieslist: action = action + "animal.Species = \"" + a + "\" OR " action = action[:-4] action = action + ")" action = action + " UNION SELECT client.ClientTitle, client.ClientSurname, client.ClientAddress, client.ClientPostcode, animal.Name, animal.Species, manualvaccination.Name, manualvaccination.Next AS NextDue FROM manualvaccination INNER JOIN animal ON manualvaccination.AnimalID = animal.ID INNER JOIN client ON animal.OwnerID = client.ID WHERE manualvaccination.Next BETWEEN \"" + str( fromdate) + "\" AND \"" + str(todate) + "\"" if self.vaccinetickbox.GetValue() == False: if len(self.includedvaccinationslist) == 0: action = action + " AND manualvaccination.Name IS NULL" else: action = action + " AND (" for a in self.includedvaccinationslist: action = action + "manualvaccination.Name = \"" + a + "\" OR " action = action[:-4] action = action + ")" if self.speciestickbox.GetValue() == False: if len(self.includedspecieslist) == 0: action = action + " AND animal.Species IS NULL" else: action = action + " AND (" for a in self.includedspecieslist: action = action + "animal.Species = \"" + a + "\" OR " action = action[:-4] action = action + ")" action = action + " ORDER BY NextDue desc" results = db.SendSQL(action, self.localsettings.dbconnection) output = "\"title\",\"surname\",\"address\",\"postcode\",\"animalname\",\"species\",\"vaccinationtype\",\"duedate\"\n" for a in results: for b in range(0, len(a)): if b == 7: duedate = a[b] duedate = miscmethods.FormatSQLDate( duedate, self.localsettings) output = output + "\"" + str(duedate) + "\"," elif b == 2: address = a[b] #.replace("\n", ", ") output = output + "\"" + str(address) + "\"," else: output = output + "\"" + str(a[b]) + "\"," output = output[:-1] + "\n" output = output[:-1] path = wx.SaveFileSelector("CSV", "csv", "duevaccinations.csv") out = open(path, "w") out.write(output) out.close() miscmethods.ShowMessage(self.GetLabel("csvsavedtolabel") + " " + path)
def onTxt(self, event): path = wx.SaveFileSelector("", ".txt", parent=self) if not path: with open(path, "w", encoding="utf-8") as file: file.write(self.content) self.contentBox.SetFocus()
def onPDF(self, event): self.viewer.tf_interface.save_pdf( wx.SaveFileSelector("PDF Export", ".pdf"))
def OnBSavePointsButton(self, event): fn = wx.SaveFileSelector('Save point positions to file', '.txt') if fn is None: print('No file selected') else: self.sim_controller.save_points(fn)
def onSave(self, event): # wxGlade: MyFrame.<event_handler> savefile = wx.SaveFileSelector('Open a Wave file', '.wav', 'testmorse.wav', None) if (savefile != ""): self.SetTitle("Morse Code Wave File - " + savefile) self.morse.save_wav(savefile)