From 5d8a0a0e99d9075adc28f2525fe0aba8e14c2b0a Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 5 Jan 2013 15:59:39 +0100 Subject: [PATCH] ... --- PrintRScript.py | 16 +++- ProfList.py | 22 ----- corpusNG.py | 83 +++++++++++++++- functions.py | 11 +-- iramuteq.py | 5 +- layout.py | 270 ++++++++++++++++++++++++----------------------------- profile_segment.py | 14 +-- tree.py | 235 ++++++++++++++++++++++++++++------------------ 8 files changed, 373 insertions(+), 283 deletions(-) diff --git a/PrintRScript.py b/PrintRScript.py index 7ec1540..e93501a 100644 --- a/PrintRScript.py +++ b/PrintRScript.py @@ -540,11 +540,23 @@ def barplot(table, rownames, colnames, rgraph, tmpgraph, intxt = False) : tominf <- which(di == -Inf) if (length(toinf)) { di[toinf] <- NA - di[toinf] <- max(di, na.rm = TRUE) + 2 + valmax <- max(di, na.rm = TRUE) + if (valmax <= 0) { + valmax <- 2 + } else { + valmax <- valmax + 2 + } + di[toinf] <- valmax } if (length(tominf)) { di[tominf] <- NA - di[tominf] <- min(di, na.rm = TRUE) - 2 + valmin <- min(di, na.rm = TRUE) + if (valmin >=0) { + valmin <- -2 + } else { + valmin <- valmin -2 + } + di[tominf] <- valmin } rownames(di)<- %s colnames(di) <- %s diff --git a/ProfList.py b/ProfList.py index 9097897..596b4e6 100644 --- a/ProfList.py +++ b/ProfList.py @@ -154,18 +154,9 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col def OnItemSelected(self, event): self.currentItem = event.m_itemIndex - #print 'OnItemSelected: "%s", "%s", "%s", "%s"\n' % (self.currentItem, self.GetItemText(self.currentItem), self.getColumnText(self.currentItem, 1), self.getColumnText(self.currentItem, 2)) - #self.log.WriteText('OnItemSelected: "%s", "%s", "%s", "%s"\n' % - # (self.currentItem, - # self.GetItemText(self.currentItem), - # self.getColumnText(self.currentItem, 1), - # self.getColumnText(self.currentItem, 2))) def OnItemActivated(self, event): self.currentItem = event.m_itemIndex - #print "OnItemActivated: %s\nTopItem: %s\n" % (self.GetItemText(self.currentItem), self.GetTopItem()) - #self.log.WriteText("OnItemActivated: %s\nTopItem: %s\n" % - # (self.GetItemText(self.currentItem), self.GetTopItem())) def getColumnText(self, index, col): item = self.GetItem(index, col) @@ -173,9 +164,6 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col def OnItemDeselected(self, evt): pass - #self.log.WriteText("OnItemDeselected: %s" % evt.m_itemIndex) - - #--------------------------------------------------- # These methods are callbacks for implementing the # "virtualness" of the list... @@ -200,7 +188,6 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col def OnGetItemAttr(self, item): index=self.itemIndexMap[item] - #genre=self.itemDataMap[index][2] if index < self.lenact : if item % 2 : return self.attr1 @@ -219,15 +206,6 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col else : return None -# if genre=="Rock": -# return self.attr2 -# elif genre=="Jazz": -# return self.attr1 -# elif genre=="New Age": -# return self.attr3 -# else: -# return None - #--------------------------------------------------- # Matt C, 2006/02/22 # Here's a better SortItems() method -- diff --git a/corpusNG.py b/corpusNG.py index 5e7ba26..50f90e7 100644 --- a/corpusNG.py +++ b/corpusNG.py @@ -127,6 +127,19 @@ class Corpus : res = self.cformes.execute('SELECT uces FROM uces where id=? ORDER BY id;', (`wordid`,)) return list(itertools.chain(*[[int(val) for val in row[0].split()] if not isinstance(row[0], int) else [row[0]] for row in res])) + def getformeuceseff(self, formeid) : + if isinstance(formeid, basestring) : + formeid = self.formes[formeid].ident + res = self.cformes.execute('SELECT uces FROM uces where id=? ORDER BY id;', (`formeid`,)) + uces = list(itertools.chain(*[[int(val) for val in row[0].split()] if not isinstance(row[0], int) else [row[0]] for row in res])) + query = 'SELECT eff FROM eff where id=%i ORDER BY id' % formeid + res = self.cformes.execute(query) + eff = list(itertools.chain(*[[int(val) for val in row[0].split()] if not isinstance(row[0], int) else [row[0]] for row in res])) + formeuceeff = {} + for i, uce in enumerate(uces) : + formeuceeff[uce] = formeuceeff.get(uce, 0) + eff[i] + return formeuceeff + def getlemuces(self, lem) : formesid = ', '.join([`val` for val in self.lems[lem].formes]) query = 'SELECT uces FROM uces where id IN (%s) ORDER BY id' % formesid @@ -137,7 +150,7 @@ class Corpus : uces = self.getlemuces(lem) return list(set([self.getucefromid(val).uci for val in uces])) - def getlemuceseff(self, lem) : + def getlemuceseff(self, lem, luces = None) : formesid = ', '.join([`val` for val in self.lems[lem].formes]) query = 'SELECT uces FROM uces where id IN (%s) ORDER BY id' % formesid res = self.cformes.execute(query) @@ -251,7 +264,7 @@ class Corpus : self.iduces = dict([[uce.ident, uce] for uci in self.ucis for uce in uci.uces]) def make_lexitable(self, mineff, etoiles) : - tokeep = [lem for lem in self.lems if self.lems[lem].freq > mineff] + tokeep = [lem for lem in self.lems if self.lems[lem].freq >= mineff] etuces = [[] for et in etoiles] for uci in self.ucis : get = list(set(uci.etoiles).intersection(etoiles)) @@ -385,6 +398,28 @@ class Corpus : actpara = self.iduces[uce[0]].para ident += 1 f.write('\n'.join([self.ucis[self.iduces[uce[0]].uci].paras[ident].encode(self.parametres['syscoding']), uce[1].encode(self.parametres['syscoding'])]) + '\n') + + def export_corpus_classes(self, outf, alc = True, lem = False) : + ucecl = {} + for i, lc in enumerate(self.lc) : + for uce in lc : + ucecl[uce] = i + 1 + for uce in self.lc0 : + ucecl[uce] = 0 + res = self.getalluces() + self.make_iduces() + with open(outf, 'w') as f : + for uce in res : + guce = uce[1] + actuci = self.iduces[uce[0]].uci + if lem : + guce = ' '.join([self.formes[forme].lem for forme in guce.split()]) + if alc : + etline = ' '.join(self.ucis[self.iduces[uce[0]].uci].etoiles + ['*classe_%i' % ucecl[uce[0]]]) + else : + etline = ' '.join(['<' + '='.join(et.split('_')) + '>' for et in self.ucis[self.iduces[uce[0]].uci].etoiles[1:]]) + f.write(etline.encode(self.parametres['syscoding']) + '\n') + f.write(guce.encode(self.parametres['syscoding']) + '\n\n') def make_and_write_sparse_matrix_from_uces(self, actives, outfile, listuce = False) : log.info('make_and_write_sparse_matrix_from_uces %s' % outfile) @@ -451,7 +486,9 @@ class Corpus : def parse_active(self, gramact, gramsup = None) : log.info('parse actives') for lem in self.lems : - if self.lems[lem].gram in gramact : + if lem.startswith('_') and lem.endswith('_') : + self.lems[lem].act = 2 + elif self.lems[lem].gram in gramact : self.lems[lem].act = 1 elif gramsup is not None : if self.lems[lem].gram in gramsup : @@ -622,7 +659,23 @@ class Corpus : result = [[seg] + [str(val) for val in d[seg]] for seg in d if sum(d[seg]) >= effmin] with open(fileout, 'w') as f : f.write('\n'.join([';'.join(line) for line in result])) - + + def make_proftype(self, outf) : + res = {} + for lem in self.lems : + gram = self.lems[lem].gram + if not gram in res : + res[gram] = [0 for val in self.lc] + lemuceeff = self.getlemuceseff(lem) + for i, classe in enumerate(self.lc) : + concern = set(classe).intersection(lemuceeff.keys()) + res[gram][i] += sum([lemuceeff[uce] for uce in concern]) + res = [[gram] + [`val` for val in res[gram]] for gram in res] + res.sort() + with open(outf, 'w') as f : + f.write('\n'.join([';'.join(line) for line in res]).encode(self.parametres['syscoding'])) + + def make_ucecl_from_R(self, filein) : with open(filein, 'rU') as f : c = f.readlines() @@ -637,6 +690,28 @@ class Corpus : self.lc = [[uce[0] for uce in self.lc if uce[1] == i] for i in range(clnb+1)] self.lc0 = self.lc.pop(0) #return ucecl + + def get_stat_by_cluster(self, outf) : + log.info('get_stat_by_cluster') + t1 = time() + occurrences = dict([[i + 1, 0] for i in range(len(self.lc))]) + formescl = dict([[i + 1, 0] for i in range(len(self.lc))]) + hapaxcl = dict([[i + 1, 0] for i in range(len(self.lc))]) + lenclasses = dict([[i+1,len(cl)] for i, cl in enumerate(self.lc)]) + sets = [set(cl) for cl in self.lc] + for forme in self.formes : + formeuceeff = self.getformeuceseff(forme) + for i, classe in enumerate(self.lc) : + concern = sets[i].intersection(formeuceeff.keys()) + if len(concern) : + occurrences[i+1] += sum([formeuceeff[uce] for uce in concern]) + formescl[i+1] += 1 + if self.formes[forme].freq == 1 : + hapaxcl[i+1] += 1 + toprint = '\n'.join([';'.join([`i`, `occurrences[i]`, `formescl[i]`, `hapaxcl[i]`, `lenclasses[i]`, `float(hapaxcl[i])/float(formescl[i])`]) for i in occurrences]) + with open(outf, 'w') as f : + f.write(toprint) + log.info('%f' % (time() - t1)) def gethapaxbyet(self, etoiles) : hapaxuces = [self.getlemuces(forme)[0] for forme in self.lems if self.lems[forme].freq == 1] diff --git a/functions.py b/functions.py index 480f277..aee5d9b 100644 --- a/functions.py +++ b/functions.py @@ -264,7 +264,7 @@ def treat_line_alceste(i, line) : line[5] = str(float(line[5].replace(',', '.')))[0:7] return [i, int(line[0]), int(line[1]), float(line[2]), float(line[3]), line[6], line[4], line[5]] -def ReadProfileAsDico(parent, File, Alceste=False, encoding = sys.getdefaultencoding()): +def ReadProfileAsDico(File, Alceste=False, encoding = sys.getdefaultencoding()): #print 'lecture des profils : ReadProfileAsDico' #if Alceste : # print 'lecture du dictionnaire de type' @@ -274,7 +274,6 @@ def ReadProfileAsDico(parent, File, Alceste=False, encoding = sys.getdefaultenco dictlem = {} print 'lecture des profiles' #encoding = sys.getdefaultencoding() - print encoding FileReader = codecs.open(File, 'r', encoding) Filecontent = FileReader.readlines() FileReader.close() @@ -298,11 +297,11 @@ def ReadProfileAsDico(parent, File, Alceste=False, encoding = sys.getdefaultenco DictProfile[cluster] = [valclusters[i]] + prof[i] return DictProfile -def GetTxtProfile(dictprofile) : +def GetTxtProfile(dictprofile, cluster_size) : proflist = [] for classe in range(0, len(dictprofile)) : prof = dictprofile[str(classe + 1)] - clinfo = prof[0] + clinfo = cluster_size[classe] proflist.append('\n'.join([' '.join(['classe %i' % (classe + 1), '-', '%s uce sur %s - %s%%' % (clinfo[0], clinfo[1], clinfo[2])]), '\n'.join(['%5s|%5s|%6s|%6s|%8s|%8s|%20s\t%10s' % tuple([str(val) for val in line]) for line in prof if len(line)==8])])) return '\n\n'.join(proflist) @@ -541,9 +540,9 @@ def read_list_file(filename, encoding = sys.getdefaultencoding()): ncontent=[line.replace('\n','').split(';') for line in content if line.strip() != ''] return ncontent -class MessageImage(wx.Dialog): +class MessageImage(wx.Frame): def __init__(self, parent,title, size): - wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = title, pos = wx.DefaultPosition, size = size, style = wx.DEFAULT_DIALOG_STYLE ) + wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = title, pos = wx.DefaultPosition, size = size, style = wx.DEFAULT_FRAME_STYLE ) self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) self.imageFile = False self.imagename = u"chi_classe.png" diff --git a/iramuteq.py b/iramuteq.py index 2961efc..91cf8f0 100644 --- a/iramuteq.py +++ b/iramuteq.py @@ -295,7 +295,6 @@ class IraFrame(wx.Frame): self.Sheet = MySheet(self) #self._mgr.AddPane(self.Sheet, wx.aui.AuiPaneInfo().Name("Data").CenterPane()) self._mgr.AddPane(self.Sheet, aui.AuiPaneInfo().Name("Data").CenterPane()) - #self.nb.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnCloseTab) self.nb.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnCloseTab) self.nb.Bind(aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.OnPageChanged) # add the toolbars to the manager @@ -652,14 +651,14 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis.""" self.tree.GiveFocus(uuid=npage.parametres['uuid']) def OnCloseTab(self, evt): - log.info('Closing tab %s' % str(evt.GetEventObject())) + #log.info('Closing tab %s' % str(evt.GetEventObject())) ctrl = evt.GetEventObject() if isinstance(ctrl.GetParent(), aui.AuiNotebook) or isinstance(ctrl.GetParent(), wx.Panel): notebook = True else : notebook = False page = self.nb.GetPage(self.nb.GetSelection()) - if 'parametres' in dir(page) : + if 'parametres' in dir(page) and isinstance(ctrl.GetParent(), IraFrame) : self.history.rmtab(page.parametres) self.tree.CloseItem(uuid = page.parametres['uuid']) TabTitle = self.nb.GetPageText(self.nb.GetSelection()) diff --git a/layout.py b/layout.py index 384e000..df30cfd 100644 --- a/layout.py +++ b/layout.py @@ -10,11 +10,11 @@ import wx import agw.aui as aui from chemins import ConstructPathOut, ChdTxtPathOut, FFF, ffr, PathOut, StatTxtPathOut, simipath from ConfigParser import ConfigParser -from functions import ReadProfileAsDico, GetTxtProfile, read_list_file, ReadList, exec_rcode, print_liste, BugReport, DoConf, indices_simi +from functions import ReadProfileAsDico, GetTxtProfile, read_list_file, ReadList, exec_rcode, print_liste, BugReport, DoConf, indices_simi, check_Rresult from ProfList import * from guiparam3d import param3d, simi3d from PrintRScript import write_afc_graph, print_simi3d, PrintSimiScript -from profile_segment import * +from profile_segment import ProfileSegment from functions import ReadList from listlex import * from Liste import * @@ -26,7 +26,7 @@ import datetime import sys import tempfile import shutil -import webbrowser +#import webbrowser import codecs import logging @@ -273,7 +273,18 @@ class GraphPanel(wx.ScrolledWindow): self.sizer_2.Add(self.sizer_1, 1, wx.EXPAND, 0) self.SetSizer(self.sizer_1) self.sizer_1.Fit(self) - + + +def open_antiprofil(panel, AntiProfile, encoding) : + DictAnti = ReadProfileAsDico(AntiProfile, True, encoding) + panel.AntiProfNB = aui.AuiNotebook(panel, -1, wx.DefaultPosition) + for i in range(0, panel.parametres['clnb']): + tabantiprofile = ProfListctrlPanel(panel, panel, DictAnti[str(i + 1)], True, i + 1) + panel.AntiProfNB.AddPage(tabantiprofile, 'classe %s' % str(i + 1)) + panel.TabChdSim.AddPage(panel.AntiProfNB, 'Antiprofils') + + + class OpenCHDS(): def __init__(self, parent, corpus, parametres, Alceste=False): #sep = u'\n ' @@ -296,18 +307,6 @@ class OpenCHDS(): elif 'tableau' in dir(gparent) : self.encoding = gparent.tableau.parametres['syscoding'] - #AnalyseConf = ConfigParser() - #AnalyseConf.readfp(codecs.open(filename,'r', self.encoding)) - #AnalyseConf.read(filename) - #if 'analyse' in AnalyseConf.sections() : - # section = 'analyse' - #elif 'questionnaire' in AnalyseConf.sections() : - # section = 'questionnaire' - #elif 'chd_dist_quest' in AnalyseConf.sections() : - # section = 'chd_dist_quest' - #self.section = section - #clnb = AnalyseConf.get(section, 'clusternb') - #clnb = int(clnb) clnb = parametres['clnb'] dlg = progressbar(self, maxi = 4 + clnb) self.clnb = clnb @@ -315,55 +314,41 @@ class OpenCHDS(): print 'lecture des profils' dlg.Update(2, u'lecture des profils') - DictProfile = ReadProfileAsDico(self, Profile, Alceste, self.encoding) + DictProfile = ReadProfileAsDico(Profile, Alceste, self.encoding) self.DictProfile = DictProfile + self.cluster_size = [] #print 'lecture des antiprofils' #DictAnti = ReadProfileAsDico(self, AntiProfile, Alceste, self.encoding) panel = wx.Panel(parent, -1) sizer1 = wx.BoxSizer(wx.VERTICAL) - panel.chd_toolbar = wx.ToolBar(panel, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER) - panel.chd_toolbar.SetToolBitmapSize(wx.Size(16, 16)) + if os.path.exists(DictPathOut['pre_rapport']): + with codecs.open(DictPathOut['pre_rapport'], 'r', self.encoding) as f : + txt = f.read() + self.debtext = txt + else : + self.debtext = '' +# panel.chd_toolbar = wx.ToolBar(panel, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER) +# panel.chd_toolbar.SetToolBitmapSize(wx.Size(16, 16)) if isinstance(self.corpus, Corpus) : panel.corpus = self.corpus - self.ID_sg = wx.NewId() - butsg = wx.Button(panel.chd_toolbar, self.ID_sg, u"Profils des segments répétés ") - panel.chd_toolbar.AddControl(butsg) - panel.chd_toolbar.AddSeparator() - self.ID_export = wx.NewId() - butexp = wx.Button(panel.chd_toolbar, self.ID_export, u"Exporter le corpus ") - panel.chd_toolbar.AddControl(butexp) - panel.chd_toolbar.AddSeparator() - self.ID_colored = wx.NewId() - butcol = wx.Button(panel.chd_toolbar, self.ID_colored, u"Corpus en couleur ") - panel.chd_toolbar.AddControl(butcol) - panel.chd_toolbar.AddSeparator() - self.ID_searchf = wx.NewId() - butsearchf = wx.Button(panel.chd_toolbar, self.ID_searchf, u"Outil de navigation ") - panel.chd_toolbar.AddControl(butsearchf) - panel.chd_toolbar.AddSeparator() - - self.ID_proftype =wx.NewId() - butpt = wx.Button(panel.chd_toolbar, self.ID_proftype, u"Profils des types ") - panel.chd_toolbar.AddControl(butpt) - panel.chd_toolbar.AddSeparator() - - self.ID_clusterstat =wx.NewId() - butclusterstat = wx.Button(panel.chd_toolbar, self.ID_clusterstat, u"Stat par classe ") - panel.chd_toolbar.AddControl(butclusterstat) - panel.chd_toolbar.AddSeparator() - - - self.ID_rapport = wx.NewId() - #rap_img = wx.Image(os.path.join(self.parent.images_path,'icone_rap_16.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap() - #panel.chd_toolbar.AddLabelTool(self.ID_rapport, "rapport", rap_img, shortHelp=u"Produire le rapport", longHelp=u"Exporter un rapport en texte simple") - butrap = wx.Button(panel.chd_toolbar, self.ID_rapport, u"Rapport ") - panel.chd_toolbar.AddControl(butrap) - - panel.chd_toolbar.Realize() - sizer1.Add(panel.chd_toolbar,0, wx.EXPAND, 5) + panel.dictpathout = self.DictPathOut + panel.pathout = self.DictPathOut + panel.parent = self.parent + panel.DictProfile = self.DictProfile + panel.cluster_size = self.cluster_size + panel.debtext = self.debtext + +# self.ID_rapport = wx.NewId() +# #rap_img = wx.Image(os.path.join(self.parent.images_path,'icone_rap_16.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap() +# #panel.chd_toolbar.AddLabelTool(self.ID_rapport, "rapport", rap_img, shortHelp=u"Produire le rapport", longHelp=u"Exporter un rapport en texte simple") +# butrap = wx.Button(panel.chd_toolbar, self.ID_rapport, u"Rapport ") +# panel.chd_toolbar.AddControl(butrap) +# +# panel.chd_toolbar.Realize() +# sizer1.Add(panel.chd_toolbar,0, wx.EXPAND, 5) #self.TabChdSim = wx.aui.AuiNotebook(self.parent.nb, -1, wx.DefaultPosition) notebook_flags = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_FLOAT| wx.NO_BORDER @@ -379,18 +364,10 @@ class OpenCHDS(): panel.TabChdSim.corpus = corpus panel.TabChdSim.corpus.dictpathout = self.DictPathOut panel.parametres = self.parametres + self.panel = panel self.notenb = self.parent.nb.GetPageCount() - if os.path.exists(DictPathOut['pre_rapport']): - #self.tabRap = wx.TextCtrl(self.TabChdSim, -1, "", style=wx.TE_MULTILINE | wx.TE_RICH2) - #self.tabRap.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier")) - with codecs.open(DictPathOut['pre_rapport'], 'r', self.encoding) as f : - txt = f.read() - #self.tabRap.write(txt) - #self.tabRap.ShowPosition(0) - self.debtext = txt - else : - self.debtext = '' + if os.path.exists(self.DictPathOut['liste_graph_chd']) : list_graph = read_list_file(self.DictPathOut['liste_graph_chd'], self.encoding) @@ -402,13 +379,14 @@ class OpenCHDS(): #self.ProfNB.SetTabCtrlHeight(100) #panel.AntiProfNB = aui.AuiNotebook(panel, -1, wx.DefaultPosition) if os.path.exists(DictPathOut['prof_seg']) : - prof_seg = ReadProfileAsDico(self, DictPathOut['prof_seg'], False, self.encoding) + prof_seg = ReadProfileAsDico(DictPathOut['prof_seg'], False, self.encoding) self.prof_seg_nb = aui.AuiNotebook(panel, -1, wx.DefaultPosition) for i in range(0, clnb): + self.cluster_size.append(DictProfile[str(i + 1)][0][0:3]) dlg.Update(3+i, 'Classe %i' %(i+1)) ind = '/'.join(DictProfile[str(i + 1)][0][0:2]) indpour = ' - '.join([ind, DictProfile[str(i + 1)][0][2]]) - self.tabprofile = ProfListctrlPanel(self.parent, self, DictProfile[str(i + 1)], Alceste, i + 1) + self.tabprofile = ProfListctrlPanel(self.parent, self.panel, DictProfile[str(i + 1)], Alceste, i + 1) #self.tabantiprofile = ProfListctrlPanel(self.parent, self, DictAnti[str(i + 1)], Alceste, i + 1) panel.ProfNB.AddPage(self.tabprofile, 'classe %s %s(%s%%)' % (str(i + 1), sep, indpour)) #panel.AntiProfNB.AddPage(self.tabantiprofile, 'classe %s' % str(i + 1)) @@ -452,15 +430,7 @@ class OpenCHDS(): if os.path.exists(DictPathOut['prof_seg']) : panel.TabChdSim.AddPage(self.prof_seg_nb, u'Profils des segments répétés') - if isinstance(self.corpus, Corpus) : - panel.Bind(wx.EVT_BUTTON, self.on_export_classes, id = self.ID_export) - panel.Bind(wx.EVT_BUTTON, self.onprofseg, id = self.ID_sg) - panel.Bind(wx.EVT_BUTTON, self.oncolored, id = self.ID_colored) - panel.Bind(wx.EVT_BUTTON, self.onsearchf, id = self.ID_searchf) - panel.Bind(wx.EVT_BUTTON, self.onproftype, id = self.ID_proftype) - panel.Bind(wx.EVT_BUTTON, self.onclusterstat, id = self.ID_clusterstat) - - panel.Bind(wx.EVT_BUTTON, self.ongetrapport, id = self.ID_rapport) +# panel.Bind(wx.EVT_BUTTON, self.ongetrapport, id = self.ID_rapport) self.parent.nb.AddPage(panel, 'Classification - %s' % corpname) self.parent.ShowTab(True) self.parent.nb.SetSelection(self.parent.nb.GetPageCount() - 1) @@ -476,76 +446,76 @@ class OpenCHDS(): outfile = print_simi3d(self) error = exec_rcode(self.parent.RPath, outfile, wait = True) - def ongetrapport(self, event) : - dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.txt', 'title': 'Rapport'}) - dial.fbb.SetValue(self.DictPathOut['rapport']) - dial.CenterOnParent() - res = dial.ShowModal() - if res == wx.ID_OK : - fileout = dial.fbb.GetValue() - dial.Destroy() - with open(fileout, 'w') as f : - f.write(self.debtext + '\n' + GetTxtProfile(self.DictProfile)) - msg = u"Fini !" - dlg = wx.MessageDialog(self.parent, msg, u"Rapport", wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION) - dlg.CenterOnParent() - dlg.ShowModal() - dlg.Destroy() - else : - dial.Destroy() - - def on_export_classes(self, event) : - corpus = self.parent.nb.GetPage(self.parent.nb.GetSelection()).corpus - dial = PrefExport(self, self.parent) - dial.fbb.SetValue(os.path.join(os.path.dirname(corpus.dictpathout['ira']), 'export_corpus.txt')) - dial.CenterOnParent() - res = dial.ShowModal() - if res == wx.ID_OK : - if dial.radio_type.GetSelection() == 0 : alc = True - else : alc = False - if dial.radio_lem.GetSelection() == 0 : lem = True - else : lem = False - self.corpus.export_corpus_classes(dial.fbb.GetValue(), alc = alc, lem = lem) - msg = u"Fini !" - dial.Destroy() - dlg = wx.MessageDialog(self.parent, msg, u"Export", wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION) - dlg.CenterOnParent() - dlg.ShowModal() - dlg.Destroy() - - def onprofseg(self, event): - #try : - print 'plus de bug profseg' - print self.parametres - corpus = self.parent.nb.GetPage(self.parent.nb.GetSelection()).corpus - ProfileSegment(self.parent, self.dictpathout, self.parametres, corpus) - #except : - # BugReport(self.parent) - - def onproftype(self, event): - try : - corpus = self.parent.nb.GetPage(self.parent.nb.GetSelection()).corpus - ProfilType(self.parent, corpus) - except : - BugReport(self.parent) - - def oncolored(self,evt) : - dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.html', 'title': 'Corpus en couleur'}) - dial.fbb.SetValue(os.path.join(os.path.dirname(self.corpus.dictpathout['ira']), 'corpus_couleur.html')) - dial.CenterOnParent() - res = dial.ShowModal() - if res == wx.ID_OK : - fileout = dial.fbb.GetValue() - dial.Destroy() - txt = self.corpus.make_colored_corpus() - 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) - dlg.CenterOnParent() - if dlg.ShowModal() == wx.ID_YES : - webbrowser.open(fileout) - dlg.Destroy() +# def ongetrapport(self, event) : +# dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.txt', 'title': 'Rapport'}) +# dial.fbb.SetValue(self.DictPathOut['rapport']) +# dial.CenterOnParent() +# res = dial.ShowModal() +# if res == wx.ID_OK : +# fileout = dial.fbb.GetValue() +# dial.Destroy() +# with open(fileout, 'w') as f : +# f.write(self.debtext + '\n' + GetTxtProfile(self.DictProfile, self.cluster_size)) +# msg = u"Fini !" +# dlg = wx.MessageDialog(self.parent, msg, u"Rapport", wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION) +# dlg.CenterOnParent() +# dlg.ShowModal() +# dlg.Destroy() +# else : +# dial.Destroy() + +# def on_export_classes(self, event) : +# corpus = self.parent.nb.GetPage(self.parent.nb.GetSelection()).corpus +# dial = PrefExport(self, self.parent) +# dial.fbb.SetValue(os.path.join(os.path.dirname(corpus.dictpathout['ira']), 'export_corpus.txt')) +# dial.CenterOnParent() +# res = dial.ShowModal() +# if res == wx.ID_OK : +# if dial.radio_type.GetSelection() == 0 : alc = True +# else : alc = False +# if dial.radio_lem.GetSelection() == 0 : lem = True +# else : lem = False +# self.corpus.export_corpus_classes(dial.fbb.GetValue(), alc = alc, lem = lem) +# msg = u"Fini !" +# dial.Destroy() +# dlg = wx.MessageDialog(self.parent, msg, u"Export", wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION) +# dlg.CenterOnParent() +# dlg.ShowModal() +# dlg.Destroy() + +# def onprofseg(self, event): +# #try : +# print 'plus de bug profseg' +# print self.parametres +# corpus = self.parent.nb.GetPage(self.parent.nb.GetSelection()).corpus +# ProfileSegment(self.parent, self.dictpathout, self.parametres, corpus) +# #except : +# # BugReport(self.parent) +# +# def onproftype(self, event): +# try : +# corpus = self.parent.nb.GetPage(self.parent.nb.GetSelection()).corpus +# ProfilType(self.parent, corpus) +# except : +# BugReport(self.parent) +# +# def oncolored(self,evt) : +# dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.html', 'title': 'Corpus en couleur'}) +# dial.fbb.SetValue(os.path.join(os.path.dirname(self.corpus.dictpathout['ira']), 'corpus_couleur.html')) +# dial.CenterOnParent() +# res = dial.ShowModal() +# if res == wx.ID_OK : +# fileout = dial.fbb.GetValue() +# dial.Destroy() +# txt = self.corpus.make_colored_corpus() +# 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) +# dlg.CenterOnParent() +# if dlg.ShowModal() == wx.ID_YES : +# webbrowser.open(fileout) +# dlg.Destroy() def onclusterstat(self, evt) : dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.csv', 'title': 'Stat par classe'}) @@ -563,10 +533,10 @@ class OpenCHDS(): if dlg.ShowModal() == wx.ID_OK : dlg.Destroy() - def onsearchf(self, evt) : - if 'FrameSearch' not in dir(self.parent) : - self.parent.FrameSearch = SearchFrame(self.parent, -1, u"Rechercher...", self.corpus) - self.parent.FrameSearch.Show() + #def onsearchf(self, evt) : + # if 'FrameSearch' not in dir(self.panel) : + # self.panel.FrameSearch = SearchFrame(self.parent, -1, u"Rechercher...", self.corpus) + # self.panel.FrameSearch.Show() diff --git a/profile_segment.py b/profile_segment.py index 3def4b8..639b660 100644 --- a/profile_segment.py +++ b/profile_segment.py @@ -64,7 +64,6 @@ class ProfileSegment() : def do_layout(self) : SelectTab = self.parent.nb.GetSelection() page = self.parent.nb.GetPage(SelectTab).TabChdSim - print page prof_seg = ReadProfileAsDico(self, self.dictpathout['prof_seg'], True, self.parent.syscoding) prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition) for i in range(0,len(self.corpus.lc)) : @@ -74,9 +73,10 @@ class ProfileSegment() : page.SetSelection(page.GetPageCount() - 1) class ProfilType() : - def __init__(self, parent, corpus) : + def __init__(self, parent, corpus, parametres) : self.parent = parent self.corpus = corpus + self.parametres = parametres self.outprof = self.corpus.dictpathout['prof_type'] dial = PrefProfTypes(self.parent) dial.fbb.SetValue(self.outprof) @@ -87,10 +87,10 @@ class ProfilType() : alceste = True else : alceste = False - if 'outprof' in self.corpus.parametre : - self.corpus.parametre['outprof'][self.outprof] = alceste - else : - self.corpus.parametre['outprof'] = {self.outprof: alceste} + #if 'outprof' in self.corpus.parametre : + # self.corpus.parametre['outprof'][self.outprof] = alceste + #else : + # self.corpus.parametre['outprof'] = {self.outprof: alceste} self.dlg = progressbar(self, maxi = 4) self.dlg.Update(1, u'Recherche des types') self.make_table() @@ -102,7 +102,7 @@ class ProfilType() : self.dlg.Destroy() def make_table(self) : - self.corpus.prof_type() + self.corpus.make_proftype(self.corpus.dictpathout['type_cl']) def make_prof(self, alceste = True) : txt = """ diff --git a/tree.py b/tree.py index 5e13814..9d69efc 100644 --- a/tree.py +++ b/tree.py @@ -5,21 +5,28 @@ #Lisense: GNU GPL import wx +import os +import webbrowser import wx.lib.agw.customtreectrl as CT import logging from openanalyse import OpenAnalyse from corpusNG import Corpus, copycorpus -from functions import DoConf - +from functions import DoConf, GetTxtProfile +from profile_segment import ProfileSegment, ProfilType +from search_tools import SearchFrame +from dialog import PrefSimpleFile, PrefExport +from layout import open_antiprofil log = logging.getLogger('iramuteq.tree') -#from agw import customtreectrl as CT 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 self.SetSizeHintsSz( wx.Size( 500,200 ), wx.DefaultSize ) bSizer1 = wx.BoxSizer( wx.VERTICAL ) @@ -38,7 +45,8 @@ class InfoDialog ( wx.Dialog ): 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 ) - fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 ) + + fgSizer1 = wx.FlexGridSizer( 0, nb, 0, 0 ) fgSizer1.SetFlexibleDirection( wx.BOTH ) fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) @@ -46,12 +54,12 @@ class InfoDialog ( wx.Dialog ): 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) #fgSizer1.Add( wx.StaticText( self.m_panel1, wx.ID_ANY, val[1], wx.DefaultPosition, wx.DefaultSize, 0 ), 0, wx.ALL, 0) - txtctrl.append( wx.TextCtrl( self.m_panel1, wx.ID_ANY, val[1], wx.DefaultPosition, (500, 20), wx.TE_READONLY ) ) + txtctrl.append( wx.TextCtrl( self.m_panel1, wx.ID_ANY, val[1], wx.DefaultPosition, (450, 20), wx.TE_READONLY ) ) txtctrl[-1].SetBackgroundColour('#DDE8EB') #wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)) fgSizer1.Add( txtctrl[-1], 0, wx.ALL|wx.EXPAND, 0) - fgSizer1.Add( wx.StaticLine( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ), 0, wx.EXPAND |wx.ALL, 0) - fgSizer1.Add( wx.StaticLine( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ), 0, wx.EXPAND|wx.ALL, 0) + #fgSizer1.Add( wx.StaticLine( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ), 0, wx.EXPAND |wx.ALL, 0) + #fgSizer1.Add( wx.StaticLine( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ), 0, wx.EXPAND|wx.ALL, 0) self.m_panel1.SetSizer( fgSizer1 ) self.m_panel1.Layout() @@ -100,14 +108,6 @@ class LeftTree(CT.CustomTreeCtrl): il = wx.ImageList(16, 16) -# for items in ArtIDs[1:-1]: -# bmp = wx.ArtProvider_GetBitmap(eval(items), wx.ART_TOOLBAR, (16, 16)) -# il.Add(bmp) - -# smileidx = il.Add(images.Smiles.GetBitmap()) -# numicons = il.GetImageCount() - - #self.AssignImageList(il) self.count = 0 self.log = log @@ -120,46 +120,12 @@ class LeftTree(CT.CustomTreeCtrl): self.SetItemImage(self.root, 24, CT.TreeItemIcon_Normal) self.SetItemImage(self.root, 13, CT.TreeItemIcon_Expanded) - #textctrl = wx.TextCtrl(self, -1, "I Am A Simple\nMultiline wx.TexCtrl", style=wx.TE_MULTILINE) - #self.gauge = wx.Gauge(self, -1, 50, style=wx.GA_HORIZONTAL|wx.GA_SMOOTH) - #self.gauge.SetValue(0) - #combobox = wx.ComboBox(self, -1, choices=["That", "Was", "A", "Nice", "Holyday!"], style=wx.CB_READONLY|wx.CB_DROPDOWN) - - #textctrl.Bind(wx.EVT_CHAR, self.OnTextCtrl) - #combobox.Bind(wx.EVT_COMBOBOX, self.OnComboBox) - #lenArtIds = len(ArtIDs) - 2 for corpus in self.h : - #if 'corpus_name' in self.h[self.history.order[x]] : - # key = 'corpus_name' - #else : - # key = 'name' child = self.AppendItem(self.root, corpus['corpus_name']) - #if x == 1: - # child = self.AppendItem(self.root, "Item %d" % x + "\nHello World\nHappy wxPython-ing!") - # self.SetItemBold(child, True) - #else: - # child = self.AppendItem(self.root, "Item %d" % x) self.SetPyData(child, corpus) self.SetItemImage(child, 24, CT.TreeItemIcon_Normal) self.SetItemImage(child, 13, CT.TreeItemIcon_Expanded) - #if random.randint(0, 3) == 0: - # self.SetItemLeftImage(child, random.randint(0, lenArtIds)) - - #for y in range(5): - # if y == 0 and x == 1: - # last = self.AppendItem(child, "item %d-%s" % (x, chr(ord("a")+y)), ct_type=2, wnd=self.gauge) - # elif y == 1 and x == 2: - # last = self.AppendItem(child, "Item %d-%s" % (x, chr(ord("a")+y)), ct_type=1, wnd=textctrl) - # if random.randint(0, 3) == 1: - # self.SetItem3State(last, True) - # - # elif 2 < y < 4: - # last = self.AppendItem(child, "item %d-%s" % (x, chr(ord("a")+y))) - # elif y == 4 and x == 1: - # last = self.AppendItem(child, "item %d-%s" % (x, chr(ord("a")+y)), wnd=combobox) - # else: - # if 'corpus_name' in self.h[self.history.order[x]] : if 'analyses' in corpus : for y in corpus['analyses'] : last = self.AppendItem(child, y['name'], ct_type=0) @@ -168,27 +134,6 @@ class LeftTree(CT.CustomTreeCtrl): self.SetItemImage(last, 24, CT.TreeItemIcon_Normal) self.SetItemImage(last, 13, CT.TreeItemIcon_Expanded) - # if random.randint(0, 3) == 0: - # self.SetItemLeftImage(last, random.randint(0, lenArtIds)) - - #for z in range(len(self.history[x]) - 1): - -# if z > 2: -# item = self.AppendItem(last, "item %d-%s-%d" % (x, chr(ord("a")+y), z), ct_type=0) -# #if random.randint(0, 3) == 1: -# # self.SetItem3State(item, True) -# elif 0 < z <= 2: -# item = self.AppendItem(last, "item %d-%s-%d" % (x, chr(ord("a")+y), z), ct_type=0) -# elif z == 0: -# item = self.AppendItem(last, "item %d-%s-%d" % (x, chr(ord("a")+y), z)) -# #self.SetItemHyperText(item, True) -# self.SetPyData(item, None) -# self.SetItemImage(item, 28, CT.TreeItemIcon_Normal) -# self.SetItemImage(item, 28, CT.TreeItemIcon_Selected) - - # if random.randint(0, 3) == 0: - # self.SetItemLeftImage(item, random.randint(0, lenArtIds)) - self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick) #self.Bind(wx.EVT_IDLE, self.OnIdle) @@ -206,8 +151,8 @@ class LeftTree(CT.CustomTreeCtrl): 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) + #self.Bind(CT.EVT_TREE_ITEM_EXPANDED, self.OnItemExpanded) + #self.Bind(CT.EVT_TREE_ITEM_COLLAPSED, self.OnItemCollapsed) self.Bind(CT.EVT_TREE_SEL_CHANGED, self.OnSelChanged) self.Bind(CT.EVT_TREE_SEL_CHANGING, self.OnSelChanging) self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown) @@ -385,6 +330,30 @@ class LeftTree(CT.CustomTreeCtrl): 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") + + 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(): @@ -432,6 +401,98 @@ class LeftTree(CT.CustomTreeCtrl): def OnWordCloud(self, evt) : self.parent.OnWordCloud(evt, self.getcorpus(self.itemdict)) + 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 OnExportCorpus(self, evt) : + dial = PrefExport(self, self.parent) + dial.fbb.SetValue(os.path.join(os.path.dirname(self.page.dictpathout['ira']), 'export_corpus.txt')) + dial.CenterOnParent() + res = dial.ShowModal() + if res == wx.ID_OK : + if dial.radio_type.GetSelection() == 0 : alc = True + 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) + msg = u"Fini !" + dial.Destroy() + dlg = wx.MessageDialog(self.parent, msg, u"Export", wx.OK | wx.NO_DEFAULT | 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.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() + 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) + dlg.CenterOnParent() + if dlg.ShowModal() == wx.ID_YES : + webbrowser.open(fileout) + dlg.Destroy() + + 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.Show() + + def StatClasse(self, evt): + dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.csv', 'title': 'Stat par classe'}) + dial.fbb.SetValue( os.path.join(os.path.dirname(self.page.dictpathout['ira']), 'stat_par_classe.csv')) + dial.CenterOnParent() + res = dial.ShowModal() + if res == wx.ID_OK : + fileout = dial.fbb.GetValue() + 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.CenterOnParent() + if dlg.ShowModal() == wx.ID_OK : + 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' : + self.page.TabChdSim.SetSelection(i) + find = True + break + if not find : + open_antiprofil(self.page, self.page.dictpathout['ANTIPRO_OUT'], self.parent.syscoding) + self.page.TabChdSim.SetSelection(self.page.TabChdSim.GetPageCount() - 1) + + def OnRapport(self, evt) : + dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.txt', 'title': 'Rapport'}) + dial.fbb.SetValue(self.page.dictpathout['rapport']) + dial.CenterOnParent() + res = dial.ShowModal() + if res == wx.ID_OK : + fileout = dial.fbb.GetValue() + dial.Destroy() + 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.CenterOnParent() + dlg.ShowModal() + dlg.Destroy() + else : + dial.Destroy() + def OnItemBackground(self, event): colourdata = wx.ColourData() @@ -545,6 +606,7 @@ class LeftTree(CT.CustomTreeCtrl): itemtype = "RadioButton" dlg = InfoDialog(self, itemtext, parametres) + dlg.CenterOnParent() dlg.ShowModal() dlg.Destroy() @@ -674,6 +736,7 @@ class LeftTree(CT.CustomTreeCtrl): else : OpenAnalyse(self.parent, pydata) self.SetItemBold(item, True) + self.OnSelChanged(pydata = pydata) #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") @@ -719,26 +782,20 @@ class LeftTree(CT.CustomTreeCtrl): event.Skip() - def OnSelChanged(self, event): - item = event.GetItem() - pydata = self.GetPyData(item) + def OnSelChanged(self, event = None, pydata = None): + if event is not None : + item = event.GetItem() + pydata = self.GetPyData(item) if pydata is not None : 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.page = self.parent.nb.GetPage(i) + if 'parametres' in dir(self.page) : + if self.page.parametres['uuid'] == pydata['uuid'] : self.parent.nb.SetSelection(i) break - - #self.item = event.GetItem() - #if self.item: - # self. - #self.log.info("OnSelChanged: %s" % self.GetItemText(self.item)) - # if wx.Platform == '__WXMSW__': - # self.log.info(", BoundingRect: %s" % self.GetBoundingRect(self.item, True) + "\n") - # pass - event.Skip() + if event is not None : + event.Skip() def OnSelChanging(self, event): @@ -751,7 +808,7 @@ class LeftTree(CT.CustomTreeCtrl): olditemtext = "None" else: olditemtext = self.GetItemText(olditem) - self.log.info("OnSelChanging: From %s" % olditemtext + " To %s" % self.GetItemText(item) + "\n") + #self.log.info("OnSelChanging: From %s" % olditemtext + " To %s" % self.GetItemText(item) + "\n") event.Skip() -- 2.7.4