fbi_theme_preview.py 文件源码

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

项目:FBIThemePreviewer 作者: jurassicplayer 项目源码 文件源码
def saveConfig(self, config_type):
        print("Saving config: {}".format(config_type))
        if config_type == "config":
            filepath = "config"
            config_dict = self.app_config
            ordered = ['theme_folder', 'theme_title', 'theme_desc', 'theme_author', 'theme_version', 'meta_icon', 'screen_gap', 'anim_duration', 'overwrite', 'language']
        elif config_type == "textcolor":
            theme_folder = self.app_config['theme_folder']
            os.makedirs(theme_folder, exist_ok=True)
            filepath = os.path.join(theme_folder,'textcolor.cfg')
            config_dict={}
            for key in self.text_config:
                r,g,b,a = self.text_config[key]
                value = "{:02x}{:02x}{:02x}{:02x}".format(a,b,g,r).upper()
                config_dict.update({key: value})
            ordered = ['text', 'nand', 'sd', 'gamecard', 'dstitle', 'file', 'directory', 'enabled', 'disabled', 'installed', 'notinstalled', 'ticketinuse', 'ticketnotinuse']
            if os.path.isfile(filepath) and not self.app_config['overwrite'] in ['always', 'textcolor']:
                if not messagebox.askyesno("Warning", "A textcolor.cfg already exists, do you want to overwrite?", icon='warning'):
                    return
        with open(filepath, 'w') as f:
            for key in ordered:
                f.write("{}={}\n".format(key, config_dict[key]))
            f.truncate(f.tell() - len(os.linesep))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号