當前位置: 首頁>>代碼示例>>Python>>正文


Python QFileDialog.getSaveFileName方法代碼示例

本文整理匯總了Python中PyQt5.QtWidgets.QFileDialog.getSaveFileName方法的典型用法代碼示例。如果您正苦於以下問題:Python QFileDialog.getSaveFileName方法的具體用法?Python QFileDialog.getSaveFileName怎麽用?Python QFileDialog.getSaveFileName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtWidgets.QFileDialog的用法示例。


在下文中一共展示了QFileDialog.getSaveFileName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: on_pushButton_10_clicked

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getSaveFileName [as 別名]
def on_pushButton_10_clicked(self):
        """
        恢複
        """
        ori_img = self.my_recovery_parameter.get('ori_img',None)
        attacked_img = self.my_recovery_parameter.get('attacked_img',None)
        if not ori_img:
            QMessageBox.warning(self,"警告",'未讀取原圖',QMessageBox.Ok)
        elif not attacked_img:
            QMessageBox.warning(self,"警告",'未讀取受到攻擊的圖片',QMessageBox.Ok)
        else:
            outfile_path,_ = QFileDialog.getSaveFileName(self, '恢複圖片', self.my_bwm_parameter.get('work_path','./'),"PNG (*.png);;All Files (*)")
            if outfile_path:
                rate = self.doubleSpinBox_3.value()
                self.recovery_thread = recovery(ori_img,attacked_img,outfile_path,rate)
                self.recovery_thread.finished.connect(self.recovery_thread.deleteLater)
                self.recovery_thread.num_of_good.connect(self.show_recovery)
                self.recovery_thread.start() 
開發者ID:fire-keeper,項目名稱:BlindWatermark,代碼行數:20,代碼來源:main_win.py

示例2: dialog_save_lattice

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getSaveFileName [as 別名]
def dialog_save_lattice(self):
        """Save lattice to file"""

        filename = QFileDialog.getSaveFileName(self.mw, 'Save Lattice', '', "Python Files (*.py);;All Files (*)", options=QFileDialog.DontUseNativeDialog)
        if filename[0] == '':
            return 0

        lp = Parser()
        lines = lp.gui_lattice2input(self.mw.lattice, split=True)

        if filename[1] == 'Python Files (*.py)' and filename[0][-3:] != '.py':
            filename = filename[0] + '.py'
        else:
            filename = filename[0]

        with open(filename, 'w') as fp:
            fp.writelines(lines) 
開發者ID:ocelot-collab,項目名稱:ocelot,代碼行數:19,代碼來源:menu_file.py

示例3: new_project

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getSaveFileName [as 別名]
def new_project(self, src_imgdir):
        '''
        create new project directory from src image directory to dst
        '''
        imgdir = src_imgdir.toLocalFile()
        p = Path(imgdir)
        default_projdir = str(
            p.with_name( consts.default_proj_name(p.name) )
        )

        projdir,_ = QFileDialog.getSaveFileName(
            caption=consts.config["new_project_dialog"]["caption"],
            directory=default_projdir,
            filter=consts.config["new_project_dialog"]["filter"]
        )

        new_projdir = state.new_project(imgdir, projdir)
        if new_projdir:
            self.set_project(new_projdir)
            return new_projdir

    #--------------------------------------------------- 
開發者ID:KUR-creative,項目名稱:SickZil-Machine,代碼行數:24,代碼來源:gui.py

示例4: __export_presets

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getSaveFileName [as 別名]
def __export_presets(self):
        names = [item.text() for item in self.presetsList.selectedItems()]
        archive, _ = QFileDialog.getSaveFileName(
            self,
            directory='archive.presets',
            filter='*.presets'
        )

        if archive != '':
            if not archive.endswith('.presets'):
                archive += '.presets'
            try:
                export_presets(names, archive)
            except PresetExportError as e:
                QDetailedMessageBox.dcritical(
                    translate('Presets', 'Presets'),
                    translate('Presets', 'Cannot export correctly.'),
                    str(e),
                    parent=self
                ) 
開發者ID:FrancescoCeruti,項目名稱:linux-show-player,代碼行數:22,代碼來源:presets_ui.py

示例5: save

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getSaveFileName [as 別名]
def save(self):
        """Save log to file."""
        home = str(Path.home())
        self.output = ""
        self.output = QFileDialog.getSaveFileName(self,
                                                  'Save file',
                                                  home,
                                                  "ReST files (*.rst)")

        if self.output[0] is not "":
            with open(self.output[0], 'w') as f:
                f.write(self.te.toPlainText())

            btMessage = f'File saved as {self.output[0]}.'
        else:
            btMessage = "Can't save. No file specified."
        self.systemtray_icon.showMessage(
            APP_NAME, btMessage, QIcon(ICON_PATH), 5000)
        self.statusBar().showMessage(btMessage) 
