python3 xmind python3画思维导图

1、下载安装

https://github.com/18813055625/xmind-sdk-python3

git clone https://github.com/jmoraleda/xmind-sdk-python3.git
python setup.py install
2、基本代码介绍

import xmind    #加载包

w = xmind.load(“test.xmind”) # 加载,如果不存在,创建新的工作布
    s1=w.getPrimarySheet() # 得到第一页
    s1.setTitle(“first sheet”) # 给第一页命名
    
    r1=s1.getRootTopic() # 创建根节点
    r1.setTitle(“根”) # 给根节点命名

r2=r1.addSubTopic()#创建二级节点

r2.setTitle(“枝叶”)#命名

xmind.save(“test2.xmind”) ##保存文件

4、给节点增加图像

用到的函数:addMarker

r1=s1.getRootTopic() # get the root topic of this sheet
r1.addMarker(MarkerId.peopleRed)#增加人头像
r1.setTitle(id_num) # set its title出生年月

5、常见的分之结构

第一种xmind结构

import xmind
w = xmind.load(“test.xmind”) # load an existing file or create a new workbook if nothing is found
s1=w.getPrimarySheet() # get the first sheet
s1.setTitle(“first sheet”) # set its title

a={“h1”:1,‘h2’:[2,3],‘h3’:[4,5,6]}
r1=s1.getRootTopic() # get the root topic of this sheet
r1.setTitle(a[‘h1’]) # set its title
r2=r1.addSubTopic()
r2.setTitle(a[‘h2’])
r3=r2.addSubTopic()
r3.setTitle(a[‘h3’])
xmind.save(w,“test2.xmind”)

import xmind
w = xmind.load(“test.xmind”) # load an existing file or create a new workbook if nothing is found
s1=w.getPrimarySheet() # get the first sheet
s1.setTitle(“first sheet”) # set its title
a={“h1”:1,‘h2’:[2,3],‘h3’:[[4,5,6],[7,8]]}
r1=s1.getRootTopic() # get the root topic of this sheet
r1.setTitle(a[‘h1’]) # set its title
c=a[‘h2’]
c2=a[‘h3’]

for i,val in enumerate©:
print(i,val)
a=‘b’+str(i)
a=r1.addSubTopic()
a.setTitle(val) # set its title
for i2,val2 in enumerate(c2):
if i==i2:
a.addSubTopic().setTitle(val2)

xmind.save(w,“test4.xmind”)
第二种xmind结果

import xmind
w = xmind.load(“test.xmind”)
s1=w.getPrimarySheet() # get the first sheet
s1.setTitle(“first sheet”) # set its title
a={“h1”:1,‘h2’:[2,3],‘h3’:[[4,5,6],[7,8]]}
r1=s1.getRootTopic() # get the root topic of this sheet
r1.setTitle(a[‘h1’]) # set its title
c=a[‘h2’]
c2=a[‘h3’]
for i,val in enumerate©:
print(i,val)
a=‘b’+str(i)
a=r1.addSubTopic()
a.setTitle(val) # set its title
for i2,val2 in enumerate(c2):
if i==i2:
a2=‘b2’+str(i)
a2=a.addSubTopic()
# if isinstance(val, list):
for i3,val3 in enumerate(val2):
a3=‘b3’+str(i3)
a3=a2.addSubTopic()
a3.setTitle(val3)

xmind.save(w,“test5.xmind”)
第三种结构


作者:pan15125284
来源:CSDN
原文:https://blog.csdn.net/pan15125284/article/details/92760928
版权声明:本文为博主原创文章,转载请附上博文链接!

  • 1
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值