def saveLayout(self): filedialog = QFileDialog(self) url = filedialog.getSaveFileUrl(filter='15-Puzzle Data File(*.data)') path = url[0].path() if os.path.exists(os.path.dirname(path)): file = open(path, 'w') file.write(str(self.narray).replace('[', '').replace(']', '')) file.close() self.ui.statusbar.showMessage('保存成功:' + path, 3000) else: message = QMessageBox() message.setText('路径有误,保存失败')
def save_current(self): """現在のPlaylistを保存する タイトルをファイル名として、パスをファイルの各行に書き出す。 """ name = self.tabText(self.currentIndex()) url, ok = QFileDialog.getSaveFileUrl( self, 'Save File', name + self.playlist_ext, 'playlist(*{}'.format(self.playlist_ext)) if not ok: return False url = url.toLocalFile() self.current_playlist().save(url)
def saveFile(parent, caption: str, current_dir__str: Union[None, str]): options = QFileDialog.Options() options |= QFileDialog.AcceptSave cur_dir__url = QUrl(current_dir__str) file_dialog, _ = QFileDialog.getSaveFileUrl(parent, caption, dir=cur_dir__url, options=options) if file_dialog and _: file_dialog: 'QUrl' return file_dialog.toLocalFile() return None
def saveResult(self): if self.result == None: message = QMessageBox(self) message.setText('没有结果显示,请先执行出解决方案') message.show() else: filedialog = QFileDialog(self) url = filedialog.getSaveFileUrl(filter='15-Puzzle Data File(*.data)') path = url[0].path() if os.path.exists(os.path.dirname(path)): file = open(path, 'w') for m in self.result: if type(m) == np.ndarray: file.write(str(m) + '\n') else: file.write(m + '\n') file.close() self.ui.statusbar.showMessage('保存成功:' + path, 3000) else: message = QMessageBox() message.setText('路径有误,保存失败')