開發者ID:DedSecInside,項目名稱:Awesome-Scripts,代碼行數:21,代碼來源:work_log.py

示例6: on_save_log

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getSaveFileName [as 別名]
def on_save_log(self):
        file_name, _ = QFileDialog.getSaveFileName(  # second return value contains the used file type filter.
            self.window(),
            "Save log file",
            "",
            ""  # TODO: File type filter. Maybe "*.log"?
        )
        del _  # We are only interested in the selected file name
        if file_name:
            list_widget = self.listWidget  # type: QListWidget
            item_texts = (list_widget.item(row).text() for row in range(list_widget.count()))
            log_text = "\n".join(item_texts) + "\n"
            try:
                with open(file_name, "w") as log_file:
                    log_file.write(log_text)
            except IOError:
                logger.exception("Error saving log file")
            else:
                self.on_clear_log()  # Error log saved, so clear the previously saved entries 
開發者ID:autokey,項目名稱:autokey,代碼行數:21,代碼來源:centralwidget.py

示例7: dump_memory

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getSaveFileName [as 別名]
def dump_memory(self, file_path=None, ptr=0, length=0):
        if ptr == 0:
            ptr, inp = InputDialog.input_pointer(self._app_window)
        if ptr > 0:
            if length == 0:
                accept, length = InputDialog.input(
                    self._app_window, hint='insert length', placeholder='1024')
                if not accept:
                    return
                try:
                    if length.startswith('0x'):
                        length = int(length, 16)
                    else:
                        length = int(length)
                except:
                    return
            if file_path is None:
                r = QFileDialog.getSaveFileName(self._app_window, caption='Save binary dump to file')
                if len(r) == 0 or len(r[0]) == 0:
                    return
                file_path = r[0]
            data = self.read_memory(ptr, length)
            if data is not None and len(data) > 1:
                with open(file_path, 'wb') as f:
                    f.write(data[1]) 
開發者ID:iGio90,項目名稱:Dwarf,代碼行數:27,代碼來源:core.py

示例8: on_pbLog_clicked

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getSaveFileName [as 別名]
def on_pbLog_clicked(self):
        """ Select file for logging error/output of Lector
        """
        fileFilter = self.tr("Log files (*.log);;All files (*);;")
        init_filename = self.ui.lnLog.text()
        if not init_filename:
            if (os.path.split(sys.executable)[1]).lower().startswith('python'):
                logPath = os.path.abspath(os.path.dirname(__file__))
            else:
                logPath =  os.path.abspath(os.path.dirname(sys.executable))
            init_filename = os.path.join(logPath, "lector.log")
        filename = str(QFileDialog.getSaveFileName(self,
                self.tr("Select file for log output..."),
                init_filename,
                fileFilter))
        if not filename:
            return
        else:
            self.ui.lnLog.setText(filename) 
開發者ID:zdenop,項目名稱:lector,代碼行數:21,代碼來源:settingsdialog.py

示例9: _export_plaintext_recovery

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getSaveFileName [as 別名]
def _export_plaintext_recovery(self, gateway):
        dest, _ = QFileDialog.getSaveFileName(
            self.parent,
            "Select a destination",
            os.path.join(
                os.path.expanduser("~"), gateway.name + " Recovery Key.json"
            ),
        )
        if not dest:
            return
        try:
            gateway.export(dest, include_rootcap=True)
        except Exception as e:  # pylint: disable=broad-except
            error(self.parent, "Error exporting Recovery Key", str(e))
            return
        self.done.emit(dest) 
開發者ID:gridsync,項目名稱:gridsync,代碼行數:18,代碼來源:recovery.py

示例10: _save_button_clicked

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getSaveFileName [as 別名]
def _save_button_clicked(self):
        anchor_positions = self._data_model.get_anchor_postions()
        data = {}
        for id, pos in anchor_positions.items():
            data[id] = {'x': pos[0], 'y': pos[1], 'z': pos[2]}

        names = QFileDialog.getSaveFileName(self, 'Save file',
                                            self._current_folder,
                                            "*.yaml;;*.*")

        if names[0] == '':
            return

        self._current_folder = os.path.dirname(names[0])

        if not names[0].endswith(".yaml") and names[0].find(".") < 0:
            filename = names[0] + ".yaml"
        else:
            filename = names[0]

        f = open(filename, 'w')
        with f:
            yaml.dump(data, f) 
