2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2008-2009 Pierre Ratinaud
9 #import wx.lib.agw.aui as aui
11 from chemins import ConstructPathOut, ChdTxtPathOut, FFF, ffr, PathOut, StatTxtPathOut, simipath
12 from ConfigParser import ConfigParser
13 from functions import ReadProfileAsDico, GetTxtProfile, read_list_file, ReadList, exec_rcode, print_liste, BugReport, DoConf, indices_simi
14 from ProfList import *
15 from guiparam3d import param3d, simi3d
16 from PrintRScript import write_afc_graph, print_simi3d, PrintSimiScript
17 from profile_segment import *
18 from functions import ReadList
21 from search_tools import SearchFrame
22 from dialog import PrefGraph, PrefExport, PrefSimpleFile, PrefDendro
23 from guifunct import SelectColumn, PrepSimi
24 from corpusNG import Corpus
33 log = logging.getLogger('iramuteq.layout')
36 class GraphPanelAfc(wx.Panel):
37 def __init__(self, parent, dico, list_graph, clnb, itempath = 'liste_graph_afc', coding = sys.getdefaultencoding()):
38 wx.Panel.__init__(self,parent)
43 self.itempath = itempath
44 self.parent = self.GetParent()#parent
45 self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier"))
49 self.list_graph = list_graph
50 self.TabCHD = self.parent.GetParent()
51 self.nb = self.TabCHD.GetParent()
52 self.ira = self.nb.GetParent()
53 self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
54 afc_img = wx.Image(os.path.join(self.ira.images_path,'button_afc.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
55 self.butafc = wx.BitmapButton(self, -1, afc_img)
56 self.Bind(wx.EVT_BUTTON, self.afc_graph, self.butafc)
57 self.dirout = os.path.dirname(self.Dict['ira'])
60 for i in range(0,len(list_graph)):
61 if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
62 self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
63 self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1]))
64 self.buts.append(wx.Button(self.panel_1, wx.ID_DELETE, name = `i - b`))
68 self.list_graph = [graph for i, graph in enumerate(self.list_graph) if i not in todel]
70 self.param = { 'typegraph' : 0,
77 'do_select_chi_classe' : 0,
94 self.__set_properties()
97 def __set_properties(self):
98 self.panel_1.EnableScrolling(True,True)
99 #self.panel_1.SetSize((1000,1000))
100 self.panel_1.SetScrollRate(20, 20)
102 def __do_layout(self):
103 log.info('do layout')
104 self.sizer_1 = wx.BoxSizer(wx.VERTICAL)
105 self.sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
106 self.sizer_3 = wx.BoxSizer(wx.VERTICAL)
107 self.sizer_2.Add(self.butafc, 0, 0, 0)
108 for i in range(0, len(self.listimg)):
109 self.sizer_3.Add(self.listimg[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
110 self.sizer_3.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
111 self.sizer_3.Add(self.buts[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
112 self.Bind(wx.EVT_BUTTON, self.on_delete_image, self.buts[i])
113 self.panel_1.SetSizer(self.sizer_3)
114 self.sizer_2.Add(self.panel_1, 1, wx.EXPAND, 0)
115 self.SetSizer(self.sizer_2)
117 def on_delete_image(self, event) :
118 image_id = int(event.GetEventObject().GetName())
119 image_path = self.list_graph[image_id][0]
120 message = 'This file will be delete : %s.\nAre you sure ?' % os.path.join(self.dirout, image_path)
121 dial = wx.MessageDialog(self, message, style = wx.YES_NO)
122 res = dial.ShowModal()
123 if res == wx.ID_YES :
125 log.info('delete image %i' % image_id)
126 oldimg = self.listimg.pop(image_id)
128 oldlab = self.labels.pop(image_id)
130 oldbut = self.buts.pop(image_id)
132 #No = [but.Destroy() for but in self.buts]
133 #self.buts = [wx.Button(self.panel_1, wx.ID_DELETE, name = `i`) for i, img in enumerate(self.listimg)]
134 for i, but in enumerate(self.buts) :
136 todel = self.list_graph.pop(image_id)
137 os.remove(os.path.join(self.dirout, todel[0]))
138 print_liste(self.Dict[self.itempath], self.list_graph)
139 #self.sizer_1.Destroy()
140 #self.sizer_2.Destroy()
141 #self.sizer_3.Destroy()
143 self.sizer_3.Fit(self.panel_1)
149 def afc_graph(self,event):
150 #dirout = os.path.dirname(self.Dict['ira'])
151 while os.path.exists(os.path.join(self.dirout,'graph_afc_'+str(self.afcnb)+'.png')):
153 self.fileout = ffr(os.path.join(self.dirout,'graph_afc_'+str(self.afcnb)+'.png'))
154 dial = PrefGraph(self.parent,-1,self.param,'')
155 dial.CenterOnParent()
156 val = dial.ShowModal()
158 self.param = {'typegraph' : dial.choicetype.GetSelection(),
159 'width' : dial.spin1.GetValue(),
160 'height' : dial.spin2.GetValue(),
161 'what' : dial.choice1.GetSelection(),
162 'qui' : dial.choice2.GetSelection(),
163 'do_select_nb' : dial.check1.GetValue(),
164 'do_select_chi' : dial.check2.GetValue(),
165 'do_select_chi_classe' : dial.check_chic.GetValue(),
166 'select_nb' : dial.spin_nb.GetValue(),
167 'select_chi' : dial.spin_chi.GetValue(),
168 'nbchic' : dial.spin_nbchic.GetValue(),
169 'over' : dial.check3.GetValue(),
170 'cex_txt' : dial.check4.GetValue(),
171 'txt_min' : dial.spin_min.GetValue(),
172 'txt_max' : dial.spin_max.GetValue(),
173 'tchi' : dial.check_tchi.GetValue(),
174 'tchi_min' : dial.spin_min_tchi.GetValue(),
175 'tchi_max' : dial.spin_max_tchi.GetValue(),
176 'taillecar' : dial.spin3.GetValue(),
177 'facteur' : [dial.spin_f1.GetValue(),dial.spin_f2.GetValue(), dial.spin_f3.GetValue()],
179 'film' : str(dial.film.GetValue()).upper(),
180 'alpha' : dial.slider_sphere.GetValue()
182 self.nb.parent = self.ira
183 self.DictPathOut = self.Dict
184 self.RscriptsPath = self.ira.RscriptsPath
187 """ % self.DictPathOut['RData']
188 if self.itempath == 'liste_graph_afcf' :
191 afc_table <- afcf_table
192 chistabletot <- specfp
193 infp <- which(is.infinite(chistabletot) & chistabletot > 0)
194 infm <- which(is.infinite(chistabletot) & chistabletot < 0)
195 chistabletot[infp] <- 0
196 chistabletot[infm] <- 0
197 chistabletot[infp] <- max(chistabletot) + 1
198 chistabletot[infm] <- min(chistabletot) - 1
200 elif self.itempath == 'liste_graph_afct' :
203 afc_table <- afct_table
204 chistabletot <- spectp
206 txt += write_afc_graph(self)
207 filetmp = tempfile.mktemp()
208 file = open(filetmp,'w')
211 pid = exec_rcode(self.ira.RPath, filetmp)
212 check_Rresult(self.ira, pid)
213 if self.param['typegraph'] == 0 :
215 if self.param['qui'] == 0 : value = u'actives'
216 if self.param['qui'] == 1 : value = u'supplémentaires'
217 if self.param['qui'] == 2 : value = u'étoilées'
218 if self.param['qui'] == 3 : value = u'classes'
220 if self.param['what'] == 0 : value = u'Coordonnées'
221 if self.param['what'] == 1 : value = u'Corrélations'
222 txt += value + u' - facteur %i / %i' % (self.param['facteur'][0], self.param['facteur'][1])
223 if self.param['do_select_nb'] : txt += u' - sélection de %i variables' % self.param['select_nb']
224 if self.param['do_select_chi'] : txt += u' - sélection des variables avec chi2 > %i ' % self.param['select_chi']
225 if self.param['over'] : txt += u' - Eviter les recouvrements'
226 if self.param['cex_txt'] : txt += u' - taille du texte proportionnel à la masse'
227 if self.param['tchi'] : txt += u' - taille du texte proportionnel au chi2 d\'association'
228 #list_graph = read_list_file(self.DictPathOut[self.itempath], self.coding)
229 self.list_graph.append([self.fileout, txt])
230 print_liste(self.DictPathOut[self.itempath], self.list_graph)
231 self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(self.fileout, wx.BITMAP_TYPE_ANY)))
232 self.sizer_3.Add( self.listimg[-1], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
233 self.labels.append(wx.StaticText(self.panel_1,-1, txt))
234 self.sizer_3.Add(self.labels[-1], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
235 self.buts.append(wx.Button(self.panel_1, wx.ID_DELETE, name = `len(self.list_graph) - 1`))
236 self.sizer_3.Add(self.buts[-1], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
237 self.sizer_3.Fit(self.panel_1)
240 self.panel_1.Scroll(0,self.panel_1.GetScrollRange(wx.VERTICAL))
243 class GraphPanel(wx.ScrolledWindow):
244 def __init__(self, parent, dico, list_graph, txt = '', style = wx.TAB_TRAVERSAL):
245 wx.ScrolledWindow.__init__(self, parent, style = style)
249 self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier"))
252 self.dirout = os.path.dirname(self.Dict['ira'])
253 self.deb = wx.StaticText(self, -1, txt)
254 for i in range(0,len(list_graph)):
255 if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
256 self.listimg.append(wx.StaticBitmap(self, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
257 self.labels.append(wx.StaticText(self, -1, list_graph[i][1]))
259 self.__set_properties()
262 def __set_properties(self):
263 self.SetScrollRate(20, 20)
265 def __do_layout(self):
266 self.sizer_1 = wx.BoxSizer(wx.VERTICAL)
267 self.sizer_2 = wx.BoxSizer(wx.VERTICAL)
268 self.sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
269 self.sizer_1.Add(self.deb)
270 for i in range(0, len(self.listimg)):
271 self.sizer_1.Add(self.listimg[i], 1, wx.ALIGN_CENTER_HORIZONTAL, 0)
272 self.sizer_1.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
273 self.sizer_2.Add(self.sizer_1, 1, wx.EXPAND, 0)
274 self.SetSizer(self.sizer_1)
275 self.sizer_1.Fit(self)
278 def __init__(self, parent, corpus, parametres, Alceste=False):
283 self.parametres = parametres
284 self.pathout = PathOut(parametres['ira'])
285 self.pathout.basefiles(ChdTxtPathOut)
286 DictPathOut = self.pathout
287 self.DictPathOut = DictPathOut
288 self.dictpathout = DictPathOut
291 Profile = DictPathOut['PROFILE_OUT']
292 AntiProfile = DictPathOut['ANTIPRO_OUT']
293 if isinstance(self.corpus, Corpus) :
294 self.encoding = self.corpus.parametres['syscoding']
295 self.corpus.make_ucecl_from_R(self.pathout['uce'])
296 elif 'tableau' in dir(gparent) :
297 self.encoding = gparent.tableau.parametres['syscoding']
299 #AnalyseConf = ConfigParser()
300 #AnalyseConf.readfp(codecs.open(filename,'r', self.encoding))
301 #AnalyseConf.read(filename)
302 #if 'analyse' in AnalyseConf.sections() :
303 # section = 'analyse'
304 #elif 'questionnaire' in AnalyseConf.sections() :
305 # section = 'questionnaire'
306 #elif 'chd_dist_quest' in AnalyseConf.sections() :
307 # section = 'chd_dist_quest'
308 #self.section = section
309 #clnb = AnalyseConf.get(section, 'clusternb')
311 clnb = parametres['clnb']
312 dlg = progressbar(self, maxi = 4 + clnb)
314 corpname = self.corpus.parametres['corpus_name']
315 print 'lecture des profils'
316 dlg.Update(2, u'lecture des profils')
318 DictProfile = ReadProfileAsDico(self, Profile, Alceste, self.encoding)
319 self.DictProfile = DictProfile
320 #print 'lecture des antiprofils'
321 #DictAnti = ReadProfileAsDico(self, AntiProfile, Alceste, self.encoding)
323 panel = wx.Panel(parent, -1)
324 sizer1 = wx.BoxSizer(wx.VERTICAL)
326 panel.chd_toolbar = wx.ToolBar(panel, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER)
327 panel.chd_toolbar.SetToolBitmapSize(wx.Size(16, 16))
329 if isinstance(self.corpus, Corpus) :
330 panel.corpus = self.corpus
331 self.ID_sg = wx.NewId()
332 butsg = wx.Button(panel.chd_toolbar, self.ID_sg, u"Profils des segments répétés ")
333 panel.chd_toolbar.AddControl(butsg)
334 panel.chd_toolbar.AddSeparator()
335 self.ID_export = wx.NewId()
336 butexp = wx.Button(panel.chd_toolbar, self.ID_export, u"Exporter le corpus ")
337 panel.chd_toolbar.AddControl(butexp)
338 panel.chd_toolbar.AddSeparator()
339 self.ID_colored = wx.NewId()
340 butcol = wx.Button(panel.chd_toolbar, self.ID_colored, u"Corpus en couleur ")
341 panel.chd_toolbar.AddControl(butcol)
342 panel.chd_toolbar.AddSeparator()
343 self.ID_searchf = wx.NewId()
344 butsearchf = wx.Button(panel.chd_toolbar, self.ID_searchf, u"Outil de navigation ")
345 panel.chd_toolbar.AddControl(butsearchf)
346 panel.chd_toolbar.AddSeparator()
348 self.ID_proftype =wx.NewId()
349 butpt = wx.Button(panel.chd_toolbar, self.ID_proftype, u"Profils des types ")
350 panel.chd_toolbar.AddControl(butpt)
351 panel.chd_toolbar.AddSeparator()
353 self.ID_clusterstat =wx.NewId()
354 butclusterstat = wx.Button(panel.chd_toolbar, self.ID_clusterstat, u"Stat par classe ")
355 panel.chd_toolbar.AddControl(butclusterstat)
356 panel.chd_toolbar.AddSeparator()
359 self.ID_rapport = wx.NewId()
360 #rap_img = wx.Image(os.path.join(self.parent.images_path,'icone_rap_16.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
361 #panel.chd_toolbar.AddLabelTool(self.ID_rapport, "rapport", rap_img, shortHelp=u"Produire le rapport", longHelp=u"Exporter un rapport en texte simple")
362 butrap = wx.Button(panel.chd_toolbar, self.ID_rapport, u"Rapport ")
363 panel.chd_toolbar.AddControl(butrap)
365 panel.chd_toolbar.Realize()
366 sizer1.Add(panel.chd_toolbar,0, wx.EXPAND, 5)
368 #self.TabChdSim = wx.aui.AuiNotebook(self.parent.nb, -1, wx.DefaultPosition)
369 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
370 panel.TabChdSim = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
371 panel.TabChdSim.SetAGWWindowStyleFlag(notebook_flags)
372 panel.TabChdSim.SetArtProvider(aui.ChromeTabArt())
373 sizer1.Add(panel.TabChdSim,10, wx.EXPAND, 5)
374 panel.SetSizer(sizer1)
378 if isinstance(self.corpus, Corpus) :
379 panel.TabChdSim.corpus = corpus
380 panel.TabChdSim.corpus.dictpathout = self.DictPathOut
381 panel.parametres = self.parametres
383 self.notenb = self.parent.nb.GetPageCount()
384 if os.path.exists(DictPathOut['pre_rapport']):
385 #self.tabRap = wx.TextCtrl(self.TabChdSim, -1, "", style=wx.TE_MULTILINE | wx.TE_RICH2)
386 #self.tabRap.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier"))
387 with codecs.open(DictPathOut['pre_rapport'], 'r', self.encoding) as f :
389 #self.tabRap.write(txt)
390 #self.tabRap.ShowPosition(0)
395 if os.path.exists(self.DictPathOut['liste_graph_chd']) :
396 list_graph = read_list_file(self.DictPathOut['liste_graph_chd'], self.encoding)
397 CHD = GraphPanelDendro(panel.TabChdSim, DictPathOut, list_graph, txt = self.debtext)
398 panel.TabChdSim.AddPage(CHD,'CHD')
400 panel.ProfNB = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
401 panel.ProfNB.SetArtProvider(aui.ChromeTabArt())
402 #self.ProfNB.SetTabCtrlHeight(100)
403 #panel.AntiProfNB = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
404 if os.path.exists(DictPathOut['prof_seg']) :
405 prof_seg = ReadProfileAsDico(self, DictPathOut['prof_seg'], False, self.encoding)
406 self.prof_seg_nb = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
407 for i in range(0, clnb):
408 dlg.Update(3+i, 'Classe %i' %(i+1))
409 ind = '/'.join(DictProfile[str(i + 1)][0][0:2])
410 indpour = ' - '.join([ind, DictProfile[str(i + 1)][0][2]])
411 self.tabprofile = ProfListctrlPanel(self.parent, self, DictProfile[str(i + 1)], Alceste, i + 1)
412 #self.tabantiprofile = ProfListctrlPanel(self.parent, self, DictAnti[str(i + 1)], Alceste, i + 1)
413 panel.ProfNB.AddPage(self.tabprofile, 'classe %s %s(%s%%)' % (str(i + 1), sep, indpour))
414 #panel.AntiProfNB.AddPage(self.tabantiprofile, 'classe %s' % str(i + 1))
415 if os.path.exists(DictPathOut['prof_seg']) :
416 self.tab_prof_seg = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
417 self.prof_seg_nb.AddPage(self.tab_prof_seg, 'classe %i' % (i + 1))
420 self.TabAFC = aui.AuiNotebook(panel.TabChdSim, -1, wx.DefaultPosition)
422 list_graph=read_list_file(DictPathOut['liste_graph_afc'], self.encoding)
423 self.tabAFCGraph = GraphPanelAfc(self.TabAFC, DictPathOut, list_graph, self.clnb, coding=self.encoding)
424 self.TabAFC.AddPage(self.tabAFCGraph, 'AFC')
426 if os.path.exists(self.DictPathOut['afc_facteur']) :
427 dictrow, first = ReadList(self.DictPathOut['afc_facteur'], self.encoding)
428 self.TabAFC_facteur = ListForSpec(self.parent, parametres, dictrow, first)
429 #dictrow, first = ReadList(self.DictPathOut['afc_row'], self.encoding)
430 #self.TabAFC_ligne = ListForSpec(self.parent, self.parametres, dictrow, first)
431 #dictrow, first = ReadList(self.DictPathOut['afc_col'], self.encoding)
432 #self.TabAFC_colonne = ListForSpec(parent, self.parametres, dictrow, first)
433 self.TabAFC.AddPage(self.TabAFC_facteur, 'Facteurs')
434 #self.TabAFC.AddPage(self.TabAFC_colonne, u'Colonnes')
435 #self.TabAFC.AddPage(self.TabAFC_ligne, u'Lignes')
437 sizer_3 = wx.BoxSizer(wx.VERTICAL)
438 self.parent.nb_panel_2 = wx.Panel(panel.TabChdSim, -1)
439 self.parent.button_simi = wx.Button(self.parent.nb_panel_2, -1, "Voyager")
440 self.parent.simi3dpanel = simi3d(self.parent.nb_panel_2, -1)
441 sizer_3.Add(self.parent.simi3dpanel, 1, wx.EXPAND, 0)
442 sizer_3.Add(self.parent.button_simi, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
443 self.parent.nb_panel_2.SetSizer(sizer_3)
444 self.TabAFC.AddPage(self.parent.nb_panel_2, "graph 3D")
445 self.parent.Bind(wx.EVT_BUTTON, self.onsimi, self.parent.button_simi)
447 panel.TabChdSim.AddPage(panel.ProfNB, 'Profils')
448 #panel.TabChdSim.AddPage(panel.AntiProfNB, 'Antiprofils')
449 dlg.Update(4 + self.clnb, 'Affichage...')
451 panel.TabChdSim.AddPage(self.TabAFC, 'AFC')
452 if os.path.exists(DictPathOut['prof_seg']) :
453 panel.TabChdSim.AddPage(self.prof_seg_nb, u'Profils des segments répétés')
455 if isinstance(self.corpus, Corpus) :
456 panel.Bind(wx.EVT_BUTTON, self.on_export_classes, id = self.ID_export)
457 panel.Bind(wx.EVT_BUTTON, self.onprofseg, id = self.ID_sg)
458 panel.Bind(wx.EVT_BUTTON, self.oncolored, id = self.ID_colored)
459 panel.Bind(wx.EVT_BUTTON, self.onsearchf, id = self.ID_searchf)
460 panel.Bind(wx.EVT_BUTTON, self.onproftype, id = self.ID_proftype)
461 panel.Bind(wx.EVT_BUTTON, self.onclusterstat, id = self.ID_clusterstat)
463 panel.Bind(wx.EVT_BUTTON, self.ongetrapport, id = self.ID_rapport)
464 self.parent.nb.AddPage(panel, 'Classification - %s' % corpname)
465 self.parent.ShowTab(True)
466 self.parent.nb.SetSelection(self.parent.nb.GetPageCount() - 1)
467 #for pane in self.parent._mgr.GetAllPanes() :
468 # if isinstance(pane.window, aui.AuiNotebook):
470 # nb.SetAGWWindowStyleFlag(notebook_flags)
471 # nb.SetArtProvider(aui.ChromeTabArt())
473 self.parent._mgr.Update()
475 def onsimi(self,event):
476 outfile = print_simi3d(self)
477 error = exec_rcode(self.parent.RPath, outfile, wait = True)
479 def ongetrapport(self, event) :
480 dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.txt', 'title': 'Rapport'})
481 dial.fbb.SetValue(self.DictPathOut['rapport'])
482 dial.CenterOnParent()
483 res = dial.ShowModal()
485 fileout = dial.fbb.GetValue()
487 with open(fileout, 'w') as f :
488 f.write(self.debtext + '\n' + GetTxtProfile(self.DictProfile))
490 dlg = wx.MessageDialog(self.parent, msg, u"Rapport", wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION)
497 def on_export_classes(self, event) :
498 corpus = self.parent.nb.GetPage(self.parent.nb.GetSelection()).corpus
499 dial = PrefExport(self, self.parent)
500 dial.fbb.SetValue(os.path.join(os.path.dirname(corpus.dictpathout['ira']), 'export_corpus.txt'))
501 dial.CenterOnParent()
502 res = dial.ShowModal()
504 if dial.radio_type.GetSelection() == 0 : alc = True
506 if dial.radio_lem.GetSelection() == 0 : lem = True
508 self.corpus.export_corpus_classes(dial.fbb.GetValue(), alc = alc, lem = lem)
511 dlg = wx.MessageDialog(self.parent, msg, u"Export", wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION)
516 def onprofseg(self, event):
518 print 'plus de bug profseg'
519 print self.parametres
520 corpus = self.parent.nb.GetPage(self.parent.nb.GetSelection()).corpus
521 ProfileSegment(self.parent, self.dictpathout, self.parametres, corpus)
523 # BugReport(self.parent)
525 def onproftype(self, event):
527 corpus = self.parent.nb.GetPage(self.parent.nb.GetSelection()).corpus
528 ProfilType(self.parent, corpus)
530 BugReport(self.parent)
532 def oncolored(self,evt) :
533 dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.html', 'title': 'Corpus en couleur'})
534 dial.fbb.SetValue(os.path.join(os.path.dirname(self.corpus.dictpathout['ira']), 'corpus_couleur.html'))
535 dial.CenterOnParent()
536 res = dial.ShowModal()
538 fileout = dial.fbb.GetValue()
540 txt = self.corpus.make_colored_corpus()
541 with open(fileout, 'w') as f :
543 msg = u"Fini !\nVoulez-vous ouvrir le corpus dans votre navigateur ?"
544 dlg = wx.MessageDialog(self.parent, msg, u"Corpus en couleur", wx.NO | wx.YES | wx.NO_DEFAULT | wx.ICON_QUESTION)
546 if dlg.ShowModal() == wx.ID_YES :
547 webbrowser.open(fileout)
550 def onclusterstat(self, evt) :
551 dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.csv', 'title': 'Stat par classe'})
552 dial.fbb.SetValue( os.path.join(os.path.dirname(self.corpus.dictpathout['ira']), 'stat_par_classe.csv'))
553 dial.CenterOnParent()
554 res = dial.ShowModal()
556 fileout = dial.fbb.GetValue()
559 self.corpus.get_stat_by_cluster(fileout)
561 dlg = wx.MessageDialog(self.parent, msg, u"Stat par classe", wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION)
563 if dlg.ShowModal() == wx.ID_OK :
566 def onsearchf(self, evt) :
567 if 'FrameSearch' not in dir(self.parent) :
568 self.parent.FrameSearch = SearchFrame(self.parent, -1, u"Rechercher...", self.corpus)
569 self.parent.FrameSearch.Show()
573 def PrintRapport(self, corpus, parametres, txt = True):
574 #if sys.platform == 'win32':
580 |i|R|a|M|u|T|e|Q| - %s
584 """ % datetime.datetime.now().ctime()
585 totocc = corpus.gettotocc()
587 txt += u'nombre d\'uci: %i%s' % (corpus.getucinb(), sep)
588 txt += u'nombre d\'uce: %i%s' % (corpus.getucenb(), sep)
589 txt += u'nombre de formes: %i%s' % (len(corpus.formes), sep)
590 txt += u'nombre d\'occurrences: %i%s' % (totocc, sep)
591 txt += u'moyenne d\'occurrences par forme: %f%s' % (float(totocc) / float(len(self.corpus.formes)), sep)
592 txt += u'nombre de lemmes: %i%s' % (len(corpus.lems), sep)
593 txt += u'nombre de formes actives: %i%s' % (corpus.getactivesnb(1), sep)
594 txt += u'nombre de formes supplémentaires: %i%s' % (corpus.getactivesnb(2), sep)
595 txt += u'nombre de formes actives de fréquence >= %i: %i%s' % (parametres['eff_min_forme'], parametres['nbactives'], sep)
596 txt += u'moyenne d\'occurrences par uce :%f%s' % (float(totocc) / float(corpus.getucenb()), sep)
597 if 'tailleuc1' in parametres :
598 if parametres['classif_mode'] != 0 :
599 txt += u'taille uc1 : %i\n' % parametres['tailleuc1']
601 txt += u'taille uc1 / uc2: %i / %i - %i / %i%s' % (parametres['tailleuc1'], parametres['tailleuc2'], parametres['lenuc1'], parametres['lenuc2'], sep)
603 self.Ucenb = self.nbind
604 txt += u'nombre d\'individus : %i%s' % (self.nbind, sep)
605 txt += u'nombre de classes : %i%s' % (self.clnb, sep)
607 txt += u'nombre de classes : %i%s' % (parametres['clnb'], sep)
608 if parametres['classif_mode'] == 0 or parametres['classif_mode'] == 1 :
609 txt += u'%i uce classées sur %i (%.2f%%)%s' % (sum([len(cl) for cl in corpus.lc]), corpus.getucenb(), (float(sum([len(cl) for cl in corpus.lc])) / float(corpus.getucenb())) * 100, sep)
610 elif self.parametres['classif_mode'] == 2 :
611 txt += u'%i uci classées sur %i (%.2f%%)%s' % (sum([len(cl) for cl in corpus.lc]), corpus.getucinb(), (float(sum([len(cl) for cl in corpus.lc]))) / float(corpus.getucinb()) * 100, sep)
612 elif analyse == 'quest' :
613 txt += u'%i uce classées sur %i (%.2f%%)%s' % (self.ucecla, self.Ucenb, (float(self.ucecla) / float(self.Ucenb)) * 100, sep)
616 ###########################
618 ###########################
619 """ % parametres['time']
620 file = open(self.pathout['pre_rapport'], 'w')
625 def __init__(self, ira, corpus, parametres):
626 self.pathout = PathOut(dirout = parametres['pathout'])
628 self.dictpathout = StatTxtPathOut(parametres['pathout'])
629 #self.corpus.read_corpus_from_shelves(self.corpus.dictpathout['db'])
631 self.encoding = self.corpus.parametres['syscoding']
632 self.parametres = parametres
634 self.DictSpec, first = ReadList(self.dictpathout['tablespecf'], self.corpus.parametres['syscoding'])
635 self.DictType, firstt = ReadList(self.dictpathout['tablespect'], self.corpus.parametres['syscoding'])
636 self.DictEff, firsteff = ReadList(self.dictpathout['tableafcm'], self.corpus.parametres['syscoding'])
637 self.DictEffType, firstefft = ReadList(self.dictpathout['tabletypem'], self.corpus.parametres['syscoding'])
638 self.DictEffRelForme, firsteffrelf = ReadList(self.dictpathout['eff_relatif_forme'], self.corpus.parametres['syscoding'])
639 self.DictEffRelType, firsteffrelt = ReadList(self.dictpathout['eff_relatif_type'], self.corpus.parametres['syscoding'])
641 self.TabStat = aui.AuiNotebook(ira.nb, -1, wx.DefaultPosition)
642 self.TabStat.parametres = parametres
643 self.ListPan = ListForSpec(ira, self.parent, self.DictSpec, first)
644 self.ListPant = ListForSpec(ira, self.parent, self.DictType, firstt)
645 self.ListPanEff = ListForSpec(ira, self.parent, self.DictEff, firsteff)
646 self.ListPanEffType = ListForSpec(ira, self.parent, self.DictEffType, firstefft)
647 self.ListPanEffRelForme = ListForSpec(ira, self.parent, self.DictEffRelForme, firsteffrelf)
648 self.ListPanEffRelType = ListForSpec(ira, self.parent, self.DictEffRelType, firsteffrelt)
650 self.TabStat.AddPage(self.ListPan, u'formes')
651 self.TabStat.AddPage(self.ListPant, u'Types')
652 self.TabStat.AddPage(self.ListPanEff, u'Effectifs formes')
653 self.TabStat.AddPage(self.ListPanEffType, u'Effectifs Type')
654 self.TabStat.AddPage(self.ListPanEffRelForme, u'Effectifs relatifs formes')
655 self.TabStat.AddPage(self.ListPanEffRelType, u'Effectifs relatifs Type')
656 if self.parametres['clnb'] > 2 :
657 self.TabAFC = aui.AuiNotebook(self.TabStat, -1, wx.DefaultPosition)
658 list_graph=read_list_file(self.dictpathout['liste_graph_afcf'], encoding = self.encoding)
659 self.tabAFCGraph = GraphPanelAfc(self.TabAFC, self.dictpathout, list_graph, self.parametres['clnb'], itempath ='liste_graph_afcf', coding = self.encoding)
660 self.TabAFC.AddPage(self.tabAFCGraph, 'AFC formes')
661 list_graph=read_list_file(self.dictpathout['liste_graph_afct'], encoding = self.encoding)
662 self.tabAFCTGraph = GraphPanelAfc(self.TabAFC, self.dictpathout, list_graph, self.parametres['clnb'], itempath ='liste_graph_afct', coding=self.encoding)
663 self.TabAFC.AddPage(self.tabAFCTGraph, 'AFC type')
664 self.TabStat.AddPage(self.TabAFC, 'AFC')
667 ira.nb.AddPage(self.TabStat, u'Spécificités')
669 self.TabStat.corpus = self.corpus
670 ira.nb.SetSelection(self.parent.nb.GetPageCount() - 1)
671 ira.ShowAPane("Tab_content")
674 def __init__(self, ira, corpus, parametres):
675 self.pathout = PathOut(dirout = parametres['pathout'])
679 self.TabStat = aui.AuiNotebook(ira.nb, -1, wx.DefaultPosition)
680 self.TabStat.parametres = parametres
681 # CHD = GraphPanel(panel.TabChdSim, DictPathOut, list_graph, txt = self.debtext)
682 # panel.TabChdSim.AddPage(CHD,'CHD')
684 #self.TabStatTot = wx.TextCtrl(self.TabStat, -1, style=wx.NO_BORDER | wx.TE_MULTILINE | wx.TE_RICH2)
685 list_graph = [['zipf.png', 'zipf']]
686 self.TabStatTot = GraphPanel(ira.nb, self.pathout, list_graph, self.result['glob'])
687 #self.TabStatTot.write(self.result['glob'])
688 self.TabStat.AddPage(self.TabStatTot, 'global')
689 for item in self.result:
691 datam = [['forme', 'nb']]
692 self.ListPan = ListPanel(ira, self, self.result[item])
693 self.TabStat.AddPage(self.ListPan, item)
694 ira.nb.AddPage(self.TabStat, 'Stat')
695 ira.nb.SetSelection(ira.nb.GetPageCount() - 1)
696 ira.ShowAPane("Tab_content")
698 def read_result(self) :
699 lcle = {'total' :u'total.csv', u'formes_actives':u'formes_actives.csv', u'formes_supplémentaires':u'formes_supplémentaires.csv', u'hapax': u'hapax.csv'}
702 with open(self.pathout[lcle[key]], 'r') as f :
703 self.result[key] = [line.split(';') for line in f.read().splitlines()]
704 self.result[key] = dict([[i,[line[0],int(line[1]), line[2]]] for i, line in enumerate(self.result[key])])
705 with open(self.pathout['glob.txt'], 'r') as f :
706 self.result['glob'] = f.read()
708 class GraphPanelDendro(wx.Panel):
709 def __init__(self,parent, dico, list_graph, txt=False):
710 wx.Panel.__init__(self,parent)
712 self.dictpathout = dico
713 self.dirout = os.path.dirname(self.dictpathout['ira'])
714 self.list_graph = list_graph
715 self.parent = self.GetParent()#parent
716 self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier"))
719 self.tabchd = self.parent.GetParent()
720 self.ira = self.tabchd.GetParent()
721 self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
722 self.deb = wx.StaticText(self.panel_1, -1, txt)
723 dendro_img = wx.Image(os.path.join(self.ira.images_path,'but_dendro.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
724 self.butdendro = wx.BitmapButton(self, -1, dendro_img)
726 for i in range(0,len(list_graph)):
727 if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
728 self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
729 self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1]))
731 self.__set_properties()
734 def __set_properties(self):
735 self.panel_1.EnableScrolling(True,True)
736 #self.panel_1.SetSize((1000,1000))
737 self.panel_1.SetScrollRate(20, 20)
738 self.Bind(wx.EVT_BUTTON, self.ondendro, self.butdendro)
739 self.param = {'width' : 700,
743 'taille_classe' : True,
746 self.type_dendro = [ u"phylogram", u"cladogram", u"fan", u"unrooted", u"radial" ]
748 def __do_layout(self):
749 self.sizer_1 = wx.BoxSizer(wx.VERTICAL)
750 self.sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
751 self.sizer_3 = wx.BoxSizer(wx.VERTICAL)
752 self.sizer_3.Add(self.deb)
753 self.sizer_2.Add(self.butdendro, 0, 0, 0)
754 for i in range(0, len(self.listimg)):
755 self.sizer_3.Add(self.listimg[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
756 self.sizer_3.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
757 self.panel_1.SetSizer(self.sizer_3)
758 self.sizer_2.Add(self.panel_1, 1, wx.EXPAND, 0)
759 self.SetSizer(self.sizer_2)
761 def make_param(self, dial):
762 self.param['width'] = dial.m_spinCtrl2.GetValue()
763 self.param['height'] = dial.m_spinCtrl1.GetValue()
764 self.param['type_dendro'] = dial.m_choice1.GetSelection()
765 self.param['color_nb'] = dial.m_radioBox1.GetSelection()
766 self.param['taille_classe'] = dial.m_checkBox1.GetValue()
767 self.param['type_tclasse'] = dial.m_radioBox2.GetSelection()
769 def make_dendro(self) :
770 while os.path.exists(os.path.join(self.dirout, 'dendrogamme_' + str(self.graphnb)+'.png')) :
772 fileout = ffr(os.path.join(self.dirout,'dendrogamme_' + str(self.graphnb)+'.png'))
773 width = self.param['width']
774 height = self.param['height']
775 type_dendro = self.type_dendro[self.param['type_dendro']]
776 if self.param['taille_classe'] :
780 if self.param['color_nb'] == 0 :
784 if self.param['type_tclasse'] == 0 :
788 dendro_path = self.dictpathout['Rdendro']
789 classe_path = self.dictpathout['uce']
794 classes <- read.csv2("%s", row.names=1)
795 classes <- classes[,1]
796 open_file_graph("%s", width=%i, height=%i)
797 plot.dendropr(tree.cut1$tree.cl, classes, type.dendro="%s", histo=%s, bw=%s, lab=NULL, tclasse=%s)
798 """ % (ffr(dendro_path), ffr(self.ira.RscriptsPath['Rgraph']), ffr(classe_path), ffr(fileout), width, height, type_dendro, histo, bw, tclasse)
800 tmpfile = tempfile.mktemp()
801 with open(tmpfile, 'w') as f :
803 error = exec_rcode(self.ira.RPath, tmpfile, wait=True)
804 check_Rresult(self.ira, error)
805 self.list_graph.append([fileout, 'Dendrogramme CHD1 - %s' % type_dendro])
806 print_liste(self.dictpathout['liste_graph_chd'], self.list_graph)
807 self.sizer_3.Add(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(fileout, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
808 self.sizer_3.Add(wx.StaticText(self.panel_1,-1, 'Dendrogramme CHD1 - %s' % type_dendro), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
809 self.sizer_3.Fit(self.panel_1)
811 self.panel_1.Scroll(0,self.panel_1.GetScrollRange(wx.VERTICAL))
814 def ondendro(self, evt):
815 dial = PrefDendro(self.ira, self.param)
816 val = dial.ShowModal()
818 self.make_param(dial)
824 def __init__(self, ira, parametres) :
825 #self.text = wx.TextCtrl(ira, -1, "", wx.Point(0, 0), wx.Size(200, 200), wx.NO_BORDER | wx.TE_MULTILINE | wx.TE_RICH2 | wx.TE_READONLY)
826 self.panel = CopusPanel(ira, parametres)
827 ira.nb.AddPage(self.panel, 'Description %s' % parametres['corpus_name'])
828 #self.text.write(DoConf().totext(parametres))
829 ira.nb.SetSelection(ira.nb.GetPageCount() - 1)
830 ira.ShowAPane("Tab_content")
832 class CopusPanel(wx.Panel) :
833 def __init__(self, parent, parametres) :
834 wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.TAB_TRAVERSAL )
835 self.parametres = parametres
836 fgSizer5 = wx.FlexGridSizer( 0, 2, 0, 0 )
837 fgSizer5.SetFlexibleDirection( wx.BOTH )
838 fgSizer5.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
839 self.fgSizer5 = fgSizer5
841 self.m_staticText18 = wx.StaticText( self, wx.ID_ANY, u"Description du corpus", wx.DefaultPosition, wx.DefaultSize, 0 )
843 self.m_staticText18.Wrap( -1 )
844 fgSizer5.Add( self.m_staticText18, 0, wx.ALL, 5 )
846 self.m_staticText19 = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
847 self.m_staticText19.Wrap( -1 )
848 fgSizer5.Add( self.m_staticText19, 0, wx.ALL, 5 )
850 self.m_staticText20 = wx.StaticText( self, wx.ID_ANY, u"Nom", wx.DefaultPosition, wx.DefaultSize, 0 )
851 self.m_staticText20.Wrap( -1 )
852 fgSizer5.Add( self.m_staticText20, 0, wx.ALL, 5 )
854 self.m_staticText21 = wx.StaticText( self, wx.ID_ANY, parametres['corpus_name'], wx.DefaultPosition, wx.DefaultSize, 0 )
855 self.m_staticText21.Wrap( -1 )
856 fgSizer5.Add( self.m_staticText21, 0, wx.ALL, 5 )
858 description = {'lang' : u'langue',
859 'encoding' : u'encodage'}
861 keys = ['lang', 'encoding', 'originalpath', 'pathout', 'date', 'time']
863 self.addkeys(keys, description)
865 self.m_staticText18 = wx.StaticText( self, wx.ID_ANY, u"Paramètres", wx.DefaultPosition, wx.DefaultSize, 0 )
866 self.m_staticText18.Wrap( -1 )
867 fgSizer5.Add( self.m_staticText18, 0, wx.ALL, 5 )
869 self.m_staticText19 = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
870 self.m_staticText19.Wrap( -1 )
871 fgSizer5.Add( self.m_staticText19, 0, wx.ALL, 5 )
873 keys = ['ucemethod', 'ucesize', 'keep_caract', 'expressions']
874 self.addkeys(keys, description)
876 self.m_staticText18 = wx.StaticText( self, wx.ID_ANY, u"Statistiques", wx.DefaultPosition, wx.DefaultSize, 0 )
877 self.m_staticText18.Wrap( -1 )
878 fgSizer5.Add( self.m_staticText18, 0, wx.ALL, 5 )
880 self.m_staticText19 = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
881 self.m_staticText19.Wrap( -1 )
882 fgSizer5.Add( self.m_staticText19, 0, wx.ALL, 5 )
884 keys = ['ucinb', 'ucenb', 'occurrences', 'formesnb', 'hapax']
885 self.addkeys(keys, description)
887 self.SetSizer( fgSizer5 )
890 def addkeys(self, keys, description) :
892 option = self.parametres.get(key,u'non défnini')
893 if isinstance(option, int) :
895 text = wx.StaticText( self, wx.ID_ANY, description.get(key, key), wx.DefaultPosition, wx.DefaultSize, 0 )
897 self.fgSizer5.Add( text, 0, wx.ALL, 5 )
899 text = wx.StaticText( self, wx.ID_ANY, option, wx.DefaultPosition, wx.DefaultSize, 0 )
901 self.fgSizer5.Add( text, 0, wx.ALL, 5 )
903 class GraphPanelSimi(wx.Panel):
904 def __init__(self, parent, dico, list_graph):
905 wx.Panel.__init__(self,parent)
908 self.dirout = os.path.dirname(self.Dict['ira'])
909 self.parent = self.GetParent()#parent
910 self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier"))
913 self.tabsimi = self.parent.GetParent()
914 self.ira = self.tabsimi.GetParent()
915 self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
916 afc_img = wx.Image(os.path.join(self.ira.images_path,'button_simi.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
917 self.butafc = wx.BitmapButton(self, -1, afc_img)
918 export_img = wx.Image(os.path.join(self.ira.images_path,'button_export.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
919 self.butexport = wx.BitmapButton(self, -1, export_img)
921 for i in range(0,len(list_graph)):
922 if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) and list_graph[i][0] != '' :
923 self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
924 self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1]))
926 self.__set_properties()
929 def __set_properties(self):
930 self.panel_1.EnableScrolling(True,True)
931 #self.panel_1.SetSize((1000,1000))
932 self.panel_1.SetScrollRate(20, 20)
934 def __do_layout(self):
935 self.sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
936 self.sizer_2 = wx.BoxSizer(wx.VERTICAL)
937 self.sizer_3 = wx.BoxSizer(wx.VERTICAL)
938 self.sizer_2.Add(self.butafc, 0, 0, 0)
939 self.sizer_2.Add(self.butexport, 0, 0, 0)
940 for i in range(0, len(self.listimg)):
941 self.sizer_3.Add(self.listimg[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
942 self.sizer_3.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
943 self.panel_1.SetSizer(self.sizer_3)
944 self.sizer_1.Add(self.sizer_2, 0, wx.EXPAND, 0)
945 self.sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
946 self.SetSizer(self.sizer_1)
948 class DefaultTextLayout :
949 def __init__(self, ira, corpus, parametres) :
950 self.pathout = PathOut(dirout = parametres['pathout'])
953 self.parametres = parametres
958 log.info('no layout yet')
960 class WordCloudLayout(DefaultTextLayout):
962 #self.dictpathout = parent.corpus.dictpathout
963 #self.pathout = os.path.dirname(filename)
964 #self.corpus = parent.corpus
966 self.pathout.basefiles(simipath)
967 self.Tab = aui.AuiNotebook(self.ira.nb, -1, wx.DefaultPosition)
968 # if os.path.exists(self.pathout['liste_graph']) :
969 # list_graph = read_list_file(self.pathout['liste_graph'])
971 # list_graph = [['','']]
972 list_graph = [['nuage_1.png', 'Nuage']]
973 self.TabStatTot = GraphPanel(self.ira.nb, self.pathout, list_graph)
974 #self.TabStatTot.write(self.result['glob'])
975 self.Tab.AddPage(self.TabStatTot, 'Nuage')
976 self.Tab.corpus = self.corpus
977 self.Tab.parametres = self.parametres
978 self.ira.nb.AddPage(self.Tab, 'WordCloud %s' % self.parametres.get('corpus_name','corpus_name'))
979 self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
980 self.ira.ShowAPane("Tab_content")
982 class SimiLayout(DefaultTextLayout) :
984 self.pathout.basefiles(simipath)
986 self.indices = indices_simi
987 if os.path.exists(self.pathout['liste_graph']) :
988 list_graph = read_list_file(self.pathout['liste_graph'])
990 list_graph = [['','']]
991 notebook_flags = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_FLOAT
992 self.tabsimi = aui.AuiNotebook(self.ira.nb, -1, wx.DefaultPosition)
993 self.tabsimi.SetAGWWindowStyleFlag(notebook_flags)
994 self.tabsimi.SetArtProvider(aui.ChromeTabArt())
995 self.tabsimi.corpus = self.corpus
996 self.tabsimi.parametres = self.parametres
997 self.graphpan = GraphPanelSimi(self.tabsimi, self.pathout, list_graph)
998 self.graphpan.Bind(wx.EVT_BUTTON, self.redosimi, self.graphpan.butafc)
999 self.graphpan.Bind(wx.EVT_BUTTON, self.export, self.graphpan.butexport)
1000 self.tabsimi.AddPage(self.graphpan, 'Graph')
1001 self.ira.nb.AddPage(self.tabsimi, 'Analyse de graph')
1002 self.ira.ShowTab(True)
1003 self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
1005 def redosimi(self, evt) :
1006 with open(self.pathout['selected.csv'],'r') as f :
1008 selected = [int(val) for val in selected.splitlines()]
1009 if self.actives is None :
1010 with codecs.open(self.pathout['actives.csv'], 'r', self.parametres['encoding']) as f :
1011 self.actives = f.read()
1012 self.actives = self.actives.splitlines()#[act for act in self.actives.splitlines()]
1013 dictcol = dict([[i, [act, self.corpus.getlemeff(act)]] for i, act in enumerate(self.actives)])
1014 #res = SelectColumn(self.ira, dictcol, self.actives, self.pathout['selected.csv'], selected = selected, dlg = True)
1016 prep = PrepSimi(self.ira, self, self.parametres,self.pathout['selected.csv'], self.actives, indices_simi, wordlist = dictcol, selected = selected)
1017 if prep.val == wx.ID_OK :
1018 self.parametres = prep.parametres
1020 script = PrintSimiScript(self)
1021 script.make_script()
1022 pid = exec_rcode(self.ira.RPath, script.scriptout, wait = True)
1023 check_Rresult(self.ira, pid)
1024 if self.parametres['type_graph'] == 1:
1025 if os.path.exists(self.pathout['liste_graph']):
1026 graph_simi = read_list_file(self.pathout['liste_graph'])
1027 graph_simi.append([os.path.basename(script.filename), script.txtgraph])
1029 graph_simi = [[os.path.basename(script.filename), script.txtgraph]]
1030 print_liste(self.pathout['liste_graph'], graph_simi)
1031 DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira'])
1032 if self.parametres['type_graph'] == 1:
1033 self.graphpan.sizer_3.Add(wx.StaticBitmap(self.graphpan.panel_1, -1, wx.Bitmap(script.filename, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1034 self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1, script.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1035 self.graphpan.sizer_3.Fit(self.graphpan.panel_1)
1036 self.graphpan.Layout()
1037 self.graphpan.panel_1.Scroll(0,self.graphpan.panel_1.GetScrollRange(wx.VERTICAL))
1039 def export(self, evt) :
1041 # def read_result(self) :
1042 # #self.corpus.read_corpus_from_shelves(self.corpus.dictpathout['db'])
1043 # #self.corpus.make_et_table()
1045 # with open(os.path.join(self.pathout,'glob.txt'), 'r') as f :
1046 # self.result['glob'] = f.read()