From 992d1e91b97a956ca2a7336e9f365ff8bea45e03 Mon Sep 17 00:00:00 2001 From: Pierre Ratinaud Date: Wed, 10 Dec 2014 17:43:36 +0100 Subject: [PATCH] ... --- dialog.py | 20 +++++-- iramuteq.py | 182 +++++++++++++++++++++++++++++++++++++++++++++++++++--------- tree.py | 131 ++++++++++++++++--------------------------- 3 files changed, 216 insertions(+), 117 deletions(-) diff --git a/dialog.py b/dialog.py index 751f888..66a427a 100755 --- a/dialog.py +++ b/dialog.py @@ -2676,9 +2676,8 @@ class message(wx.Frame): self.Destroy() def OnSub(self ,evt): - parametres = {'fromuceids' : True, 'uceids' : self.uceids} - self.ira.OnSubText(None, parametres) - + parametres = {'fromuceids' : True, 'uceids' : self.uceids, 'isempty' : True} + self.ira.OnSubText(wx.MenuEvent(), None, parametres) class ExtractDialog ( wx.Dialog ): @@ -3029,7 +3028,7 @@ class SimpleDialog ( wx.Dialog ): class SubTextFromMetaDial ( wx.Dialog ): def __init__( self, parent, parametres ): - wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Subcorpus from metadata", pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE ) + wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Subcorpus").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE ) self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) @@ -3039,14 +3038,14 @@ class SubTextFromMetaDial ( wx.Dialog ): fgSizer1.SetFlexibleDirection( wx.BOTH ) fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) - self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"SubCorpus Name", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Name").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText1.Wrap( -1 ) fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) self.subcorpusname = wx.TextCtrl( self, wx.ID_ANY, parametres['corpus_name'], wx.DefaultPosition, wx.Size( 300,-1 ), 0 ) fgSizer1.Add( self.subcorpusname, 0, wx.ALL, 5 ) - self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, u"Select one or more metadata", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"Select one or more metadata").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText2.Wrap( -1 ) fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) @@ -3075,9 +3074,18 @@ class SubTextFromMetaDial ( wx.Dialog ): bSizer1.Fit( self ) self.Centre( wx.BOTH ) + self.Bind(wx.EVT_LISTBOX, self.onchoose, self.m_listBox1) + if not parametres.get('isempty', False) : + self.m_sdbSizer1OK.Enable(False) def __del__( self ): pass + + def onchoose(self, evt): + if len(self.m_listBox1.GetSelections()) > 0 : + self.m_sdbSizer1OK.Enable(True) + else : + self.m_sdbSizer1OK.Enable(False) class BarGraphDialog ( wx.Dialog ): diff --git a/iramuteq.py b/iramuteq.py index 9618316..c762bf8 100644 --- a/iramuteq.py +++ b/iramuteq.py @@ -90,6 +90,10 @@ ID_SimiTxt = wx.NewId() ID_proto = wx.NewId() ID_ImportTXM = wx.NewId() ID_FreqMulti = wx.NewId() +ID_Splitfromvar = wx.NewId() +ID_Subtxtfrommeta = wx.NewId() +ID_Subtxtfromthem = wx.NewId() +ID_WC = wx.NewId() ########################################################## #elements de configuration ########################################################## @@ -158,6 +162,27 @@ code_langues = {'french' : 'fr_FR', 'italian' : 'it_IT', 'spanish' : 'es_ES' } + +images_analyses = { + 'textroot' : 'textroot.png', + 'alceste' : 'reinert.png', + 'corpus' : 'textcorpus.png', + 'wordcloud' :'wordcloud.png', + 'stat' :'stats.png', + 'simitxt' : 'simitxt.png', + 'clustersimitxt' :'clustersimitxt.png', + 'clustercloud' : 'clustercloud.png', + 'spec' : 'spec.png', + 'matroot' : 'matroot.png', + 'matrix' : 'matrix.png', + 'freq' : 'frequences.png', + 'freqmulti' : 'frequences.png', + 'chi2' : 'chi2.png', + 'reinertmatrix' : 'reinertmatrix.png', + 'simimatrix' : 'simimatrix.png', + 'simiclustermatrix' : 'simimatrix.png', + 'proto' : 'proto.png', + } ##################################################################### class IraFrame(wx.Frame): @@ -199,15 +224,19 @@ class IraFrame(wx.Frame): self.x = 0 # create menu #-------------------------------------------------------------------------------- + self.images_analyses = images_analyses + for img in images_analyses : + self.images_analyses[img] = wx.Image(os.path.join(self.images_path, self.images_analyses[img]), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap() self.mb = wx.MenuBar() file_menu = wx.Menu() item = wx.MenuItem(file_menu, ID_OpenData, _(u"Open a matrix").decode('utf8'), _(u"Open a matrix").decode('utf8')) - item.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN)) + #item.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN)) + item.SetBitmap(self.images_analyses['matroot']) file_menu.AppendItem(item) item = wx.MenuItem(file_menu, ID_OpenText, _(u"Open a text corpus").decode('utf8'), _(u"Open a text corpus").decode('utf8')) - item.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN)) + item.SetBitmap(self.images_analyses['textroot']) file_menu.AppendItem(item) item = wx.MenuItem(file_menu, ID_OnOpenAnalyse, _(u"Open an analysis").decode('utf8'), _(u"Open an analysis").decode('utf8')) @@ -256,17 +285,44 @@ class IraFrame(wx.Frame): view_menu.Append(ID_RESULT, _(u'Show results').decode('utf8')) #view_menu.AppendSeparator() matrix_menu = wx.Menu() - matrix_menu.Append(ID_Freq, _(u"Frequencies").decode('utf8')) - matrix_menu.Append(ID_FreqMulti, _(u'Multiple frequencies').decode('utf8')) - matrix_menu.Append(ID_Chi2, _(u"Chi2").decode('utf8')) + matanalyses = [[ID_Freq, _(u"Frequencies").decode('utf8'), 'freq'], + [ID_Freq, _(u"Multiple Frequencies").decode('utf8'), 'freqmulti'], + [ID_Chi2, _(u"Chi2").decode('utf8'), 'chi2'], + {'name' : _(u"Clustering").decode('utf8'), + 'content' : [[ID_CHDReinert, _(u"Reinert's Method").decode('utf8'), 'reinertmatrix']]}, + [ID_SIMI, _(u"Similarities Analysis").decode('utf8'), 'simimatrix'], + [ID_proto, _(u"Prototypical Analysis").decode('utf8'), 'proto'], + [ID_Splitfromvar, _(u"Split from variable").decode('utf8'), '']] + + for analyse in matanalyses : + if not isinstance(analyse, dict) : + item = wx.MenuItem(matrix_menu, analyse[0], analyse[1]) + item.SetBitmap(self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16))) + matrix_menu.AppendItem(item) + else : + nmenu = wx.Menu() + for subana in analyse['content'] : + item = wx.MenuItem(nmenu, subana[0], subana[1]) + item.SetBitmap(self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16))) + nmenu.AppendItem(item) + matrix_menu.AppendMenu(-1, analyse['name'], nmenu) + #item = wx.MenuItem(matrix_menu, ID_Freq, _(u"Frequencies").decode('utf8')) + #item.SetBitmap(self.images_analyses['freq']) + #matrix_menu.AppendItem(item) + #matrix_menu.Append(ID_Freq, _(u"Frequencies").decode('utf8')) + #item = wx.MenuItem(matrix_menu, ID_Freq, _(u"Multiple Frequencies").decode('utf8')) + #item.SetBitmap(self.images_analyses['freqmulti']) + #matrix_menu.Append(ID_FreqMulti, _(u'Multiple frequencies').decode('utf8')) + #matrix_menu.AppendItem(item) + #matrix_menu.Append(ID_Chi2, _(u"Chi2").decode('utf8')) #matrix_menu.Append(ID_Student, u"t de Student") - menu_classif = wx.Menu() - menu_classif.Append(ID_CHDReinert, _(u"Reinert's Method").decode('utf8')) + #menu_classif = wx.Menu() + #menu_classif.Append(ID_CHDReinert, _(u"Reinert's Method").decode('utf8')) #menu_classif.Append(ID_CHDSIM, u"Par matrice des distances") - matrix_menu.AppendMenu(-1, _(u"Clustering").decode('utf8'), menu_classif) + #matrix_menu.AppendMenu(-1, _(u"Clustering").decode('utf8'), menu_classif) #matrix_menu.Append(ID_AFCM, u"AFCM") - matrix_menu.Append(ID_SIMI, _(u"Similarities Analysis").decode('utf8')) - matrix_menu.Append(ID_proto, _(u"Prototypical Analysis").decode('utf8')) + #matrix_menu.Append(ID_SIMI, _(u"Similarities Analysis").decode('utf8')) + #matrix_menu.Append(ID_proto, _(u"Prototypical Analysis").decode('utf8')) ID_RCODE = wx.NewId() #matrix_menu.Append(ID_RCODE, u"Code R...") #menu_splittab = wx.Menu() @@ -277,17 +333,40 @@ class IraFrame(wx.Frame): self.matrix_menu = matrix_menu text_menu = wx.Menu() + analyses_text = [[ID_TEXTSTAT, _(u"Statistics").decode('utf8'), 'stat'], + [ID_ASLEX, _(u"Specificities and CA").decode('utf8'), 'spec'], + {'name' : _(u"Clustering").decode('utf8'), + 'content' : [[ID_TEXTREINERT, _(u"Reinert's Method").decode('utf8'), 'alceste']]}, + [ID_SimiTxt, _(u"Similarities Analysis").decode('utf8'), 'simitxt'], + [ID_WC, _(u"WordCloud").decode('utf8'), 'wordcloud'], + {'name' : _(u"Sub corpus").decode('utf8'), + 'content' : [[ID_Subtxtfrommeta, _(u'Sub corpus from metadata').decode('utf8'), None], + [ID_Subtxtfromthem, _(u'Sub corpus from thematic').decode('utf8'), None]]}, + ] + + for analyse in analyses_text : + if not isinstance(analyse, dict) : + item = wx.MenuItem(text_menu, analyse[0], analyse[1]) + item.SetBitmap(self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16))) + text_menu.AppendItem(item) + else : + nmenu = wx.Menu() + for subana in analyse['content'] : + item = wx.MenuItem(nmenu, subana[0], subana[1]) + item.SetBitmap(self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16))) + nmenu.AppendItem(item) + text_menu.AppendMenu(-1, analyse['name'], nmenu) #text_menu.Append(ID_CHECKCORPUS, u"Vérifier le corpus") - text_menu.Append(ID_TEXTSTAT, _(u"Statistics").decode('utf8')) - text_menu.Append(ID_ASLEX, _(u"Specificities and CA").decode('utf8')) - #text_menu.Append(ID_TEXTAFCM, u"AFC sur UCI / Vocabulaire") - menu_classiftxt = wx.Menu() - menu_classiftxt.Append(ID_TEXTREINERT, _(u"Reinert's Method").decode('utf8')) - #menu_classiftxt.Append(ID_TEXTPAM, u"Par matrice des distances") - text_menu.AppendMenu(-1, _(u"Clustering").decode('utf8'), menu_classiftxt) - text_menu.Append(ID_SimiTxt, _(u"Similarities Analysis").decode('utf8')) - ID_WC = wx.NewId() - text_menu.Append(ID_WC, _(u"WordCloud").decode('utf8')) +# text_menu.Append(ID_TEXTSTAT, _(u"Statistics").decode('utf8')) +# text_menu.Append(ID_ASLEX, _(u"Specificities and CA").decode('utf8')) +# #text_menu.Append(ID_TEXTAFCM, u"AFC sur UCI / Vocabulaire") +# menu_classiftxt = wx.Menu() +# menu_classiftxt.Append(ID_TEXTREINERT, _(u"Reinert's Method").decode('utf8')) +# #menu_classiftxt.Append(ID_TEXTPAM, u"Par matrice des distances") +# text_menu.AppendMenu(-1, _(u"Clustering").decode('utf8'), menu_classiftxt) +# text_menu.Append(ID_SimiTxt, _(u"Similarities Analysis").decode('utf8')) +# +# text_menu.Append(ID_WC, _(u"WordCloud").decode('utf8')) self.text_menu = text_menu help_menu = wx.Menu() @@ -317,12 +396,31 @@ class IraFrame(wx.Frame): tb1 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER) tb1.SetToolBitmapSize(wx.Size(16, 16)) - tb1.AddLabelTool(ID_OpenData, "OpenData", wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, wx.Size(16, 16)), shortHelp="Questionnaire", longHelp="Ouvrir un questionnaire") + tb1.AddLabelTool(ID_OpenData, "OpenData", self.images_analyses['matroot'], shortHelp=_(u"Matrix").decode('utf8'), longHelp=_(u"Open a matrix").decode('utf8')) tb1.AddSeparator() - tb1.AddLabelTool(ID_OpenText, "OpenText", wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, wx.Size(16, 16)), shortHelp="Texte", longHelp="Ouvrir un corpus texte") - + tb1.AddLabelTool(ID_OpenText, "OpenText", self.images_analyses['textroot'], shortHelp=_(u"Text").decode('utf8'), longHelp=_(u"Open a text corpus").decode('utf8')) + tb1.Realize() + tb_text = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, + wx.TB_FLAT | wx.TB_NODIVIDER) + for analyse in analyses_text : + if not isinstance(analyse, dict) : + tb_text.AddLabelTool(analyse[0], analyse[1], self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)), shortHelp = analyse[1], longHelp = analyse[1]) + else : + for subana in analyse['content'] : + tb_text.AddLabelTool(subana[0], subana[1], self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)), shortHelp = subana[1], longHelp = subana[1]) + tb_text.Realize() + + tb_mat = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, + wx.TB_FLAT | wx.TB_NODIVIDER) + for analyse in matanalyses : + if not isinstance(analyse, dict) : + tb_mat.AddLabelTool(analyse[0], analyse[1], self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)), shortHelp = analyse[1], longHelp = analyse[1]) + else : + for subana in analyse['content'] : + tb_mat.AddLabelTool(subana[0], subana[1], self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)), shortHelp = subana[1], longHelp = subana[1]) + tb_mat.Realize() #------------------------------------------------------------------------------------------------ self.text_ctrl_txt = wx.TextCtrl(self, -1, "", wx.Point(0, 0), wx.Size(200, 200), wx.NO_BORDER | wx.TE_MULTILINE | wx.TE_RICH2 | wx.TE_READONLY) @@ -372,7 +470,20 @@ class IraFrame(wx.Frame): self._mgr.AddPane(tb1, aui.AuiPaneInfo(). Name("tb1").Caption("Fichiers"). ToolbarPane().Top(). - LeftDockable(True).RightDockable(False)) + LeftDockable(True).RightDockable(False)) + + self._mgr.AddPane(tb_text, aui.AuiPaneInfo(). + Name("tb_text").Caption("analyse_text"). + ToolbarPane().Top(). + LeftDockable(True).RightDockable(False)) + + self._mgr.AddPane(tb_mat, aui.AuiPaneInfo(). + Name("tb_mat").Caption("analyse_matrix"). + ToolbarPane().Top(). + LeftDockable(True).RightDockable(False)) + + self._mgr.GetPane('tb_text').Hide() + self._mgr.GetPane('tb_mat').Hide() self.ShowAPane("Intro_Text") self._mgr.GetPane("lefttree").Show() @@ -402,6 +513,7 @@ class IraFrame(wx.Frame): self.Bind(wx.EVT_MENU, self.OnCHDReinert, id=ID_CHDReinert) self.Bind(wx.EVT_MENU, self.OnAFCM, id=ID_AFCM) self.Bind(wx.EVT_MENU, self.OnProto, id=ID_proto) + self.Bind(wx.EVT_MENU, self.OnSplitVar, id = ID_Splitfromvar) #self.Bind(wx.EVT_MENU, self.OnRCode, id=ID_RCODE) #self.Bind(wx.EVT_MENU, self.OnSplitVar, id=ID_SPLITVAR) #self.Bind(wx.EVT_MENU, self.OnCheckcorpus, id = ID_CHECKCORPUS) @@ -412,6 +524,8 @@ class IraFrame(wx.Frame): self.Bind(wx.EVT_MENU, self.OnPamSimple, id=ID_TEXTPAM) self.Bind(wx.EVT_MENU, self.OnSimiTxt, id=ID_SimiTxt) self.Bind(wx.EVT_MENU, self.OnWordCloud, id=ID_WC) + self.Bind(wx.EVT_MENU, self.OnSubText, id = ID_Subtxtfrommeta) + self.Bind(wx.EVT_MENU, self.OnSubText, id = ID_Subtxtfromthem) self.Bind(wx.EVT_MENU, self.OnSimiTab, id=ID_SIMI) self.Bind(wx.EVT_MENU, self.OnExit, id=wx.ID_EXIT) #self.Bind(wx.EVT_MENU, self.OnSaveTabAs, id=ID_SaveTab) @@ -549,8 +663,16 @@ vous devez signaler le chemin de l'éxecutable de R dans les préférences.""" def ShowMenu(self, menu, Show=True): if menu == 'text' : menu_pos = 4 + if Show : + self._mgr.GetPane('tb_text').Show() + else : + self._mgr.GetPane('tb_text').Hide() elif menu == 'matrix' : menu_pos = 3 + if Show : + self._mgr.GetPane('tb_mat').Show() + else : + self._mgr.GetPane('tb_mat').Hide() elif menu == 'view' : menu_pos = 2 else : @@ -560,7 +682,7 @@ vous devez signaler le chemin de l'éxecutable de R dans les préférences.""" if not menu_pos is None : self.mb.EnableTop(menu_pos, Show) self.mb.UpdateMenus() - + self._mgr.Update() #-------------------------------------------------------------------- def OnClose(self, event): @@ -618,9 +740,13 @@ vous devez signaler le chemin de l'éxecutable de R dans les préférences.""" self.ShowAPane(u"Text") self._mgr.Update() - def OnSubText(self, corpus, parametres = None): + def OnSubText(self, evt, corpus = None, parametres = None): if corpus is None : corpus = self.tree.getcorpus() + if evt.GetId() == ID_Subtxtfrommeta : + parametres = {'frommeta' : True} + elif evt.GetId() == ID_Subtxtfromthem : + parametres = {'fromtheme' : True} builder = SubBuilder(self, corpus, parametres) if builder.res == wx.ID_OK : busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self) @@ -845,8 +971,10 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis.""" #Prototypical(self, {'type' : 'proto'}) def OnSplitVar(self, evt, matrix = None): + if matrix is None : + matrix = self.tree.getmatrix() self.analyse_matrix(SplitMatrixFromVar, matrix = matrix, analyse_type = 'splitvar', parametres = {'pathout': matrix.pathout.dirout}, dlgnb = 3) - matrix = self.tree.getmatrix() + #matrix = self.tree.getmatrix() def OnSimiTxt(self, evt, corpus = None) : diff --git a/tree.py b/tree.py index 12627f4..5b4b616 100644 --- a/tree.py +++ b/tree.py @@ -22,6 +22,27 @@ 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 ): @@ -110,26 +131,11 @@ class LeftTree(CT.CustomTreeCtrl): 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['freqmulti'] = 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['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()) + 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 @@ -146,8 +152,8 @@ class LeftTree(CT.CustomTreeCtrl): 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']) @@ -168,8 +174,8 @@ class LeftTree(CT.CustomTreeCtrl): 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) : @@ -391,54 +397,11 @@ class LeftTree(CT.CustomTreeCtrl): 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'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')) - 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() - if item.IsSubMenu() : - nmenu = wx.Menu() - for val in item.GetSubMenu().GetMenuItems() : - nmenu.Append(val.GetId(), val.GetText()) - menu.AppendMenu(itemid, itemtext, nmenu) - else : - 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')) @@ -556,29 +519,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) @@ -746,7 +709,7 @@ 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'] -- 2.7.4