開發者ID:bitcraze,項目名稱:crazyflie-clients-python,代碼行數:25,代碼來源:anchor_position_dialog.py

示例11: saveOperation

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getSaveFileName [as 別名]
def saveOperation(self):
        filename = QFileDialog.getSaveFileName(self, 'Save file', './screenshot.png', '*.png;;*.jpg')
        if len(filename[0]) == 0:
            return
        else:
            self.saveScreenshot(False, filename[0], filename[1][2:])
            self.close() 
開發者ID:SeptemberHX,項目名稱:screenshot,代碼行數:9,代碼來源:screenshot.py

示例12: s_save

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getSaveFileName [as 別名]
def s_save(self):
        """Slot for saving the current machine to a json file

        Parameters
        ----------
        self : DMachineSetup
            A DMachineSetup object
        """
        # Ask the user to select a .m file to save
        if self.machine.name in ["", None]:
            save_file_path = QFileDialog.getSaveFileName(
                self, self.tr("Save file"), self.machine_path, "Json (*.json)"
            )[0]
        else:
            def_path = join(self.machine_path, self.machine.name + ".json")
            save_file_path = QFileDialog.getSaveFileName(
                self, self.tr("Save file"), def_path, "Json (*.json)"
            )[0]

        # Avoid bug due to user closing the popup witout selecting a file
        if save_file_path != "":
            # Set the machine name to match the file name
            self.machine.name = str(basename(str(save_file_path)))[:-5]
            # Save the machine file
            self.machine.save(save_file_path)
            # To update the machine name field (if first page)
            self.set_nav(self.nav_step.currentRow())
            # Update the machine path to remember the last used folder
            self.machine_path = dirname(save_file_path)
            # Notify the project GUI that the machine has changed
            self.machineChanged.emit()
            self.is_save_needed = False
            return True
        return False 
開發者ID:Eomys,項目名稱:pyleecan,代碼行數:36,代碼來源:DMachineSetup.py

示例13: on_btnRead_finished

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getSaveFileName [as 別名]
def on_btnRead_finished(self):
        binpath, filter = QFileDialog.getSaveFileName(caption=u'將讀取到的數據保存到文件', filter=u'程序文件 (*.bin)')
        if binpath:
            with open(binpath, 'wb') as f:
                f.write(bytes(self.buff))

        self.jlk.reset()

        self.setEnabled(True)
        self.prgInfo.setVisible(False) 
開發者ID:XIVN1987,項目名稱:JMCUProg,代碼行數:12,代碼來源:MCUProg.py

示例14: _export2JqkaAct

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getSaveFileName [as 別名]
def _export2JqkaAct(self):
        data = {}
        if not DyStockTableSelectDlg(data, '{0}導出到同花順'.format(self.getUniqueName())).exec_():
            return

        defaultFileName = '{0}.sel' if data['all'] else '{0}_高亮.sel'
        defaultFileName = defaultFileName.format(self.getUniqueName())

        defaultDir = DyCommon.createPath('Stock/User/Save/Strategy/同花順')
        fileName, _ = QFileDialog.getSaveFileName(None, '導出到同花順', os.path.join(defaultDir, defaultFileName), "同花順files (*.sel);;all files(*.*)", options=QFileDialog.DontUseNativeDialog)
        if fileName:
            self.export2Jqka(fileName) 
開發者ID:moyuanz,項目名稱:DevilYuan,代碼行數:14,代碼來源:DyStockTableWidget.py

示例15: _saveAsAct

# 需要導入模塊: from PyQt5.QtWidgets import QFileDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getSaveFileName [as 別名]
def _saveAsAct(self):
        data = {}
        if not DyStockTableSelectDlg(data, '{0}保存'.format(self.getUniqueName())).exec_():
            return

        defaultFileName = '{0}.json' if data['all'] else '{0}_高亮.json'
        defaultFileName = defaultFileName.format(self.getUniqueName())

        defaultDir = DyCommon.createPath('Stock/User/Save/Strategy')
        fileName, _ = QFileDialog.getSaveFileName(None, '保存股票表', os.path.join(defaultDir, defaultFileName), "JSON files (*.json);;all files(*.*)", options=QFileDialog.DontUseNativeDialog)
        if fileName:
            self._saveAs(fileName, data['all']) 
開發者ID:moyuanz,項目名稱:DevilYuan,代碼行數:14,代碼來源:DyStockTableWidget.py


注:本文中的PyQt5.QtWidgets.QFileDialog.getSaveFileName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。