python创建xmind文件,带格式

网上找了xmind,https://github.com/zhuifengshen/xmind,可以创建xmind文件,但是带格式的作者没写。还有一个问题就是这个只能用xmind8打开,我用的xmind zen,打不开。网上搜索半天,找到https://blog.csdn.net/weixin_40105587/article/details/117557740,解决了文件打不开的问题。

然后研究格式的时候,本来打算修改源码看能不能行,试了下感觉太复杂了,换个思路,直接拷贝styles.xml文件,保存进去就可以了

    extract(unzip_path, os.path.join(folder, zip_name))
    shutil.copyfile(folder+"/META-INF/manifest.xml", os.path.join(inf_folder, "manifest.xml"))
    #放入样式文件,新加了这一行
    shutil.copyfile(folder + "/META-INF/styles.xml", os.path.join(unzip_path, "styles.xml"))
    os.remove(os.path.join(folder, zip_name))
import xmind.core.const as const
# id写在styles文件里,直接设置节点的格式
        style_id = '3f8h34qpk8c4hrv4o7vi0mrvp1'
        sub_topic3.setAttribute(const.ATTR_STYLE_ID, style_id)
        sub_topic4 = sub_topic3.addSubTopic()
        sub_topic4.setTitle(case.get('case_expects'))
        sub_topic4.setAttribute(const.ATTR_STYLE_ID, style_id)
<?xml version="1.0" encoding="utf-8" standalone="no"?><xmap-styles xmlns="urn:xmind:xmap:xmlns:style:2.0" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg" version="2.0"><styles><style id="3f8h34qpk8c4hrv4o7vi0mrvp1" type="topic"><topic-properties fo:text-align="left"/></style></styles></xmap-styles>

格式我只需要一个左对齐,所以只设置了这一个,要其他格式,参照正常的xmind8 styles文件里设置就行了。

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值