-#!/bin/env python
# -*- coding: utf-8 -*-
#Author: Pierre Ratinaud
#Copyright (c) 2012, Pierre Ratinaud
-#Lisense: GNU GPL
+#License: GNU GPL
import wx
import os
import wx.lib.agw.customtreectrl as CT
import logging
from openanalyse import OpenAnalyse
-from corpusNG import Corpus, copycorpus
-from functions import DoConf, GetTxtProfile
+from corpus import Corpus, copycorpus
+from tableau import Tableau, copymatrix
+from functions import DoConf, GetTxtProfile, TGen, BugReport, open_folder, translateprofile, ReadProfileAsDico, write_translation_profile, progressbar, doconcorde
from profile_segment import ProfileSegment, ProfilType
from search_tools import SearchFrame
-from dialog import PrefSimpleFile, PrefExport
-from layout import open_antiprofil
+from dialog import PrefSimpleFile, PrefExport, SearchCorpus, translate_dialog, PrefUCECarac
+from layout import open_antiprofil, TgenLayout
+from guifunct import TGenFrame
+from textaslexico import TgenSpec
+from textreinert import TgenProf
+from mergeclustergraph import MergeClusterGraph
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 ):
wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Informations", pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
if len(parametres) > 30 :
nb = 4
else :
- nb = 2
+ nb = 2
self.SetSizeHintsSz( wx.Size( 500,200 ), wx.DefaultSize )
-
+
bSizer1 = wx.BoxSizer( wx.VERTICAL )
-
+
self.m_panel2 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
bSizer2 = wx.BoxSizer( wx.VERTICAL )
-
+
self.m_staticText4 = wx.StaticText( self.m_panel2, wx.ID_ANY, txt, wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText4.Wrap( -1 )
bSizer2.Add( self.m_staticText4, 0, wx.ALL, 5 )
-
-
+
self.m_panel2.SetSizer( bSizer2 )
self.m_panel2.Layout()
bSizer2.Fit( self.m_panel2 )
bSizer1.Add( self.m_panel2, 0, wx.EXPAND |wx.ALL, 5 )
-
- self.m_panel1 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
+
+ self.m_panel1 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL|wx.VSCROLL )
fgSizer1 = wx.FlexGridSizer( 0, nb, 0, 0 )
+ fgSizer1.AddGrowableCol( 1 )
+ if nb == 4 :
+ fgSizer1.AddGrowableCol( 3 )
fgSizer1.SetFlexibleDirection( wx.BOTH )
- fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
-
+ fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_NONE )
+
txtctrl = []
for val in parametres :
fgSizer1.Add( wx.StaticText( self.m_panel1, wx.ID_ANY, val[0], wx.DefaultPosition, wx.DefaultSize, 0 ), 0, wx.ALL, 0)
self.m_panel1.SetSizer( fgSizer1 )
self.m_panel1.Layout()
fgSizer1.Fit( self.m_panel1 )
- bSizer1.Add( self.m_panel1, 0, wx.EXPAND|wx.ALL, 3 )
-
+ bSizer1.Add( self.m_panel1, 1, wx.EXPAND|wx.ALL, 3 )
+
m_sdbSizer1 = wx.StdDialogButtonSizer()
self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
m_sdbSizer1.Realize();
-
+
bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
-
-
+
self.SetSizer( bSizer1 )
self.Layout()
bSizer1.Fit( self )
-
self.Centre( wx.BOTH )
-
+
def __del__( self ):
pass
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
size=wx.DefaultSize,
style=wx.SUNKEN_BORDER|wx.WANTS_CHARS,
- agwStyle=CT.TR_HAS_BUTTONS|CT.TR_HAS_VARIABLE_ROW_HEIGHT):
+ agwStyle=CT.TR_HIDE_ROOT|CT.TR_HAS_BUTTONS|CT.TR_HAS_VARIABLE_ROW_HEIGHT):
CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style, agwStyle)
+ #FIXME : test for bigger font on HIDPI screen
+ font = wx.Font(pointSize=12, family=wx.DEFAULT, style=wx.NORMAL, weight=wx.FONTWEIGHT_NORMAL,
+ underline=False, face="", encoding=wx.FONTENCODING_DEFAULT)
+ self.SetFont(font)
+ ##################
self.log = log
alldata = dir(CT)
treestyles = []
elif data.startswith("EVT_"):
events.append(data)
self.parent = parent
+ self.ira = parent
self.events = events
self.styles = treestyles
self.item = None
-
- il = wx.ImageList(16, 16)
+
+
+ self.il = wx.ImageList(16, 16)
+ self.ild = {}
+ 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
self.log = log
self.history = parent.history
self.h = self.history.history
+
+ idopenfolder = wx.NewId()
+ #accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL, ord('E'), idopenfolder)])
+ self.Bind(wx.EVT_MENU, self.OnOpenFolder, id=idopenfolder)
+
+ idsearchcorpus = wx.NewId()
+ accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL, ord('E'), idopenfolder), (wx.ACCEL_CTRL, ord('F'), idsearchcorpus)])
+ self.Bind(wx.EVT_MENU, self.OnSearchCorpus, id=idsearchcorpus)
+ self.SetAcceleratorTable(accel_tbl)
+
self.root = self.AddRoot("Iramuteq")
if not(self.GetAGWWindowStyleFlag() & CT.TR_HIDE_ROOT):
self.SetItemImage(self.root, 24, CT.TreeItemIcon_Normal)
self.SetItemImage(self.root, 13, CT.TreeItemIcon_Expanded)
- for corpus in self.h :
- child = self.AppendItem(self.root, corpus['corpus_name'])
+ self.textroot = self.AppendItem(self.root, _(u'Textual corpus'))
+ self.SetPyData(self.textroot, {'uuid': 'textroot'})
+ 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'])
self.SetPyData(child, corpus)
- self.SetItemImage(child, 24, CT.TreeItemIcon_Normal)
- self.SetItemImage(child, 13, CT.TreeItemIcon_Expanded)
+ self.SetItemImage(child, self.ild['corpus'], CT.TreeItemIcon_Normal)
+ self.SetItemImage(child, self.ild['corpus'], CT.TreeItemIcon_Expanded)
if 'analyses' in corpus :
for y in corpus['analyses'] :
last = self.AppendItem(child, y['name'], ct_type=0)
-
self.SetPyData(last, y)
- self.SetItemImage(last, 24, CT.TreeItemIcon_Normal)
- self.SetItemImage(last, 13, CT.TreeItemIcon_Expanded)
-
+ if y['type'] in self.ild :
+ img = self.ild[y['type']]
+ else :
+ img = 24
+ self.SetItemImage(last, img, CT.TreeItemIcon_Normal)
+ self.SetItemImage(last, img, CT.TreeItemIcon_Expanded)
+
+ self.matroot = self.AppendItem(self.root, _(u'Matrix'))
+ self.SetPyData(self.matroot, {'uuid': 'matroot'})
+ 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) :
+ if 'matrix_name' in matrix :
+ child = self.AppendItem(self.matroot, matrix['matrix_name'])
+ self.SetPyData(child, matrix)
+ self.SetItemImage(child, self.ild['matrix'], CT.TreeItemIcon_Normal)
+ self.SetItemImage(child, self.ild['matrix'], CT.TreeItemIcon_Expanded)
+ if 'analyses' in matrix :
+ for y in matrix['analyses'] :
+ last = self.AppendItem(child, y['name'], ct_type=0)
+ self.SetPyData(last, y)
+ if y['type'] in self.ild :
+ img = self.ild[y['type']]
+ else :
+ img = 24
+ self.SetItemImage(last, img, CT.TreeItemIcon_Normal)
+ self.SetItemImage(last, img, CT.TreeItemIcon_Expanded)
+ else :
+ orphmat.append(matrix)
+
self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick)
#self.Bind(wx.EVT_IDLE, self.OnIdle)
'EVT_TREE_SEL_CHANGING': self.OnSelChanging, "EVT_TREE_ITEM_HYPERLINK": self.OnHyperLink}
mainframe = wx.GetTopLevelParent(self)
-
+
if not hasattr(mainframe, "leftpanel"):
#self.Bind(CT.EVT_TREE_ITEM_EXPANDED, self.OnItemExpanded)
#self.Bind(CT.EVT_TREE_ITEM_COLLAPSED, self.OnItemCollapsed)
value = choice.GetValue()
text = choice.GetLabel()
-
+
evt = "CT." + text
binder = self.eventdict[text]
if self.GetAGWWindowStyleFlag() != style:
self.SetAGWWindowStyleFlag(style)
-
+
def OnCompareItems(self, item1, item2):
-
+
t1 = self.GetItemText(item1)
t2 = self.GetItemText(item2)
-
if t1 < t2:
return -1
return 1
-
def OnIdle(self, event):
# if self.gauge:
self.CloseItem(child, uuid)
child, cookie = self.GetNextChild(itemParent, cookie)
- def GiveFocus(self, itemParent = None, uuid = None) :
+ def GiveFocus(self, itemParent = None, uuid = None, bold = False) :
if itemParent is None :
itemParent = self.root
child, cookie = self.GetFirstChild(itemParent)
pydata = self.GetPyData(child)
if pydata['uuid'] == uuid :
self.SelectItem(child)
- break
+ if bold :
+ self.SetItemBold(child, True)
+ return
+ self.GiveFocus(child, uuid, bold)
+ child, cookie = self.GetNextChild(itemParent, cookie)
+
+ def IsInTree(self, itemParent = None, uuid = None) :
+ if itemParent is None :
+ itemParent = self.root
+ child, cookie = self.GetFirstChild(itemParent)
+
+ while child :
+ pydata = self.GetPyData(child)
+ if pydata['uuid'] == uuid :
+ return True
self.GiveFocus(child, uuid)
child, cookie = self.GetNextChild(itemParent, cookie)
+ return False
+
def OnRightDown(self, event):
-
pt = event.GetPosition()
item, flags = self.HitTest(pt)
def OnRightUp(self, event):
item = self.item
-
+
if not item:
event.Skip()
return
text = self.GetItemText(item)
pydata = self.GetPyData(item)
self.pydata = pydata
-
+
self.current = item
self.itemdict = {"ishtml": ishtml, "back": back, "fore": fore, "isbold": isbold,
"font": font, "normal": normal, "selected": selected, "expanded": expanded,
"selexp": selexp, "haswin": haswin, "children": children,
"itemtype": itemtype, "text": text, "pydata": pydata, "enabled": enabled}
-
- menu = wx.Menu()
- info = menu.Append(wx.ID_ANY, "Informations")
- menu.AppendSeparator()
- if 'corpus_name' in pydata :
- stat = menu.Append(wx.ID_ANY, u"Statistiques")
- spec = menu.Append(wx.ID_ANY, u"Spécificté et AFC")
- classification = wx.Menu()
- alceste = classification.Append(wx.ID_ANY, u"Méthode ALCESTE")
- pam = classification.Append(wx.ID_ANY, u"Par matrice des distances")
- menu.AppendMenu(-1, u"Classification", classification)
- simi = menu.Append(wx.ID_ANY, u"Analyse de similitude")
- wdc = menu.Append(wx.ID_ANY, u"Nuage de mots")
- menu.AppendSeparator()
- self.Bind(wx.EVT_MENU, self.OnAlceste, alceste)
- 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)
- elif pydata.get('type', False) == 'alceste' and pydata['uuid'] in self.parent.history.opened :
- openmenu = wx.Menu()
- antipro = openmenu.Append(wx.ID_ANY, u"antiprofils")
- menu.AppendMenu(wx.ID_ANY, u"Ouvrir...", openmenu)
-
- profsr = menu.Append(wx.ID_ANY, u"Profils des segments répétés")
- profgram = menu.Append(wx.ID_ANY, u"Profils des types")
- export_corpus = menu.Append(wx.ID_ANY, u"Exporter le corpus")
- colored = menu.Append(wx.ID_ANY, u"Corpus en couleur")
- navig = menu.Append(wx.ID_ANY, u"Outil de navigation")
- statclasse = menu.Append(wx.ID_ANY, u"Statistiques par classe")
- rapport = menu.Append(wx.ID_ANY, u"Rapport")
-
+ if not item in [self.textroot, self.matroot] :
+ menu = wx.Menu()
+ 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()
-
- 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.OnExportCorpus, export_corpus)
- self.Bind(wx.EVT_MENU, self.OnColored, colored)
- self.Bind(wx.EVT_MENU, self.OnNavig, navig)
- self.Bind(wx.EVT_MENU, self.StatClasse, statclasse)
- self.Bind(wx.EVT_MENU, self.OnRapport, rapport)
-
-
- itemdelete = menu.Append(wx.ID_ANY, "Supprimer de l'historique")
- if item == self.GetRootItem():
- itemdelete.Enable(False)
- #item11 = menu.Append(wx.ID_ANY, "Prepend An Item")
- #item12 = menu.Append(wx.ID_ANY, "Append An Item")
-
- #self.Bind(wx.EVT_MENU, self.OnItemBackground, item1)
- #self.Bind(wx.EVT_MENU, self.OnItemForeground, item2)
- #self.Bind(wx.EVT_MENU, self.OnItemBold, item3)
- #self.Bind(wx.EVT_MENU, self.OnItemFont, item4)
- #self.Bind(wx.EVT_MENU, self.OnItemHyperText, item5)
- #self.Bind(wx.EVT_MENU, self.OnEnableWindow, item6)
- #self.Bind(wx.EVT_MENU, self.OnDisableItem, item7)
- #self.Bind(wx.EVT_MENU, self.OnItemIcons, item8)
- self.Bind(wx.EVT_MENU, self.OnItemInfo, info)
- self.Bind(wx.EVT_MENU, self.OnItemDelete, itemdelete)
- #self.Bind(wx.EVT_MENU, self.OnItemPrepend, item11)
- #self.Bind(wx.EVT_MENU, self.OnItemAppend, item12)
-
- self.PopupMenu(menu)
- menu.Destroy()
+
+ if 'corpus_name' in pydata :
+ buildmenu(menu, self.parent.text_menu)
+ menu.AppendSeparator()
+ elif 'matrix_name' in pydata :
+ buildmenu(menu, self.parent.matrix_menu)
+ menu.AppendSeparator()
+ 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'))
+ menu.AppendMenu(wx.ID_ANY, _(u"Open ...").decode('utf8'), openmenu)
+
+ translate = menu.Append(wx.ID_ANY, _(u"Translate Profile").decode('utf8'))
+ profsr = menu.Append(wx.ID_ANY, _(u"Repeated segments profiles").decode('utf8'))
+ profgram = menu.Append(wx.ID_ANY, _(u"POS profiles").decode('utf8'))
+ stcaract = menu.Append(wx.ID_ANY, _(u"Typical text segments").decode('utf8'))
+ tgen = menu.Append(wx.ID_ANY, _(u"Tgen Editor").decode('utf8'))
+ computetgen = menu.Append(wx.ID_ANY, _(u"Compute Tgen").decode('utf8'))
+ mergeclustergraph = menu.Append(wx.ID_ANY, _(u"Merge Cluster Graph").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'))
+ statclasse = menu.Append(wx.ID_ANY, _(u"Clusters statistics").decode('utf8'))
+ rapport = menu.Append(wx.ID_ANY, _(u"Report").decode('utf8'))
+ export_classes = menu.Append(wx.ID_ANY, _(u"Export clusters").decode('utf8'))
+ subcorpusfromcl = menu.Append(wx.ID_ANY, _(u"Sub corpus from clusters").decode('utf8'))
+ menu.AppendSeparator()
+ self.Bind(wx.EVT_MENU, self.OpenAntipro, antipro)
+ self.Bind(wx.EVT_MENU, self.OnTranslate, translate)
+ self.Bind(wx.EVT_MENU, self.OnProfSR, profsr)
+ self.Bind(wx.EVT_MENU, self.OnProfGram, profgram)
+ self.Bind(wx.EVT_MENU, self.OnStCaract, stcaract)
+ self.Bind(wx.EVT_MENU, self.OnTgenEditor, tgen)
+ self.Bind(wx.EVT_MENU, self.OnTgenCompute, computetgen)
+ self.Bind(wx.EVT_MENU, self.OnMergeClusterGraph, mergeclustergraph)
+ 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)
+ self.Bind(wx.EVT_MENU, self.StatClasse, statclasse)
+ self.Bind(wx.EVT_MENU, self.OnRapport, rapport)
+ self.Bind(wx.EVT_MENU, self.OnExportClasses, export_classes)
+ self.Bind(wx.EVT_MENU, self.OnSubCorpusFromClusters, subcorpusfromcl)
+ elif pydata.get('type', False) == 'stat' and pydata['uuid'] in self.parent.history.opened :
+ export_dictionary = menu.Append(wx.ID_ANY, _(u"Export dictionary").decode('utf8'))
+ export_lems = menu.Append(wx.ID_ANY, _(u"Export lemma dictionary").decode('utf8'))
+ export_cut_corpus = menu.Append(wx.ID_ANY, _(u"Export segmented corpus").decode('utf8'))
+ self.Bind(wx.EVT_MENU, self.OnExportDictionary, export_dictionary)
+ self.Bind(wx.EVT_MENU, self.OnExportLems, export_lems)
+ self.Bind(wx.EVT_MENU, self.OnExportCutCorpus, export_cut_corpus)
+ menu.AppendSeparator()
+ elif pydata.get('type', False) == 'spec' and pydata['uuid'] in self.parent.history.opened :
+ tgen = menu.Append(wx.ID_ANY, _(u"Tgen Editor").decode('utf8'))
+ computetgen = menu.Append(wx.ID_ANY, _(u"Compute Tgen").decode('utf8'))
+ self.Bind(wx.EVT_MENU, self.OnTgenEditor, tgen)
+ self.Bind(wx.EVT_MENU, self.OnTgenCompute, computetgen)
+ menu.AppendSeparator()
+ elif pydata.get('type', False) == 'reinertmatrix' and pydata['uuid'] in self.parent.history.opened :
+ openmenu = wx.Menu()
+ antipro = openmenu.Append(wx.ID_ANY, _(u"antiprofiles").decode('utf8'))
+ rapport = menu.Append(wx.ID_ANY, _(u"Report").decode('utf8'))
+ menu.AppendMenu(wx.ID_ANY, _(u"Open ...").decode('utf8'), openmenu)
+ self.Bind(wx.EVT_MENU, self.OpenAntipro, antipro)
+ self.Bind(wx.EVT_MENU, self.OnRapport, rapport)
+
+ 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")
+
+ #self.Bind(wx.EVT_MENU, self.OnItemBackground, item1)
+ #self.Bind(wx.EVT_MENU, self.OnItemForeground, item2)
+ #self.Bind(wx.EVT_MENU, self.OnItemBold, item3)
+ #self.Bind(wx.EVT_MENU, self.OnItemFont, item4)
+ #self.Bind(wx.EVT_MENU, self.OnItemHyperText, item5)
+ #self.Bind(wx.EVT_MENU, self.OnEnableWindow, item6)
+ #self.Bind(wx.EVT_MENU, self.OnDisableItem, item7)
+ #self.Bind(wx.EVT_MENU, self.OnItemIcons, item8)
+ 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)
+
+ self.PopupMenu(menu)
+ menu.Destroy()
def getcorpus(self):
+ busy = wx.BusyInfo(_("Please wait...Reading corpus").decode('utf8'), self.parent)
+ wx.SafeYield()
if self.pydata['uuid'] in self.parent.history.openedcorpus :
- return copycorpus(self.parent.history.openedcorpus[self.pydata['uuid']])
+ corpus = copycorpus(self.parent.history.openedcorpus[self.pydata['uuid']])
elif 'corpus_name' in self.pydata :
- return Corpus(self.parent, parametres = DoConf(self.pydata['ira']).getoptions('corpus'), read = True)
+ corpus = Corpus(self.parent, parametres = DoConf(self.pydata['ira']).getoptions('corpus'), read = True)
else :
cuuid = self.pydata['corpus']
if cuuid in self.parent.history.openedcorpus :
- return copycorpus(self.parent.history.openedcorpus[cuuid])
+ corpus = copycorpus(self.parent.history.openedcorpus[cuuid])
else :
irapath = self.parent.history.corpus[cuuid]['ira']
- return Corpus(self.parent, parametres = DoConf(irapath).getoptions('corpus'), read = True)
+ corpus = Corpus(self.parent, parametres = DoConf(irapath).getoptions('corpus'), read = True)
+ del busy
+ return corpus
+
+ def getmatrix(self):
+ if 'matrix_name' in self.pydata :
+ matrix = Tableau(self.parent, parametres = DoConf(self.pydata['ira']).getoptions('matrix'))
+ matrix.open()
+ return copymatrix(matrix)
+ else :
+ cuuid = self.pydata['matrix']
+ matrix = Tableau(self.parent, parametres = DoConf(self.history.matrixanalyse[cuuid]['ira']).getoptions('matrix'))
+ matrix.open()
+ return copymatrix(matrix)
def OnSpec(self, evt) :
self.parent.OnTextSpec(evt, self.getcorpus())
def OnStat(self, evt) :
self.parent.OnTextStat(evt, self.getcorpus())
-
- def OnAlceste(self, evt) :
- self.parent.OnTextAlceste(evt, self.getcorpus())
+
+ def OnReinert(self, evt) :
+ self.parent.OnTextReinert(evt, self.getcorpus())
def OnPam(self, evt) :
- print 'rien'
+ self.parent.OnPamSimple(evt, self.getcorpus())
def OnSimiTxt(self, evt) :
self.parent.OnSimiTxt(evt, self.getcorpus())
def OnWordCloud(self, evt) :
self.parent.OnWordCloud(evt, self.getcorpus())
+# def OnFreq(self, evt):
+# self.parent.OnFreq(evt, self.getmatrix())
+
+# def OnChiSquare(self, evt):
+# self.parent.OnChi2(evt, self.getmatrix())
+
+# def OnSimiTab(self, evt):
+# self.parent.OnSimiTab(evt, self.getmatrix())
+
+# def OnProto(self, evt):
+# self.parent.OnProto(evt, self.getmatrix())
+
+# def OnSplitFromVar(self, evt):
+# self.parent.OnSplitVar(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 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)
def OnProfGram(self, evt) :
ProfilType(self.parent, self.page.corpus, self.page.parametres)
+ def OnMergeClusterGraph(self, evt) :
+ MergeClusterGraph(self.parent, self.page.corpus, self.page.parametres)
+ print 'merge done !'
+
+ def OnStCaract(self, evt) :
+ dial = PrefUCECarac(self, self.parent)
+ dial.CenterOnParent()
+ if self.page.parametres['classif_mode'] != 2 :
+ uci = False
+ else :
+ uci = True
+
+ if dial.ShowModal() == wx.ID_OK :
+ limite = dial.spin_eff.GetValue()
+ atype = dial.radio_type.GetSelection()
+ dial.Destroy()
+ corpus = self.page.corpus
+ dlg = progressbar(self.ira, maxi = len(corpus.lc))
+ dlg.Update(1, 'wait...')
+ for i in range(0, len(corpus.lc)) :
+ page = self.page.ProfNB.GetPage(i)
+ rcl = page.cl - 1
+ dlg.Update(i, u'Cluster %i' % (i+1))
+ uces = corpus.lc[rcl]
+ tab = corpus.make_table_with_classe(uces, page.la, uci = uci)
+ tab.pop(0)
+ if atype == 0 :
+ ntab = [round(sum([page.lchi[j] for j, word in enumerate(line) if word == 1]),2) for line in tab]
+ else :
+ ntab = [round(sum([page.lchi[j] for j, word in enumerate(line) if word == 1])/float(sum(line)),2) if sum(line)!=0 else 0 for line in tab]
+ ntab2 = [[ntab[j], uces[j]] for j, val in enumerate(ntab)]
+ del ntab
+ ntab2.sort(reverse = True)
+ ntab2 = ntab2[:limite]
+ nuces = [val[1] for val in ntab2]
+ ucis_txt, ucestxt = doconcorde(corpus, nuces, page.la, uci = uci)
+ items = ['<br>'.join([ucis_txt[j], '<table bgcolor = #1BF0F7 border=0><tr><td><b>score : %.2f</b></td></tr></table><br>' % ntab2[j][0], ucestxt[j]]) for j, uce in enumerate(nuces)]
+ filename = self.page.pathout['st_caract_cl_%i.html' % (rcl+1)]
+ with open(filename, 'w') as f :
+ f.write('\n'.join(items))
+ dlg.Destroy()
+
+
def OnExportCorpus(self, evt) :
dial = PrefExport(self, self.parent)
dial.fbb.SetValue(os.path.join(os.path.dirname(self.page.dictpathout['ira']), 'export_corpus.txt'))
else : alc = False
if dial.radio_lem.GetSelection() == 0 : lem = True
else : lem = False
- self.page.corpus.export_corpus_classes(dial.fbb.GetValue(), alc = alc, lem = lem)
+ if self.page.parametres['classif_mode'] != 2 :
+ uci = False
+ else :
+ uci = True
+ 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()
+ def OnExportCutCorpus(self, evt) :
+ uci = False
+ fileout = os.path.join(os.path.dirname(self.page.pathout['ira']), 'segmented_corpus.txt')
+ txt = self.page.corpus.make_cut_corpus(uci = uci)
+ with open(fileout, 'w') as f :
+ f.write(txt)
+ msg = '\n'.join([_(u"Done !").decode('utf8'), fileout])
+ dlg = wx.MessageDialog(self.parent, msg, _(u"Segmented corpus"), wx.OK | wx.ICON_INFORMATION)
+ dlg.CenterOnParent()
+ dlg.ShowModal()
+ dlg.Destroy()
+
+
def OnColored(self, evt) :
- dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.html', 'title': 'Corpus en couleur'})
+ dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.html', 'title': _(u"Colored corpus").decode('utf8')})
dial.fbb.SetValue(os.path.join(os.path.dirname(self.page.dictpathout['ira']), 'corpus_couleur.html'))
dial.CenterOnParent()
res = dial.ShowModal()
if res == wx.ID_OK :
fileout = dial.fbb.GetValue()
dial.Destroy()
- txt = self.page.corpus.make_colored_corpus()
+ if self.page.parametres['classif_mode'] != 2 :
+ uci = False
+ else :
+ uci = True
+ txt = self.page.corpus.make_colored_corpus(uci = uci)
with open(fileout, 'w') as f :
f.write(txt)
- msg = u"Fini !\nVoulez-vous ouvrir le corpus dans votre navigateur ?"
- dlg = wx.MessageDialog(self.parent, msg, u"Corpus en couleur", wx.NO | wx.YES | wx.NO_DEFAULT | wx.ICON_QUESTION)
+ 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.ICON_QUESTION)
dlg.CenterOnParent()
if dlg.ShowModal() == wx.ID_YES :
webbrowser.open(fileout)
def OnNavig(self, evt):
if 'FrameSearch' not in dir(self.page) :
- self.page.FrameSearch = SearchFrame(self.parent, -1, u"Rechercher...", self.page.corpus)
+ self.page.FrameSearch = SearchFrame(self.parent, -1, _(u"Search ...").decode('utf8'), self.page.corpus)
self.page.FrameSearch.Show()
def StatClasse(self, evt):
- dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.csv', 'title': 'Stat par classe'})
+ dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.csv', 'title': _(u"Clusters statistics").decode('utf8')})
dial.fbb.SetValue( os.path.join(os.path.dirname(self.page.dictpathout['ira']), 'stat_par_classe.csv'))
dial.CenterOnParent()
res = dial.ShowModal()
dial.Destroy()
self.page.corpus.get_stat_by_cluster(fileout)
msg = u"Fini !"
- dlg = wx.MessageDialog(self.parent, msg, u"Stat par classe", 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()
+ dlg.Destroy()
def OpenAntipro(self, evt) :
find = False
for i in range(0, self.page.TabChdSim.GetPageCount()) :
page = self.page.TabChdSim.GetPage(i)
- if self.page.TabChdSim.GetPageText(i) == 'Antiprofils' :
+ if self.page.TabChdSim.GetPageText(i) == _(u"Antiprofiles").decode('utf8') :
self.page.TabChdSim.SetSelection(i)
find = True
break
open_antiprofil(self.page, self.page.dictpathout['ANTIPRO_OUT'], self.parent.syscoding)
self.page.TabChdSim.SetSelection(self.page.TabChdSim.GetPageCount() - 1)
+ def OnTranslate(self, evt) :
+ dial = translate_dialog(self.parent)
+ dial.CenterOnParent()
+ res = dial.ShowModal()
+ if res == wx.ID_OK :
+ to_l = dial.getto_l()
+ from_l = dial.getfrom_l()
+ dial.Destroy()
+ busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self.parent)
+ wx.SafeYield()
+ prof, lems = translateprofile(self.page.corpus, ReadProfileAsDico(self.page.dictpathout['PROFILE_OUT'], True, self.parent.syscoding), lf=from_l, lt=to_l)
+ write_translation_profile(prof, lems, to_l, self.page.dictpathout)
+ open_antiprofil(self.page, prof, 'utf8', title = _(u'Translation').decode('utf8') + ' %s' % to_l, translation = True, lems=lems)
+ del busy
+ self.page.lems = lems
+ self.page.TabChdSim.SetSelection(self.page.TabChdSim.GetPageCount() - 1)
+ else :
+ dial.Destroy()
+
def OnRapport(self, evt) :
- dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.txt', 'title': 'Rapport'})
+ dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.txt', 'title': _(u"Report").decode('utf8')})
dial.fbb.SetValue(self.page.dictpathout['rapport'])
dial.CenterOnParent()
res = dial.ShowModal()
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"Rapport", 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()
else :
dial.Destroy()
+ def OnExportDictionary(self, evt) :
+ corpus = self.page.corpus
+ corpus.export_dictionary(self.page.pathout['dictionary.csv'], self.parent.syscoding)
+ log.info('export dictionary %s' % self.page.pathout['dictionary.csv'])
+ dial = wx.MessageDialog(self.parent, self.page.pathout['dictionary.csv'], 'Export', wx.OK)
+ dial.ShowModal()
+ dial.Destroy()
+
+ def OnExportLems(self, evt) :
+ corpus = self.page.corpus
+ corpus.export_lems(self.page.pathout['lemmes.csv'], self.parent.syscoding)
+ log.info('export lemmes %s' % self.page.pathout['lemmes.csv'])
+ dial = wx.MessageDialog(self.parent, self.page.pathout['lemmes.csv'], 'Export', wx.OK)
+ dial.ShowModal()
+ dial.Destroy()
+
+ def OnTgenEditor(self, evt):
+ corpus = self.page.corpus
+ tgenpath = os.path.join(self.page.parametres['pathout'], 'tgen.csv')
+ tgen = TGen(path = tgenpath, encoding = self.parent.syscoding)
+ if os.path.exists(tgenpath) :
+ tgen.read(tgenpath)
+ if isinstance(evt, list) :
+ i = 0
+ while 'tgen%i' %i in tgen.tgen :
+ i += 1
+ tgenname = 'tgen%i' %i
+ tgen.tgen[tgenname] = evt
+ tgenframe = TGenFrame(self.parent, corpus, tgen)
+ tgenframe.Show()
+ if isinstance(evt, list) :
+ tgenframe.OnNewTgen(None, tgen = tgenname)
+
+ def OnTgenCompute(self, evt):
+ 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 !").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)
+ 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):
+ corpus = self.page.corpus
+ if self.page.parametres['classif_mode'] != 2 :
+ uci = False
+ else :
+ uci = True
+ busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self.parent)
+ wx.SafeYield()
+ for i in range(1, self.page.parametres['clnb'] + 1) :
+ corpus.export_classe(self.page.pathout['classe_%i_export.txt' % i], i, uci = uci)
+ del busy
+ dial = wx.MessageDialog(self, self.page.pathout['classe_x_export.txt'], u"Export", wx.OK|wx.ICON_INFORMATION)
+ dial.ShowModal()
+ dial.Destroy()
+
+ def OnSubCorpusFromClusters(self, evt):
+ 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']
+ 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 GetCorpusByName(self, corpus_name) :
+ return [corpus for corpus in self.h if corpus_name in corpus['corpus_name']]
+
+ def OnSearchCorpus(self, evt):
+ searchframe = SearchCorpus(self.ira, self, None, None)
+ searchframe.Show()
+ #res = self.GetCorpusByName('Ministres')
+ #print res
+
+ def SetContentBackground(self, itemParent = None, uuid = None, color = True) :
+ if itemParent is None :
+ itemParent = self.root
+ child, cookie = self.GetFirstChild(itemParent)
+ while child :
+ pydata = self.GetPyData(child)
+ if pydata['uuid'] == uuid :
+ self.SelectItem(child)
+ if color :
+ self.SetItemBackgroundColour(child, wx.Colour(15,234,56))
+ return
+ self.SetContentBackground(child, uuid, color)
+ child, cookie = self.GetNextChild(itemParent, cookie)
+
+
def OnItemBackground(self, event):
colourdata = wx.ColourData()
def OnItemDelete(self, event):
strs = "Are You Sure You Want To Delete Item " + self.GetItemText(self.current) + "?"
- dlg = wx.MessageDialog(None, strs, 'Deleting Item', wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_QUESTION)
+ dlg = wx.MessageDialog(None, strs, 'Deleting Item', wx.OK | wx.CANCEL | wx.ICON_QUESTION)
if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
dlg.Destroy()
dlg.Destroy()
def AddAnalyse(self, parametres, itemParent = None, bold = True) :
- uuid = parametres['corpus']
- if itemParent is None :
- itemParent = self.root
- child, cookie = self.GetFirstChild(itemParent)
- corpus = None
- while child :
- pydata = self.GetPyData(child)
- if pydata['uuid'] == uuid :
- corpus = child
- break
- self.GiveFocus(child, uuid)
- child, cookie = self.GetNextChild(itemParent, cookie)
- #item = self.AppendItem(child, parametres['name'])
- if corpus is not None :
- item = self.AppendItem(corpus, parametres['name'])
+ uuid = parametres.get('corpus', None)
+ if uuid is not None :
+ if itemParent is None :
+ itemParent = self.textroot
+ child, cookie = self.GetFirstChild(itemParent)
+ corpus = None
+ while child :
+ pydata = self.GetPyData(child)
+ if pydata['uuid'] == uuid :
+ corpus = child
+ break
+ self.GiveFocus(child, uuid)
+ child, cookie = self.GetNextChild(itemParent, cookie)
+ #item = self.AppendItem(child, parametres['name'])
+ if corpus is not None :
+ item = self.AppendItem(corpus, parametres['name'])
+ else :
+ item = self.AppendItem(self.textroot, parametres['name'])
+ else :
+ item = self.AppendItem(self.matroot, parametres['name'])
+ self.SetPyData(item, parametres)
+ if parametres['type'] in self.ild :
+ img = self.ild[parametres['type']]
else :
- item = self.AppendItem(self.root, parametres['name'])
+ img = 24
+ self.SetItemImage(item, img, CT.TreeItemIcon_Normal)
+ self.SetItemImage(item, 13, CT.TreeItemIcon_Expanded)
+ self.SetItemBold(item, bold)
+ self.SelectItem(item)
+
+ def AddMatAnalyse(self, parametres, itemParent = None, bold = True) :
+ uuid = parametres.get('matrix', None)
+ if uuid is not None :
+ if itemParent is None :
+ itemParent = self.matroot
+ child, cookie = self.GetFirstChild(itemParent)
+ matrix = None
+ while child :
+ pydata = self.GetPyData(child)
+ if pydata['uuid'] == uuid :
+ matrix = child
+ break
+ self.GiveFocus(child, uuid)
+ child, cookie = self.GetNextChild(itemParent, cookie)
+ #item = self.AppendItem(child, parametres['name'])
+ if matrix is not None :
+ item = self.AppendItem(matrix, parametres['name'])
+ else :
+ item = self.AppendItem(self.matroot, parametres['name'])
self.SetPyData(item, parametres)
- self.SetItemImage(item, 24, CT.TreeItemIcon_Normal)
+ if parametres['type'] in self.ild :
+ img = self.ild[parametres['type']]
+ else :
+ img = 24
+ self.SetItemImage(item, img, CT.TreeItemIcon_Normal)
self.SetItemImage(item, 13, CT.TreeItemIcon_Expanded)
self.SetItemBold(item, bold)
+ self.SelectItem(item)
- def OnItemAppend(self, item):
- child = self.AppendItem(self.root, item['corpus_name'])
+ 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)
- self.SetItemImage(child, 24, CT.TreeItemIcon_Normal)
- self.SetItemImage(child, 13, CT.TreeItemIcon_Expanded)
- self.SetItemBold(child, True)
+ 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)
+ 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')
def OnLeftDClick(self, event):
-
pt = event.GetPosition()
item, flags = self.HitTest(pt)
- pydata = self.GetPyData(item)
- if pydata['uuid'] in self.parent.history.opened :
- for i in range(self.parent.nb.GetPageCount()) :
- page = self.parent.nb.GetPage(i)
- if 'parametres' in dir(page) :
- if page.parametres['uuid'] == pydata['uuid'] :
- self.parent.nb.SetSelection(i)
- break
- else :
- OpenAnalyse(self.parent, pydata)
- self.SetItemBold(item, True)
- self.OnSelChanged(pydata = pydata)
+ if item is not None :
+ pydata = self.GetPyData(item)
+ if pydata['uuid'] in self.parent.history.opened :
+ for i in range(self.parent.nb.GetPageCount()) :
+ page = self.parent.nb.GetPage(i)
+ if 'parametres' in dir(page) :
+ if page.parametres['uuid'] == pydata['uuid'] :
+ self.parent.nb.SetSelection(i)
+ break
+ elif pydata['uuid'] in ['textroot', 'matroot'] :
+ pass
+ else :
+ 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")
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()) :