X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=tree.py;h=a4c3aa3807de37dbd41f609a50bf169f6b7ab9fa;hp=aa4d00da2d032ecfc89ec167ea8ce32da9cf7e38;hb=148fe710bf14981c45e865e8b4ddb68333e62f7c;hpb=53df4af897991ea260f0b57e4b0f7826f6409860 diff --git a/tree.py b/tree.py index aa4d00d..a4c3aa3 100644 --- a/tree.py +++ b/tree.py @@ -11,16 +11,38 @@ import logging from openanalyse import OpenAnalyse from corpus import Corpus, copycorpus from tableau import Tableau, copymatrix -from functions import DoConf, GetTxtProfile, TGen +from functions import DoConf, GetTxtProfile, TGen, BugReport, open_folder from profile_segment import ProfileSegment, ProfilType from search_tools import SearchFrame from dialog import PrefSimpleFile, PrefExport from layout import open_antiprofil, TgenLayout from guifunct import TGenFrame from textaslexico import TgenSpec +from textreinert import TgenProf log = logging.getLogger('iramuteq.tree') +def buildmenu(menu, parent_menu): + for i in range(parent_menu.GetMenuItemCount()) : + item = parent_menu.FindItemByPosition(i) + itemid = item.GetId() + itemtext = item.GetText() + itemicon = item.GetBitmap() + nitem = wx.MenuItem(menu, itemid, itemtext) + nitem.SetBitmap(itemicon) + if item.IsSubMenu() : + nmenu = wx.Menu() + for val in item.GetSubMenu().GetMenuItems() : + itemid = val.GetId() + itemtext = val.GetText() + itemicon = val.GetBitmap() + nitem = wx.MenuItem(menu, itemid, itemtext) + nitem.SetBitmap(itemicon) + nmenu.AppendItem(nitem) + menu.AppendMenu(-1, item.GetText(), nmenu) + else : + menu.AppendItem(nitem) + class InfoDialog ( wx.Dialog ): def __init__( self, parent, txt, parametres ): @@ -104,28 +126,16 @@ class LeftTree(CT.CustomTreeCtrl): elif data.startswith("EVT_"): events.append(data) self.parent = parent + self.ira = parent self.events = events self.styles = treestyles self.item = None + self.il = wx.ImageList(16, 16) self.ild = {} - imgtextroot = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'textroot.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) - self.ild['alceste'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'reinert.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) - self.ild['corpus'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'textcorpus.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) - self.ild['wordcloud'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'wordcloud.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) - self.ild['stat'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'stats.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) - self.ild['simitxt'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'simitxt.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) - self.ild['clustersimitxt'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'clustersimitxt.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) - self.ild['clustercloud'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'clustercloud.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) - self.ild['spec'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'spec.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) - imgmatroot = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'matroot.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) - self.ild['matrix'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'matrix.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) - self.ild['freq'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'frequences.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) - self.ild['chi2'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'chi2.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) - self.ild['reinertmatrix'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'reinertmatrix.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) - self.ild['simimatrix'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'simimatrix.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) - self.ild['proto'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'proto.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) + for img in self.ira.images_analyses : + self.ild[img] = self.il.Add(self.ira.images_analyses[img]) self.SetImageList(self.il) self.count = 0 @@ -133,6 +143,13 @@ class LeftTree(CT.CustomTreeCtrl): self.history = parent.history self.h = self.history.history + + idopenfolder = wx.NewId() + accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL, ord('E'), idopenfolder)]) + self.SetAcceleratorTable(accel_tbl) + + self.Bind(wx.EVT_MENU, self.OnOpenFolder, id=idopenfolder) + self.root = self.AddRoot("Iramuteq") if not(self.GetAGWWindowStyleFlag() & CT.TR_HIDE_ROOT): @@ -140,10 +157,10 @@ class LeftTree(CT.CustomTreeCtrl): self.SetItemImage(self.root, 24, CT.TreeItemIcon_Normal) self.SetItemImage(self.root, 13, CT.TreeItemIcon_Expanded) - self.textroot = self.AppendItem(self.root, u'Corpus texte') + self.textroot = self.AppendItem(self.root, _(u'Textual corpus')) self.SetPyData(self.textroot, {'uuid': 'textroot'}) - self.SetItemImage(self.textroot, imgtextroot, CT.TreeItemIcon_Normal) - self.SetItemImage(self.textroot, imgtextroot, CT.TreeItemIcon_Expanded) + self.SetItemImage(self.textroot, self.ild['textroot'], CT.TreeItemIcon_Normal) + self.SetItemImage(self.textroot, self.ild['textroot'], CT.TreeItemIcon_Expanded) for corpus in reversed(self.h) : child = self.AppendItem(self.textroot, corpus['corpus_name']) @@ -162,10 +179,10 @@ class LeftTree(CT.CustomTreeCtrl): self.SetItemImage(last, img, CT.TreeItemIcon_Normal) self.SetItemImage(last, img, CT.TreeItemIcon_Expanded) - self.matroot = self.AppendItem(self.root, u'Matrices') + self.matroot = self.AppendItem(self.root, _(u'Matrix')) self.SetPyData(self.matroot, {'uuid': 'matroot'}) - self.SetItemImage(self.matroot, imgmatroot, CT.TreeItemIcon_Normal) - self.SetItemImage(self.matroot, imgmatroot, CT.TreeItemIcon_Expanded) + self.SetItemImage(self.matroot, self.ild['matroot'], CT.TreeItemIcon_Normal) + self.SetItemImage(self.matroot, self.ild['matroot'], CT.TreeItemIcon_Expanded) orphmat = [] for matrix in reversed(self.history.matrix) : @@ -382,53 +399,26 @@ class LeftTree(CT.CustomTreeCtrl): if not item in [self.textroot, self.matroot] : menu = wx.Menu() - info = menu.Append(wx.ID_ANY, _(u"Informations").encode('utf8')) - rename = menu.Append(wx.ID_ANY, _(u"Rename").encode('utf8')) + info = wx.MenuItem(menu, wx.ID_ANY, _(u"Informations").decode('utf8')) + info.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_INFORMATION, size = (16,16))) + menu.AppendItem(info) + + rename = wx.MenuItem(menu, wx.ID_ANY, _(u"Rename").decode('utf8')) + rename.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_TIP, size = (16,16))) + menu.AppendItem(rename) + + openfolder = wx.MenuItem(menu, wx.ID_ANY, _(u"Open directory").decode('utf8')) + openfolder.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FOLDER_OPEN, size = (16,16))) + menu.AppendItem(openfolder) + menu.AppendSeparator() if 'corpus_name' in pydata : - stat = menu.Append(wx.ID_ANY, _(u"Statistics").decode('utf8')) - spec = menu.Append(wx.ID_ANY, _(u"Specificities and CA").decode('utf8')) - classification = wx.Menu() - reinert = classification.Append(wx.ID_ANY, _(u"Reinert method").decode('utf8')) - #pam = classification.Append(wx.ID_ANY, u"Par matrice des distances") - menu.AppendMenu(-1, _(u"Clustering").decode('utf8'), classification) - simi = menu.Append(wx.ID_ANY, _(u"Similarities analysis").decode('utf8')) - wdc = menu.Append(wx.ID_ANY, _(u"Wordcloud").decode('utf8')) - subcorpus = wx.Menu() - subcorpusfrommeta = subcorpus.Append(wx.ID_ANY, _(u'Sub corpus from metadata').decode('utf8')) - subcorpusfromtheme = subcorpus.Append(wx.ID_ANY, _(u'Sub corpus from thematic').decode('utf8')) - menu.AppendMenu(-1, _(u"Sub corpus").decode('utf8'), subcorpus) + buildmenu(menu, self.parent.text_menu) menu.AppendSeparator() - self.Bind(wx.EVT_MENU, self.OnReinert, reinert) - #self.Bind(wx.EVT_MENU, self.OnPam, pam) - self.Bind(wx.EVT_MENU, self.OnStat, stat) - self.Bind(wx.EVT_MENU, self.OnSpec, spec) - self.Bind(wx.EVT_MENU, self.OnSimiTxt, simi) - self.Bind(wx.EVT_MENU, self.OnWordCloud, wdc) - self.Bind(wx.EVT_MENU, self.OnSubTextFromMeta, subcorpusfrommeta) - self.Bind(wx.EVT_MENU, self.OnSubTextFromTheme, subcorpusfromtheme) elif 'matrix_name' in pydata : - for i in range(self.parent.matrix_menu.GetMenuItemCount()) : - item = self.parent.matrix_menu.FindItemByPosition(i) - itemid = item.GetId() - itemtext = item.GetText() - menu.Append(itemid, itemtext) - split = wx.Menu() - splitfromvar = split.Append(-1, _(u"Split from variable").decode('utf8')) - menu.AppendMenu(-1, _(u"Split matrix").decode('utf8'), split) - self.Bind(wx.EVT_MENU, self.OnSplitFromVar, splitfromvar) - #print item, itemid, itemtext - #menu = self.parent.matrix_menu - #freq = menu.Append(wx.ID_ANY, _(u"Frequency").decode('utf8')) - #chi2 = menu.Append(wx.ID_ANY, _(u"Chi square").decode('utf8')) - #chdreinert = menu.Append(wx.ID_ANY, _(u"Reinert clustering").decode('utf8')) - #simi = menu.Append(wx.ID_ANY, _(u"Similarity analysis").decode('utf8')) + buildmenu(menu, self.parent.matrix_menu) menu.AppendSeparator() - #self.Bind(wx.EVT_MENU, self.OnFreq, freq) - #self.Bind(wx.EVT_MENU, self.OnChiSquare, chi2) - #self.Bind(wx.EVT_MENU, self.OnSimiTab, simi) - #self.Bind(wx.EVT_MENU, self.OnCHDReinert, chdreinert) elif pydata.get('type', False) == 'alceste' and pydata['uuid'] in self.parent.history.opened : openmenu = wx.Menu() antipro = openmenu.Append(wx.ID_ANY, _(u"Antiprofiles").decode('utf8')) @@ -436,6 +426,8 @@ class LeftTree(CT.CustomTreeCtrl): profsr = menu.Append(wx.ID_ANY, _(u"Repeated segments profiles").decode('utf8')) profgram = menu.Append(wx.ID_ANY, _(u"POS profiles").decode('utf8')) + tgen = menu.Append(wx.ID_ANY, _(u"Tgen Editor").decode('utf8')) + computetgen = menu.Append(wx.ID_ANY, _(u"Compute Tgen").decode('utf8')) export_corpus = menu.Append(wx.ID_ANY, _(u"Export corpus").decode('utf8')) colored = menu.Append(wx.ID_ANY, _(u"Colored corpus").decode('utf8')) navig = menu.Append(wx.ID_ANY, _(u"Navigator").decode('utf8')) @@ -447,6 +439,8 @@ class LeftTree(CT.CustomTreeCtrl): self.Bind(wx.EVT_MENU, self.OpenAntipro, antipro) self.Bind(wx.EVT_MENU, self.OnProfSR, profsr) self.Bind(wx.EVT_MENU, self.OnProfGram, profgram) + self.Bind(wx.EVT_MENU, self.OnTgenEditor, tgen) + self.Bind(wx.EVT_MENU, self.OnTgenCompute, computetgen) self.Bind(wx.EVT_MENU, self.OnExportCorpus, export_corpus) self.Bind(wx.EVT_MENU, self.OnColored, colored) self.Bind(wx.EVT_MENU, self.OnNavig, navig) @@ -474,8 +468,9 @@ class LeftTree(CT.CustomTreeCtrl): self.Bind(wx.EVT_MENU, self.OpenAntipro, antipro) self.Bind(wx.EVT_MENU, self.OnRapport, rapport) - - itemdelete = menu.Append(wx.ID_ANY, _(u"Delete from history").decode('utf8')) + itemdelete = wx.MenuItem(menu, wx.ID_ANY, _(u"Delete from history").decode('utf8')) + itemdelete.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_DELETE, size = (16,16))) + menu.AppendItem(itemdelete) #item11 = menu.Append(wx.ID_ANY, "Prepend An Item") #item12 = menu.Append(wx.ID_ANY, "Append An Item") @@ -490,6 +485,7 @@ class LeftTree(CT.CustomTreeCtrl): self.Bind(wx.EVT_MENU, self.OnItemInfo, info) self.Bind(wx.EVT_MENU, self.OnRename, rename) self.Bind(wx.EVT_MENU, self.OnItemDelete, itemdelete) + self.Bind(wx.EVT_MENU, self.OnOpenFolder, openfolder) #self.Bind(wx.EVT_MENU, self.OnItemPrepend, item11) #self.Bind(wx.EVT_MENU, self.OnItemAppend, item12) @@ -542,29 +538,29 @@ class LeftTree(CT.CustomTreeCtrl): def OnWordCloud(self, evt) : self.parent.OnWordCloud(evt, self.getcorpus()) - def OnFreq(self, evt): - self.parent.OnFreq(evt, self.getmatrix()) +# def OnFreq(self, evt): +# self.parent.OnFreq(evt, self.getmatrix()) - def OnChiSquare(self, evt): - self.parent.OnChi2(evt, self.getmatrix()) +# def OnChiSquare(self, evt): +# self.parent.OnChi2(evt, self.getmatrix()) - def OnSimiTab(self, evt): - self.parent.OnSimiTab(evt, self.getmatrix()) +# def OnSimiTab(self, evt): +# self.parent.OnSimiTab(evt, self.getmatrix()) - def OnProto(self, evt): - self.parent.OnProto(evt, self.getmatrix()) +# def OnProto(self, evt): +# self.parent.OnProto(evt, self.getmatrix()) - def OnSplitFromVar(self, evt): - self.parent.OnSplitVar(evt, self.getmatrix()) +# def OnSplitFromVar(self, evt): +# self.parent.OnSplitVar(evt, self.getmatrix()) - def OnCHDReinert(self, evt): - self.parent.OnCHDReinert(evt, self.getmatrix()) +# def OnCHDReinert(self, evt): +# self.parent.OnCHDReinert(evt, self.getmatrix()) - def OnSubTextFromMeta(self, evt): - self.parent.OnSubText(self.getcorpus(), parametres = {'frommeta' : True}) + #def OnSubTextFromMeta(self, evt): + # self.parent.OnSubText(self.getcorpus(), parametres = {'frommeta' : True}) - def OnSubTextFromTheme(self, evt): - self.parent.OnSubText(self.getcorpus(), parametres = {'fromtheme' : True}) + #def OnSubTextFromTheme(self, evt): + # self.parent.OnSubText(self.getcorpus(), parametres = {'fromtheme' : True}) def OnProfSR(self, evt) : ProfileSegment(self.parent, self.page.dictpathout, self.page.parametres, self.page.corpus) @@ -589,7 +585,7 @@ class LeftTree(CT.CustomTreeCtrl): self.page.corpus.export_corpus_classes(dial.fbb.GetValue(), alc = alc, lem = lem, uci = uci) msg = u"Fini !" dial.Destroy() - dlg = wx.MessageDialog(self.parent, msg, u"Export", wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION) + dlg = wx.MessageDialog(self.parent, msg, u"Export", wx.OK | wx.ICON_INFORMATION) dlg.CenterOnParent() dlg.ShowModal() dlg.Destroy() @@ -610,7 +606,7 @@ class LeftTree(CT.CustomTreeCtrl): with open(fileout, 'w') as f : f.write(txt) msg = ' !\n'.join([_(u"Done").decode('utf8'), _(u"Open in a web browser ?").decode('utf8')]) - dlg = wx.MessageDialog(self.parent, msg, u"Corpus en couleur", wx.NO | wx.YES | wx.NO_DEFAULT | wx.ICON_QUESTION) + dlg = wx.MessageDialog(self.parent, msg, u"Corpus en couleur", wx.NO | wx.YES | wx.ICON_QUESTION) dlg.CenterOnParent() if dlg.ShowModal() == wx.ID_YES : webbrowser.open(fileout) @@ -631,7 +627,7 @@ class LeftTree(CT.CustomTreeCtrl): dial.Destroy() self.page.corpus.get_stat_by_cluster(fileout) msg = u"Fini !" - dlg = wx.MessageDialog(self.parent, msg, _(u"Clusters statistics").decode('utf8'), wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION) + dlg = wx.MessageDialog(self.parent, msg, _(u"Clusters statistics").decode('utf8'), wx.OK | wx.ICON_INFORMATION) dlg.CenterOnParent() if dlg.ShowModal() == wx.ID_OK : dlg.Destroy() @@ -659,7 +655,7 @@ class LeftTree(CT.CustomTreeCtrl): with open(fileout, 'w') as f : f.write(self.page.debtext + '\n' + GetTxtProfile(self.page.DictProfile, self.page.cluster_size)) msg = u"Fini !" - dlg = wx.MessageDialog(self.parent, msg, _(u"Report").decode('utf8'), wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION) + dlg = wx.MessageDialog(self.parent, msg, _(u"Report").decode('utf8'), wx.OK | wx.ICON_INFORMATION) dlg.CenterOnParent() dlg.ShowModal() dlg.Destroy() @@ -703,14 +699,17 @@ class LeftTree(CT.CustomTreeCtrl): corpus = self.page.corpus tgenpath = os.path.join(self.page.parametres['pathout'], 'tgen.csv') if not os.path.exists(tgenpath) : - message = wx.MessageDialog(self.parent, _(u"No TGen yet !"), style = wx.ICON_EXCLAMATION | wx.OK) + message = wx.MessageDialog(self.parent, _(u"No TGen yet !").decode('utf8'), style = wx.ICON_EXCLAMATION | wx.OK) message.ShowModal() message.Destroy() else : self.page.parametres['tgenpath'] = tgenpath tgen = TGen(path = tgenpath, encoding = self.parent.syscoding) - self.page.parametres['etoiles'] = self.page.etoiles - TgenSpec(self.parent, corpus, self.page.parametres) + if self.page.parametres['type'] == 'spec' : + self.page.parametres['etoiles'] = self.page.etoiles + TgenSpec(self.parent, corpus, self.page.parametres) + elif self.page.parametres['type'] == 'alceste' : + TgenProf(self.parent, corpus, self.page.parametres, self.page.cluster_size) TgenLayout(self.page) def OnExportClasses(self, event): @@ -729,11 +728,35 @@ class LeftTree(CT.CustomTreeCtrl): dial.Destroy() def OnSubCorpusFromClusters(self, evt): - self.parent.OnSubText(self.getcorpus(), parametres = {'fromclusters' : True, 'clnb': self.page.parametres['clnb'], 'lc' : self.page.corpus.lc}) + self.parent.OnSubText(evt, corpus = self.getcorpus(), parametres = {'fromclusters' : True, 'clnb': self.page.parametres['clnb'], 'lc' : self.page.corpus.lc}) def OnRename(self, event): pydata = self.itemdict['pydata'] - print pydata + if 'matrix_name' in pydata : + name = 'matrix_name' + elif 'corpus_name' in pydata : + name = 'corpus_name' + else : + name = 'name' + oldname = pydata[name] + dlg = wx.TextEntryDialog(self, _("New Name").decode('utf8'), _(u'Rename').decode('utf8'), oldname) + if dlg.ShowModal() == wx.ID_OK: + newname = dlg.GetValue() + dlg.Destroy() + pydata[name] = newname + Totconf = DoConf(configfile=pydata['ira']) + conf = Totconf.getoptions() + conf[name] = newname + Totconf.makeoptions(Totconf.getsections(), [conf]) + self.history.update(pydata) + self.SetItemText(self.current, newname) + self.EnsureVisible(self.current) + + def OnOpenFolder(self, evt): + try : + open_folder(os.path.dirname(self.pydata['ira'])) + except : + print 'cannot open folder %s' % self.pydata.get('ira', 'noirapath') def OnItemBackground(self, event): @@ -947,20 +970,22 @@ class LeftTree(CT.CustomTreeCtrl): self.SetItemBold(item, bold) self.SelectItem(item) - def OnItemAppend(self, item): + def OnItemAppend(self, item, select = True): if 'corpus_name' in item : child = self.InsertItem(self.textroot, 0, item['corpus_name']) else : child = self.InsertItem(self.matroot, 0, item['matrix_name']) self.SetPyData(child, item) - self.history.addtab(item) if item['type'] in self.ild : img = self.ild[item['type']] else : img = 24 self.SetItemImage(child, img, CT.TreeItemIcon_Normal) self.SetItemImage(child, img, CT.TreeItemIcon_Expanded) - self.SetItemBold(child, True) + if select : + self.history.addtab(item) + self.SetItemBold(child, True) + self.SelectItem(child) #dlg = wx.TextEntryDialog(self, "Please Enter The New Item Name", 'Item Naming', 'Python') @@ -1022,12 +1047,19 @@ class LeftTree(CT.CustomTreeCtrl): elif pydata['uuid'] in ['textroot', 'matroot'] : pass else : - busy = wx.BusyInfo(_("Please wait..."), self.parent) - wx.SafeYield() - OpenAnalyse(self.parent, pydata) - del busy - self.SetItemBold(item, True) - self.OnSelChanged(pydata = pydata) + if os.path.exists(pydata['ira']) : + busy = wx.BusyInfo(_("Please wait..."), self.parent) + wx.SafeYield() + try : + OpenAnalyse(self.parent, pydata) + del busy + self.SetItemBold(item, True) + self.OnSelChanged(pydata = pydata) + except : + del busy + BugReport(self.ira) + else : + wx.MessageBox(_(u"This file does not exist : %s" % pydata['ira']).decode('utf8'), 'Information', wx.ICON_EXCLAMATION | wx.STAY_ON_TOP ) #if item and (flags & CT.TREE_HITTEST_ONITEMLABEL): # if self.GetAGWWindowStyleFlag() & CT.TR_EDIT_LABELS: # self.log.info("OnLeftDClick: %s (manually starting label edit)"% self.GetItemText(item) + "\n") @@ -1077,7 +1109,18 @@ class LeftTree(CT.CustomTreeCtrl): if event is not None : item = event.GetItem() pydata = self.GetPyData(item) + if pydata is not None : + if 'corpus_name' in pydata or 'corpus' in pydata : + self.ira.ShowMenu('matrix', False) + self.ira.ShowMenu('text', True) + if 'matrix_name' in pydata or 'matrix' in pydata: + self.ira.ShowMenu('text', False) + self.ira.ShowMenu('matrix', True) + if 'uuid' in pydata : + if pydata['uuid'] in ['textroot', 'matroot'] : + self.ira.ShowMenu('text', False) + self.ira.ShowMenu('matrix', False) self.pydata = pydata if pydata['uuid'] in self.parent.history.opened : for i in range(self.parent.nb.GetPageCount()) :