main_tk_setup.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:of 作者: OptimalBPM 项目源码 文件源码
def on_save_json(self, *args):
        """Triggered when save-button is clicked.
        Displays a save dialog, fetches GUI data into merge, and saves as JSON into the selected file."""
        self.notify_task('Saving..', 0)
        _filename = filedialog.asksaveasfilename(initialdir=os.path.dirname(self.setup_filename.get()),
                                                 initialfile=os.path.basename(self.setup_filename.get())
                                                 , defaultextension=".json",
                                                 filetypes=[('JSON files', '.json'), ('all files', '.*')],
                                                 title="Choose location")
        if _filename:
            self.gui_to_setup()
            self.notify_task('Saving(Generating JS)..', 0)

            _dict = self.setup.as_dict()
            self.notify_task('Saving(Writing file)..', 50)
            with open (_filename, "w") as _f:
                json.dump(_dict, fp=_f, sort_keys=True, indent=4)

            self.notify_task('Saving..done.', 100)
        else:
            self.notify_task('Saving cancelled.', 0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号