...
[iramuteq] / tree.py
diff --git a/tree.py b/tree.py
index 532457f..12627f4 100644 (file)
--- a/tree.py
+++ b/tree.py
@@ -18,6 +18,7 @@ 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')
 
@@ -127,6 +128,7 @@ class LeftTree(CT.CustomTreeCtrl):
         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['simiclustermatrix'] = 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())
         self.SetImageList(self.il)
         
@@ -142,7 +144,7 @@ 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)     
@@ -164,7 +166,7 @@ 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)
@@ -392,11 +394,11 @@ class LeftTree(CT.CustomTreeCtrl):
                 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'))
+                reinert = classification.Append(wx.ID_ANY, _(u"Reinert's 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'))
+                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'))
@@ -444,6 +446,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'))
@@ -455,6 +459,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)
@@ -717,8 +723,11 @@ class LeftTree(CT.CustomTreeCtrl):
         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):
@@ -741,7 +750,25 @@ class LeftTree(CT.CustomTreeCtrl):
     
     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, "Please Enter The New Item Name", 'Item Naming', 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 OnItemBackground(self, event):
 
@@ -970,6 +997,7 @@ class LeftTree(CT.CustomTreeCtrl):
         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')