__init__.py 文件源码

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

项目:griffith 作者: Strit 项目源码 文件源码
def show_dialog(self):
        # shows a file dialog and sets self.filepath
        # derived classes which overwrite this method have also to set self.filepath
        basedir = None
        if not self.config is None and not self.config_section is None:
            basedir = self.config.get('export_dir', None, section=self.config_section)
        if basedir is None:
            filenames = gutils.file_chooser(_('Export a %s document') % self.export_name, action=gtk.FILE_CHOOSER_ACTION_SAVE, \
                buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK), name=self.filename)
        else:
            filenames = gutils.file_chooser(_('Export a %s document') % self.export_name, action=gtk.FILE_CHOOSER_ACTION_SAVE, \
                buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK), name=self.filename, folder=basedir)
        if filenames[0]:
            self.filepath = filenames[0]
            if len(filenames) > 1:
                self.dirpath = filenames[1]
            else:
                self.dirpath = os.path.dirname(self.filepath)
            self.filename = os.path.basename(self.filepath)
            if not self.config is None and self.dirpath and not self.config_section is None:
                self.config.set('export_dir', self.dirpath, section=self.config_section)
                self.config.save()
            overwrite = None
            if os.path.isfile(self.filepath):
                if gutils.question(_('File exists. Do you want to overwrite it?'), self.parent_window):
                    overwrite = True
                else:
                    overwrite = False

            if overwrite == True or overwrite is None:
                return True
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号