Exemple #1
0
level_node = list()
for i in range(max_level):
    row_data = data[data['层级'] == (i + 1)]
    level_node.append(dict())
    if i == 0:
        for j in range(row_data.shape[0]):
            sub_topic = TopicElement(ownerWorkbook=w)
            sub_topic.setTitle(row_data.iloc[j]['结点名称'])
            r.addSubTopic(sub_topic)
            level_node[i][row_data.iloc[j]['结点名称']] = sub_topic
    else:
        for j in range(row_data.shape[0]):
            sub_topic = TopicElement(ownerWorkbook=w)
            sub_topic.setTitle(row_data.iloc[j]['结点名称'])

            if str(row_data.iloc[j]['是否有视频']) != 'nan':
                sub_topic.addLabel("video")

            if str(row_data.iloc[j]['展示方式']) != 'nan':
                if str(row_data.iloc[j]['注释说明']) != 'nan':
                    sub_topic.addLabel(row_data.iloc[j]['展示方式'] + '(' +
                                       row_data.iloc[j]['注释说明'] + ')')
                else:
                    sub_topic.addLabel(row_data.iloc[j]['展示方式'])

            level_node[i - 1][row_data.iloc[j]['上级结点']].addSubTopic(sub_topic)
            level_node[i][row_data.iloc[j]['结点名称']] = sub_topic

xmind.save(w, root_path + xmind_file_name)
Exemple #2
0
def gen_sheet2(workbook, sheet1):
    # ***** second sheet *****
    # create a new sheet and add to the workbook by default
    sheet2 = workbook.createSheet()
    sheet2.setTitle("second sheet")

    # a sheet has a blank sheet by default
    root_topic2 = sheet2.getRootTopic()
    root_topic2.setTitle("root node")

    # use other methods to create some sub topic element
    topic1 = TopicElement(ownerWorkbook=workbook)
    # set a topic hyperlink from this topic to the first sheet given by s1.getID()
    topic1.setTopicHyperlink(sheet1.getID())
    topic1.setTitle("redirection to the first sheet")  # set its title

    topic2 = TopicElement(ownerWorkbook=workbook)
    topic2.setTitle("topic with an url hyperlink")
    topic2.setURLHyperlink(
        "https://github.com/zhuifengshen/xmind")  # set an url hyperlink

    topic3 = TopicElement(ownerWorkbook=workbook)
    topic3.setTitle("third node")
    topic3.setPlainNotes("notes for this topic")  # set notes (F4 in XMind)
    topic3.setTitle("topic with \n notes")

    topic4 = TopicElement(ownerWorkbook=workbook)
    topic4.setFileHyperlink("logo.png")  # set a file hyperlink
    topic4.setTitle("topic with a file")

    topic1_1 = TopicElement(ownerWorkbook=workbook)
    topic1_1.setTitle("sub topic")
    topic1_1.addLabel("a label")  # official XMind only can a one label

    topic1_1_1 = TopicElement(ownerWorkbook=workbook)
    topic1_1_1.setTitle("topic can add multiple markers")
    topic1_1_1.addMarker(MarkerId.starBlue)
    topic1_1_1.addMarker(MarkerId.flagGreen)

    topic2_1 = TopicElement(ownerWorkbook=workbook)
    topic2_1.setTitle("topic can add multiple comments")
    topic2_1.addComment("I'm a comment!")
    topic2_1.addComment(content="Hello comment!", author='devin')

    # then the topics must be added to the root element
    root_topic2.addSubTopic(topic1)
    root_topic2.addSubTopic(topic2)
    root_topic2.addSubTopic(topic3)
    root_topic2.addSubTopic(topic4)
    topic1.addSubTopic(topic1_1)
    topic2.addSubTopic(topic2_1)
    topic1_1.addSubTopic(topic1_1_1)

    # to loop on the subTopics
    topics = root_topic2.getSubTopics()
    for index, topic in enumerate(topics):
        topic.addMarker("priority-" + str(index + 1))

    # create a relationship
    sheet2.createRelationship(topic1.getID(), topic2.getID(),
                              "relationship test")