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") 

 

python3 xmind python3画思维导图_第1张图片

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(c):
    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结果

 

python3 xmind python3画思维导图_第2张图片

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(c):
    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") 

第三种结构

python3 xmind python3画思维导图_第3张图片

你可能感兴趣的:(python)