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))
 def set_sub_key_element(self, input_data, sheet_obj, parent_topic):
     for sub_key in input_data:
         sub_key_element = TopicElement()  # create a new element
         sub_key_element.setTopicHyperlink(sheet_obj.getID())
         sub_key_element.setTitle(str(sub_key))
         if str(sub_key).endswith(DEFAULT_EXT_TIMEUNIT):
             sub_key_element.setAttribute(const.ATTR_STYLE_ID, DEFAULT_STYLE_LIGHTBLUE)
         elif str(sub_key).isdigit():
             sub_key_element.setAttribute(const.ATTR_STYLE_ID, DEFAULT_STYLE_RED)
         parent_topic.addSubTopic(sub_key_element)
         if isinstance(input_data[sub_key], dict):
             self.set_sub_key_element(input_data[sub_key], sheet_obj, sub_key_element)
         if isinstance(input_data[sub_key], unicode):
             sub_key_element.setPlainNotes(input_data[sub_key])
Beispiel #3
0
root = sheet.getRootTopic()


s1=w.getPrimarySheet() # get the first sheet
s1.setTitle("first sheet") # set its title
r1=s1.getRootTopic() # get the root topic of this sheet
r1.setTitle("we don't care of this sheet") # set its title

s2=w.createSheet() # create a new sheet
s2.setTitle("second sheet")
r2=s2.getRootTopic()
r2.setTitle("root node")


t1=TopicElement() # create a new element
t1.setTopicHyperlink(s1.getID()) # set a link from this topic to the first sheet given by s1.getID()
t1.setTitle("redirection to the first sheet") # set its title

t2=TopicElement()
t2.setTitle("second node")
t2.setURLHyperlink("https://xmind.net") # set an hyperlink

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

t4=TopicElement()
t4.setFileHyperlink("logo.jpeg") # set a file hyperlink
t4.setTitle("topic with a file")
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
r1 = s1.getRootTopic()  # get the root topic of this sheet
r1.setTitle("we don't care of this sheet")  # set its title

s2 = w.createSheet()  # create a new sheet
s2.setTitle("second sheet")
r2 = s2.getRootTopic()
r2.setTitle("root node")

t1 = TopicElement()  # create a new element
t1.setTopicHyperlink(s1.getID(
))  # set a link from this topic to the first sheet given by s1.getID()
t1.setTitle("redirection to the first sheet")  # set its title

t2 = TopicElement()
t2.setTitle("second node")
t2.setURLHyperlink("https://xmind.net")  # set an hyperlink

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

t4 = TopicElement()
t4.setFileHyperlink("logo.jpeg")  # set a file hyperlink
t4.setTitle("topic with a file")