def generate_xmind(self): # merge sumamry data with open(self.input_fp) as summary_fh: summary_data = json.load(summary_fh) merged_summary_data = self.merge_summary_data(summary_data[DEFAULT_SUMMARY_KEY]) # init xmind obj output_xmind_obj = xmind.load(self.output_fp) # create summary sheet summary_sheet = output_xmind_obj.getPrimarySheet() # get the first sheet summary_sheet.setTitle(DEFAULT_SUMMARY_KEY) # set its title summary_sheet.setAttribute(const.ATTR_THEME, DEFAULT_THEME) root_topic = summary_sheet.getRootTopic() # get the root topic of this sheet summary_root_key = merged_summary_data.keys()[0] root_topic.setTitle(summary_root_key) # set its title self.set_sub_key_element(merged_summary_data[summary_root_key], summary_sheet, root_topic) # create case sheet if DEFAULT_SUMMARY_KEY in summary_data: for case_name in summary_data[DEFAULT_SUMMARY_KEY]: case_sheet = output_xmind_obj.createSheet() case_sheet.setTitle(case_name) case_sheet.setAttribute(const.ATTR_THEME, DEFAULT_THEME) case_root_topic = case_sheet.getRootTopic() root_key = summary_data[DEFAULT_SUMMARY_KEY][case_name].keys()[0] case_root_topic.setTitle(root_key) self.set_sub_key_element(summary_data[DEFAULT_SUMMARY_KEY][case_name][root_key], case_sheet, case_root_topic) output_xmind_obj.addSheet(case_sheet) else: print "The summary json file[%s] format is not correct!" % self.input_fp xmind.save(output_xmind_obj, self.output_fp) self.append_xmind_style()
def update_xmind(): workbook = xmind.load('demo.xmind') primary_sheet = workbook.getPrimarySheet() root_topic = primary_sheet.getRootTopic() root_topic.addMarker(MarkerId.starRed) # 1、save all content and save as xmind_update_demo.xmind(recommended) xmind.save(workbook=workbook, path='xmind_update_demo.xmind') # 2、only save the content.xml xmind.save(workbook=workbook, path='xmind_update_demo1.xmind', only_content=True) # 3、only save content.xml、comments.xml、styles.xml xmind.save(workbook=workbook, path='xmind_update_demo2.xmind', except_attachments=True) # 4、save everything except `Revisions` content to save space(also recommended) xmind.save(workbook=workbook, path='xmind_update_demo3.xmind', except_revisions=True) # 5、update and overwrite the original file directly. xmind.save(workbook)
def save_xmind_report(filename, username, results): if os.path.exists(filename): os.remove(filename) workbook = xmind.load(filename) sheet = workbook.getPrimarySheet() design_sheet(sheet, username, results) xmind.save(workbook, path=filename)
def main(md_content, target_file_name, topic_name): # print('main {0}'.format(md_file)) if '.xmind' not in target_file_name: target_file_name += '.xmind' # 如果目标文件存在则删除 target_file_path = os.path.abspath(os.path.join(os.getcwd(), target_file_name)) # print(target_file_path) if os.path.exists(target_file_path): print('\033[1;35m目标文件存在且已删除 \033[0m') os.remove(target_file_path) # 1、如果指定的XMind文件存在,则加载,否则创建一个新的 workbook = xmind.load(target_file_name) # 2、获取第一个画布(Sheet),默认新建一个XMind文件时,自动创建一个空白的画布 sheet1 = workbook.getPrimarySheet() # 3、在画布上生成思维导图 Md2Xmind.handle_content(md_content, sheet1, topic_name) # 4、保存(如果指定path参数,另存为该文件名) xmind.save(workbook) print('\033[1;32m{0} created \033[0m'.format(target_file_name))
def create_xmind(dict_data, file): try: file_name = file if '.xlsx' not in file else file.split('.xlsx')[0] w = xmind.load(file_name + '.xmind') for i in range(len(dict_data)): s = w.getPrimarySheet() if i == 0 else w.createSheet() s.setTitle(dict_data[i][1][0]) # set its title global r # 初始使用变量,需要在下面的方法中查找,提供全局 r = s.getRootTopic() # get the root topic of this sheet r.setTitle(dict_data[i][1][0]) # 设置主分支标题,同sheet都相同 # 设置循环标签 不超过26位 topic_list = list(map(chr, range(ord('a'), ord('z') + 1))) topic_list.pop(17) topic_list.pop(18) for item in enumerate(dict_data[i][0]): preview_ct = 1 for dict_ct in range(len(item[1])): if dict_ct == 0: current_topic = item[1][dict_data[i][1][dict_ct + 1]] key = dict_data[i][1][dict_ct + 1] topic_name = topic_list[dict_ct] prev_topic_name = 'r' preview_ct = sort_liter(preview_ct, current_topic, key, topic_name, prev_topic_name) else: current_topic = item[1][dict_data[i][1][dict_ct + 1]] key = dict_data[i][1][dict_ct + 1] topic_name = topic_list[dict_ct] prev_topic_name = topic_list[dict_ct - 1] preview_ct = sort_liter(preview_ct, current_topic, key, topic_name, prev_topic_name) xmind.save(w, file_name + '.xmind') except Exception as err: print(err)
def gen_my_xmind_file(): workbook = xmind.load("my.xmind") sheet1 = workbook.getPrimarySheet() time_name = basic_sheet(sheet1, workbook) # gen_sheet2(sheet1, workbook) xmind.save(workbook, path='minmap/{}.xmind'.format(time_name))
def draw(self): if os.path.exists(self.xmind_path): os.remove(self.xmind_path) mind_map = xmind.load(self.xmind_path) sheet = mind_map.getPrimarySheet() sheet.setTitle(self.title) self.note.transform(sheet) xmind.save(mind_map)
def genxmindfile(filename, username, results): print(f'Generating XMIND8 file for username {username}') if os.path.exists(filename): os.remove(filename) workbook = xmind.load(filename) sheet = workbook.getPrimarySheet() design_sheet(sheet, username, results) xmind.save(workbook, path=filename)
def gen_my_xmind_file(): # load an existing file or create a new workbook if nothing is found workbook = xmind.load("my.xmind") # get the first sheet(a new workbook has a blank sheet by default) sheet1 = workbook.getPrimarySheet() design_sheet1(sheet1) # create sheet2 # gen_sheet2(workbook, sheet1) # now we save as test.xmind xmind.save(workbook, path='my.xmind')
def json_2_xmind(json_file_path, xmind_name): workbook = xmind.load(xmind_name) sheet1 = workbook.getPrimarySheet() sheet1.setTitle(xmind_name) # 设置画布名称 root_topic1 = sheet1.getRootTopic() root_topic1.setTitle(xmind_name) with open(json_file_path) as f: dict_data = json.load(f) dfs(dict_data, root_topic1) xmind.save(workbook, path=xmind_name)
def make(self): self.read_data() if os.path.exists(self.save_to): os.remove(self.save_to) workbook = xmind.load(self.save_to) sheet = workbook.getPrimarySheet() sheet.setTitle(self.title) root_topic = sheet.getRootTopic() root_topic.setTitle(self.title) self.add_sub(root_topic, 0) xmind.save(workbook, path=self.save_to)
def create(self, user_id: str, title: str) -> bool: try: _xmind_workbook, _current_file = self.get_workbook(user_id) _new_sheet = _xmind_workbook.createSheet() _new_sheet.setTitle(title) _xmind_workbook.addSheet(_new_sheet) xmind.save(_xmind_workbook, self.get_full_file_path(user_id, \ _current_file)) return True except: return False
def gen_my_xmind_file(): with open(json_file, 'rt') as f: jdata = json.loads(f.read(), object_pairs_hook=OrderedDict) for k1, v1 in jdata.items(): xmind_file = os.path.join(root_path, "{}.xmind".format(k1)) workbook = xmind.load(xmind_file) sheet1 = workbook.getPrimarySheet() design_sheet1(sheet1, k1, v1) xmind.save(workbook)
def gen_my_xmind_file(): workbook = xmind.load("my.xmind") sheet1 = workbook.getPrimarySheet() # 对第一个画布进行设计完善,具体参照下一个函数 design_sheet1(sheet1) # 3、创建第二个画布 gen_sheet2(workbook, sheet1) # 4、保存(如果指定path参数,另存为该文件名) xmind.save(workbook, path='test.xmind')
def save(self, name=None): if not self.is_zen: xmind.save(self.workbook, name or self.name) else: with ZipFile(name or self.name, 'w') as x: x.writestr( 'content.json', json.dumps(self.content, ensure_ascii=False, indent=3)) manifest = '{"file-entries":{"content.json":{},"metadata.json":{},"":{}}}' metadata = '{"creator":{"name":"Vana","version":"10.1.1.202003310622"}}' x.writestr('manifest.json', manifest) x.writestr('metadata.json', metadata)
def create(self, user_id: str, title: str) -> bool: try: _path, _sheet, _wb, _current_file = self.get_sheet(user_id) _topic_element = self.get_topic_by_path(_sheet, _path) _new_topic = TopicElement(ownerWorkbook=_wb) _new_topic.setTitle(title) _topic_element.addSubTopic(_new_topic) xmind.save(_wb, self.get_full_file_path(user_id, \ _current_file.file_name)) return True except Exception as _ex: print(_ex) return False
def gen_my_xmind_file(name, post_form, form_items, file_dic): file_path = "./" + name + ".xmind" workbook = xmind.load(file_path) # get the first sheet(a new workbook has a blank sheet by default) sheet1 = workbook.getPrimarySheet() # design_sheet1(sheet1, name, number , address, flow) write_sheet(sheet1, name, post_form, form_items, file_dic) try: xmind.save(workbook, path=file_path) return True except Exception: return False
def delete(self, user_id: str, virtual_index: int) -> bool: try: _xmind_workbook, _current_file = self.get_workbook(user_id) _sheets = [sheet.getTitle() for sheet in _xmind_workbook.getSheets()] _response_container = ResponseContainer(_sheets) _sheet_to_use = \ _response_container.get_title_by_index(virtual_index) _old_index = _sheets.index(_sheet_to_use) _xmind_workbook.removeSheet(_xmind_workbook.getSheets()[_old_index]) xmind.save(_xmind_workbook, self.get_full_file_path(user_id, \ _current_file)) return True except: return False
def get_wiki_page(url): r = requests.get(url, auth=(wiki_user, wiki_password)) body = r.text w = xmind.load('test.xmind') s1 = w.getPrimarySheet() r1 = s1.getRootTopic() # r1.setTitle('SRS') feature = r1.addSubTopic() feature.setTitle('Some Feature') Parser(feature, body).html_to_xmind() xmind.save(w, "test.xmind") # test_xmind_file("srs") # parse_html() # get_wiki_page(test_url)
def delete(self, user_id: str, virtual_index: int) -> bool: _path_item, _sheet, _wb, _current_file = self.get_sheet(user_id) _topic_element = self.get_topic_by_path(_sheet, _path_item) _childs = _topic_element.getFirstChildNodeByTagName(const.TAG_CHILDREN) # Direct maninupation with DOM -- Begin -- _first_child = _childs.firstChild if len(_first_child.childNodes) <= virtual_index: return False _first_child.removeChild(_first_child.childNodes[virtual_index]) # Direct maninupation with DOM -- End -- xmind.save(_wb, self.get_full_file_path(user_id, \ _current_file.file_name)) return True
def genTree(self): topicList = [] max = 0 targetPath = './target' isExists = os.path.exists(targetPath) if not isExists: os.mkdir(targetPath) w = xmind.load( self.xFileName ) # load an existing file or create a new workbook if nothing is found s1 = w.getPrimarySheet() # get the first sheet s1.setTitle(self.mainTitle) # set its title r1 = s1.getRootTopic() # get the root topic of this sheet r1.setTitle(mainTitle) # set its title for key in self.lineDic.keys(): keyLen = len(key) if (keyLen > max): max = keyLen print('max len tags') print(max) for i in range(1, max + 1, 2): if (i == 1): oneList = [x for x in self.lineDic.keys() if len(x) == i] for onekey in oneList: topTopic = r1.addSubTopic() topTopic.setTitle(self.lineDic[onekey][0]) topTopic.setPlainNotes(self.lineDic[onekey][1]) topicList.append(topTopic) else: moreList = [x for x in self.lineDic.keys() if len(x) == i] for morekey in moreList: supKey = morekey[0:i - 2] print('process key------') #print(str(supKey)) for findr in topicList: findkey = findr.getTitle().split()[0] if findkey == supKey: subTopic = findr.addSubTopic() subTopic.setTitle(self.lineDic[morekey][0]) subTopic.setPlainNotes(self.lineDic[morekey][1]) topicList.append(subTopic) break else: continue xmind.save(w, self.xFileName) print('Process Success-------')
def toc_to_xmind(outfp, pdf_filename): """ Convert table of contents of given PDF file to XMind document. """ out_str = io.StringIO() dumppdf.dumpoutline(out_str, pdf_filename, [], set()) # Parse XML toc_xml = out_str.getvalue() out_str.close() # no 'with' statement possible root_elem = etree.fromstring(toc_xml) # Convert XML to XMind document xwb = xmind.load( outfp ) # load an existing file or create a new workbook if nothing is found # Create XMind workbook s1 = xwb.getPrimarySheet() s1.setTitle(os.path.split(pdf_filename)[-1]) root_topic = s1.getRootTopic() root_topic.setTitle("Contents") # Transform each XML node into a mindmap node topic_stack = [root_topic ] # length will always equal depth/level during traversal prev_level = 0 for node in root_elem.iter(): # depth-first traversal if 'level' not in node.attrib: continue # irrelevant node node_level = int(node.attrib['level']) # Create topic for this node topic = TopicElement(ownerWorkbook=xwb) title = re.sub(r"^[a-zA-Z]'(.*)'$", r'\1', node.attrib['title']) topic.setTitle(title) # Add it to the topic tree level_difference = node_level - prev_level for _ in range(-level_difference + 1): # negative yields empty list topic_stack.pop() topic_stack[-1].addSubTopic(topic) topic_stack.append(topic) prev_level = node_level xmind.save(xwb)
def export_xmind_api(xmind_dic): for projectName, json_value in xmind_dic.items(): file_name = projectName unix_time = int(time.time()) new_filename = str(unix_time) if not os.path.exists(CONFIG.DOWNLOADS_DIR): os.makedirs(CONFIG.DOWNLOADS_DIR) file_dir = CONFIG.DOWNLOADS_DIR + "{0}{1}.xmind".format( file_name, new_filename) workbook = xmind.load(file_dir) sheet1 = workbook.getPrimarySheet() sheet1.setTitle(projectName) rootTop1 = sheet1.getRootTopic() rootTop1.setTitle(projectName) for systemName, json_value in json_value.items(): # system_topic = rootTop1.addSubTopic(topics_type = TOPIC_DETACHED) system_topic = rootTop1.addSubTopic() # system_topic.setTopicHyperlink(sheet1.getID()) system_topic.setTitle(systemName) for moudleName, json_value in json_value.items(): moudle_topic = system_topic.addSubTopic() moudle_topic.setTitle(moudleName) for typeName, json_value in json_value.items(): type_topic = moudle_topic.addSubTopic() type_topic.setTitle(typeName) for suiteName, json_value in json_value.items(): suite_topic = type_topic.addSubTopic() suite_topic.setTitle(suiteName) for sceneType, json_value in json_value.items(): scene_topic = suite_topic.addSubTopic() scene_topic.setTitle(sceneType) for testcaseName, json_value in json_value.items(): testcase_topic = scene_topic.addSubTopic() testcase_topic.setTitle(testcaseName) for expect, json_value in json_value.items(): expect_topic = testcase_topic.addSubTopic() expect_topic.setTitle(expect) for expectResult, json_value in json_value.items( ): expectResult_topic = expect_topic.addSubTopic( ) expectResult_topic.setTitle( expectResult) xmind.save(workbook) return file_name + new_filename + '.xmind'
def dict2xmind(dicts, filename, path): file_path = os.path.join(os.path.abspath(path), filename + ".xmind") if os.path.exists(file_path): os.remove(file_path) workbook = xmind.load(file_path) sheet = workbook.getPrimarySheet() sheet.setTitle(dicts['name']) root_topic = sheet.getRootTopic() root_topic.setTitle(dicts['name']) dict_ite(dicts['scene'], root_topic, {}) for next_ in nextRequestName: if next_ in requestName: sheet.createRelationship(nextRequestName[next_], requestName[next_], '') xmind.save(workbook, file_path)
def create(self, user_id: str, title: str) -> bool: _user: UserObject = self.create_user_object(user_id) _file_operations: FileOperations = FileOperations(_user) try: _file_operations.create(title) _, _meta_json = self.read_meta_file(user_id) _current_file = _meta_json.current_file.file_name _xmind_workbook = xmind.load(self.get_full_file_path(user_id, \ _current_file)) _sheet = _xmind_workbook.getPrimarySheet() _sheet.setTitle('NewSheet') _topic = _sheet.getRootTopic() _topic.setTitle('NewTopic') xmind.save(_xmind_workbook, self.get_full_file_path(user_id, \ _current_file)) except Exception as ex: print(ex) return False return True
def parse_html(): path = Path.cwd().joinpath("output") # Load xmind file to write w = xmind.load('test.xmind') s1 = w.createSheet() r1 = s1.getRootTopic() r1.setTitle('SRS') for s in path.iterdir(): path_section = s # Set a section in map section = r1.addSubTopic() section.setTitle(s.name) for l in path_section.iterdir(): # Set a feature in map feature = section.addSubTopic() feature.setTitle(l.stem) with l.open() as f: content = f.read() Parser(feature, content).html_to_xmind() xmind.save(w, "test.xmind")
def dictToXmind(self, dictslist, filename, startnodemessage, path): file_str = path + "/" + filename + ".xmind" # 先删除文件 if os.path.exists(file_str): os.remove(file_str) workbook = xmind.load( file_str ) # load an existing file or create a new workbook if nothing is found sheet = workbook.getPrimarySheet() # get the first sheet sheet.setTitle(filename) # set its title rtopic_sheet = sheet.getRootTopic() # get the root topic of this sheet #中心 rtopic_sheet.setTitle(startnodemessage) # set its title if self.dict_ite(dictslist, rtopic_sheet): xmind.save(workbook, file_str) pass return True else: return False
def transExcel(self): outFileName, outFiltr = QtGui.QFileDialog.getSaveFileName(self,self.tr(u"保存Xmind文件"), os.getcwd(), self.tr("Xmind Files (*.xmind )")) if not outFileName: return False sheet,sheetName = self.loadExcel(self.orinFile) caseList = self.readSheet(sheet) if not caseList: return False workbook = self.generateXmind(caseList,sheetName) if workbook is not None: line1 = "转换Excel至Xmind成功:"+"\n" line2 = "需求名称: " +sheetName + "\n" line3 = "共%d条用例" %(len(caseList)) + "\n" line4 = "输出文件地址:" + outFileName + "\n" self.ui.textBrowser.insertPlainText(line1+line2+line3+line4) xmind.save(workbook, outFileName) self.initProgressDialog(1) self.updateProgressDialog() else: return False
def creatXmindFile(data): module=[] for item in data: module.append(item['module']) module=list(set(module)) print(module) w = xmind.load("test3.xmind") # load an existing file or create a new workbook if nothing is found s2=w.createSheet() # create a new sheet s2.setTitle("框架") r2=s2.getRootTopic() r2.setTitle("框架") for i in range(len(module)): t=TopicElement() t.setTitle(module[i]) r2.addSubTopic(t) w.addSheet(s2) # the second sheet is now added to the workbook r2_topics=r2.getSubTopics() # to loop on the subTopics for topic in r2_topics: topic_name=topic.getTitle() print (topic_name) for item in data: if topic_name == item['module'] : index=topic.getIndex() t=TopicElement() content=item['caseId']+" "+'\n'+item['summary'] t.setTitle(content) r2_topics[index].addSubTopic(t) summary=t.getTitle() for item in data: if item['summary'] in summary: t1=TopicElement() content1=item['name'] t1.setTitle(content1) t.addSubTopic(t1) xmind.save(w,"test3.xmind") # and we save
def draw(self): try: os.remove(self.res_file) except FileNotFoundError: pass # 创建 sheet workbook = xmind.load(self.res_file) sheet = workbook.createSheet() # 创建根节点 root = self._get_top( 1, None, )[0] sheet.setTitle(root) rt = sheet.getRootTopic() rt.setTitle(root) # 创建子节点 self.ignore_topics = {root} self._add_child_topic(rt, root, 0) xmind.save(workbook)
def export_xmind_base(xmind_dic): for projectName, json_value in xmind_dic.items(): file_name = projectName unix_time = int(time.time()) new_filename = str(unix_time) if not os.path.exists(CONFIG.DOWNLOADS_DIR): os.makedirs(CONFIG.DOWNLOADS_DIR) file_dir = CONFIG.DOWNLOADS_DIR + "{0}{1}.xmind".format( file_name, new_filename) workbook = xmind.load(file_dir) sheet1 = workbook.getPrimarySheet() sheet1.setTitle(projectName) rootTop1 = sheet1.getRootTopic() rootTop1.setTitle(projectName) for systemName, json_value in json_value.items(): system_topic = rootTop1.addSubTopic() system_topic.setTitle(systemName) for moudleName, json_value in json_value.items(): moudle_topic = system_topic.addSubTopic() moudle_topic.setTitle(moudleName) '''模块最后一级''' Multi_layer_module(json_value, moudle_topic) xmind.save(workbook) return file_name + new_filename + '.xmind'
from xmind.core.topic import TopicElement from xmind.core import workbook,saver import xmind myWorkbook = xmind.load("please-always-overwrite-the-output.xmind") # load an existing file or create a new workbook if nothing is found mainSheet=myWorkbook.getPrimarySheet() mainSheet.setTitle("first sheet") rootTopic=mainSheet.getRootTopic() rootTopic.setTitle("root node") topics = ["first", "second", "third", "fourth", "fifth"] for topic in topics: newTopic = TopicElement() # Initialize topic object newTopic.setTitle(topic) # Set node text rootTopic.addSubTopic(newTopic) # Attach the topic to the root topic myWorkbook.addSheet(mainSheet) # the second sheet is now added to the workbook xmind.save(myWorkbook,"test.xmind") # and we save
def get_testcase_list(topic): testcase_list = [] testcase_list_init(topic ,testcase_list) return testcase_list get_LSubTopics(w.getSheets()[2].getRootTopic()) print '------------------' #终点节点的个数 print LSubTopics print LSubTopics.__len__() print getParentTopicByID_Dic print getParentTopicByID_Dic.__len__() print getTopicByID_Dic print getTopicByID_Dic.__len__() print '==============================' #获取第一条用例的结尾部分 print LSubTopics[0].getTitle() print LSubTopics[0].addMarker("yes") #获取第一条用例的用例情况 print get_testcase_list(LSubTopics[0]) print '+++++++++++++++++++++++++++++' xmind.save(w, "test3.xmind")
def getCommentsByID(issue_id): comments = '' for i in connection.getIssue(issue_id).getComments(): comments += "[" + i.authorFullName + "]" + "\n" + i.text + '\n\n' return comments.encode('utf-8') def getChild(issue_id, level, t): # print level, Id top = TopicElement() # Split on '->' due to issue title on TRAR project top.setTitle(connection.getIssue(issue_id).summary.split('->')[-1]) top.addMarker(setImpStatus(issue_id)) top.addMarker(setPriority(issue_id)) top.addMarker(setState(issue_id)) top.setURLHyperlink(server + 'issue/' + issue_id) comments = getCommentsByID(issue_id) if len(comments) > 0: top.setPlainNotes(comments) t.addSubTopic(top) for i in getSubtasks(issue_id): getChild(i.id, level+1, top) for parent in getSuperParents(issues_list): getChild(parent, 0, root_primary) xmind.save(issue_map, category + ".xmind") print category + '.xmind' + ' created'
items = {} root_items = [] # Create all the items for i in tree.iter('item'): key = i.find('key').text summary = i.find('summary').text status = i.find('status').text description = i.find('description').text url = i.find('link').text children = [k.text for k in i.findall("issuelinks/issuelinktype[@id='10000']/inwardlinks/issuelink/issuekey")] parents = [k.text for k in i.findall("issuelinks/issuelinktype[@id='10000']/outwardlinks/issuelink/issuekey")] items[key] = { 'summary': summary, 'status': status, 'url': url, 'description': description, 'children': children, 'parents': parents } if len(parents) == 0: root_items.append(key) # Display the Tree w = xmind.load('new.xmind') s1 = w.getPrimarySheet() s1.setTitle("SPHERES Jira tickets") r1 = s1.getRootTopic() r1.setTitle("SPHERES") for k in root_items: add_item(items, k, r1) xmind.save(w, args.destination)
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") # then the topics must be added to the root element r2.addSubTopic(t1) r2.addSubTopic(t2) r2.addSubTopic(t3) r2.addSubTopic(t4) topics=r2.getSubTopics() # to loop on the subTopics for topic in topics: topic.addMarker("yes") w.addSheet(s2) # the second sheet is now added to the workbook rel=s2.createRelationship(t1.getID(),t2.getID(),"test") # create a relationship s2.addRelationship(rel) # and add to the sheet xmind.save(w,"test2.xmind") # and we save
t3 = r2.addSubTopic() t3.setTitle("third node") t3.setPlainNotes("notes for this topic") t3.setTitle("topic with \n notes") # Create a topic with a file hyperlink t4 = r2.addSubTopic() t4.setFileHyperlink("logo.jpeg") t4.setTitle("topic with a file") # Create topic that is a subtopic of another topic t41 = t4.addSubTopic() t41.setTitle("a subtopic") # create a detached topic whose (invisible) parent is the root d1 = r2.addSubTopic(topics_type = TOPIC_DETACHED) d1.setTitle("detached topic") d1.setPosition(0,20) # loop on the (attached) subTopics topics=r2.getSubTopics() # Demonstrate creating a marker for topic in topics: topic.addMarker(MarkerId.starBlue) # create a relationship rel=s2.createRelationship(t1.getID(),t2.getID(),"test") # and we save xmind.save(w,"test2.xmind")