2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2008-2009 Pierre Ratinaud
9 import wx.lib.hyperlink as hl
10 import wx.lib.agw.aui as aui
11 import wx.lib.agw.labelbook as LB
12 from wx.lib.agw.fmresources import *
13 from chemins import ConstructPathOut, ChdTxtPathOut, FFF, ffr, PathOut, StatTxtPathOut, simipath
14 from ConfigParser import ConfigParser
15 from functions import ReadProfileAsDico, GetTxtProfile, read_list_file, ReadList, exec_rcode, print_liste, BugReport, DoConf, indices_simi, check_Rresult, progressbar, normpath_win32
16 from ProfList import ProfListctrlPanel
17 from guiparam3d import param3d, simi3d
18 from PrintRScript import write_afc_graph, print_simi3d, PrintSimiScript
19 from profile_segment import ProfileSegment
20 from functions import ReadList
23 from search_tools import SearchFrame
24 from dialog import PrefGraph, PrefExport, PrefSimpleFile, PrefDendro, SimpleDialog
25 from guifunct import SelectColumn, PrepSimi, PrefSimi
26 from webexport import WebExport
27 from corpus import Corpus
28 from sheet import MySheet
32 from time import sleep
37 log = logging.getLogger('iramuteq.layout')
40 class GraphPanelAfc(wx.Panel):
41 def __init__(self, parent, dico, list_graph, clnb, itempath = 'liste_graph_afc', coding = sys.getdefaultencoding()):
42 wx.Panel.__init__(self,parent)
47 self.itempath = itempath
48 self.parent = self.GetParent()#parent
49 self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Arial"))
53 self.list_graph = list_graph
54 self.TabCHD = self.parent.GetParent()
55 self.nb = self.TabCHD.GetParent()
56 self.ira = self.nb.GetParent()
57 self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
58 afc_img = wx.Image(os.path.join(self.ira.images_path,'button_afc.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
59 self.butafc = wx.BitmapButton(self, -1, afc_img)
60 self.Bind(wx.EVT_BUTTON, self.afc_graph, self.butafc)
61 self.dirout = os.path.dirname(self.Dict['ira'])
64 for i in range(0,len(list_graph)):
65 if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
66 filename, ext = os.path.splitext(list_graph[i][0])
67 if ext == '.svg' or ext == '.html':
68 self.listimg.append(hl.HyperLinkCtrl(self.panel_1, -1, os.path.join(self.dirout,list_graph[i][0]), URL=os.path.join(self.dirout,list_graph[i][0])))
70 self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
71 if os.path.exists(os.path.join(self.dirout,list_graph[i][0] + '_notplotted.csv')) :
72 txt = _(u"List of not plotted points : ").decode('utf8') + '%s' % os.path.join(self.dirout,list_graph[i][0] + '_notplotted.csv')
75 self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1] + txt))
76 self.buts.append(wx.Button(self.panel_1, wx.ID_DELETE, name = `i - b`))
80 self.list_graph = [graph for i, graph in enumerate(self.list_graph) if i not in todel]
82 self.param = { 'typegraph' : 0,
89 'do_select_chi_classe' : 0,
107 self.__set_properties()
110 def __set_properties(self):
111 self.panel_1.EnableScrolling(True,True)
112 #self.panel_1.SetSize((1000,1000))
113 self.panel_1.SetScrollRate(20, 20)
114 self.panel_1.SetFocus()
116 def __do_layout(self):
117 self.sizer_1 = wx.BoxSizer(wx.VERTICAL)
118 self.sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
119 self.sizer_3 = wx.BoxSizer(wx.VERTICAL)
120 self.sizer_2.Add(self.butafc, 0, 0, 0)
121 for i in range(0, len(self.listimg)):
122 self.sizer_3.Add(self.listimg[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
123 self.sizer_3.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
124 self.sizer_3.Add(self.buts[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
125 self.Bind(wx.EVT_BUTTON, self.on_delete_image, self.buts[i])
126 self.panel_1.SetSizer(self.sizer_3)
127 self.sizer_2.Add(self.panel_1, 1, wx.EXPAND, 0)
128 self.SetSizer(self.sizer_2)
130 def on_delete_image(self, event) :
131 image_id = int(event.GetEventObject().GetName())
132 image_path = self.list_graph[image_id][0]
133 message = _(u'This file will be delete : ') + '%s.\n' % os.path.join(self.dirout, image_path) + _('Are you sure ?')
134 dial = wx.MessageDialog(self, message, style = wx.YES_NO)
135 res = dial.ShowModal()
136 if res == wx.ID_YES :
138 log.info('delete image %i' % image_id)
139 oldimg = self.listimg.pop(image_id)
141 oldlab = self.labels.pop(image_id)
143 oldbut = self.buts.pop(image_id)
145 for i, but in enumerate(self.buts) :
147 todel = self.list_graph.pop(image_id)
148 os.remove(os.path.join(self.dirout, todel[0]))
149 print_liste(self.Dict[self.itempath], self.list_graph)
150 self.sizer_3.Fit(self.panel_1)
156 def afc_graph(self,event):
157 #dirout = os.path.dirname(self.Dict['ira'])
158 dial = PrefGraph(self.parent,-1,self.param,'')
159 dial.CenterOnParent()
160 val = dial.ShowModal()
162 if dial.choix_format.GetSelection() == 0 :
166 typegraph = dial.choicetype.GetSelection()
171 if self.clnb <= 3 and typegraph == 1 :
175 while os.path.exists(os.path.join(self.dirout,'graph_afc_'+str(self.afcnb)+typefile)):
177 self.fileout = ffr(os.path.join(self.dirout,'graph_afc_'+str(self.afcnb)+typefile))
179 self.param = {'typegraph' : typegraph,
180 'width' : dial.spin1.GetValue(),
181 'height' : dial.spin2.GetValue(),
182 'what' : dial.choice1.GetSelection(),
183 'qui' : dial.choice2.GetSelection(),
184 'do_select_nb' : dial.check1.GetValue(),
185 'do_select_chi' : dial.check2.GetValue(),
186 'do_select_chi_classe' : dial.check_chic.GetValue(),
187 'select_nb' : dial.spin_nb.GetValue(),
188 'select_chi' : dial.spin_chi.GetValue(),
189 'nbchic' : dial.spin_nbchic.GetValue(),
190 'over' : dial.check3.GetValue(),
191 'cex_txt' : dial.check4.GetValue(),
192 'txt_min' : dial.spin_min.GetValue(),
193 'txt_max' : dial.spin_max.GetValue(),
194 'tchi' : dial.check_tchi.GetValue(),
195 'tchi_min' : dial.spin_min_tchi.GetValue(),
196 'tchi_max' : dial.spin_max_tchi.GetValue(),
197 'taillecar' : dial.spin3.GetValue(),
198 'facteur' : [dial.spin_f1.GetValue(),dial.spin_f2.GetValue(), dial.spin_f3.GetValue()],
200 'film' : str(dial.film.GetValue()).upper(),
201 'alpha' : dial.slider_sphere.GetValue(),
204 self.nb.parent = self.ira
205 self.DictPathOut = self.Dict
206 self.RscriptsPath = self.ira.RscriptsPath
209 """ % ffr(self.DictPathOut['RData'])
210 if self.itempath == 'liste_graph_afcf' :
213 afc_table <- afcf_table
214 chistabletot <- specfp
216 elif self.itempath == 'liste_graph_afct' :
219 afc_table <- afct_table
220 chistabletot <- spectp
222 txt += write_afc_graph(self)
223 filetmp = tempfile.mktemp()
224 with open(filetmp, 'w') as f :
226 pid = exec_rcode(self.ira.RPath, filetmp)
227 check_Rresult(self.ira, pid)
228 if self.param['typegraph'] in [0,2] :
230 if self.param['qui'] == 0 : value = u'actives'
231 if self.param['qui'] == 1 : value = u'supplémentaires'
232 if self.param['qui'] == 2 : value = u'étoilées'
233 if self.param['qui'] == 3 : value = u'classes'
235 if self.param['what'] == 0 : value = u'Coordonnées'
236 if self.param['what'] == 1 : value = u'Corrélations'
237 txt += value + u' - facteur %i / %i' % (self.param['facteur'][0], self.param['facteur'][1])
238 if self.param['do_select_nb'] : txt += u' - sélection de %i variables' % self.param['select_nb']
239 if self.param['do_select_chi'] : txt += u' - sélection des variables avec chi2 > %i ' % self.param['select_chi']
240 if self.param['over'] : txt += u' - Eviter les recouvrements'
241 if self.param['cex_txt'] : txt += u' - taille du texte proportionnel à la masse'
242 if self.param['tchi'] : txt += u' - taille du texte proportionnel au chi2 d\'association'
243 #list_graph = read_list_file(self.DictPathOut[self.itempath], self.coding)
244 if self.param['svg'] :
245 filename, ext = os.path.splitext(self.fileout)
246 self.fileout = filename + '.svg'
247 if self.param['typegraph'] == 2 :
248 parametres = {'gexffile' : self.fileout,
250 'nodemin': self.param['txt_min'],
251 'nodemax': self.param['txt_max'],
252 'bargraphw' : 60*int(self.param['clnb']),
254 web = WebExport(self.ira, parametres)
255 self.fileout = web.exportafc()
256 self.list_graph.append([os.path.basename(self.fileout), txt])
257 print_liste(self.DictPathOut[self.itempath], self.list_graph)
258 if self.param['svg'] or self.param['typegraph'] == 2:
259 self.listimg.append(hl.HyperLinkCtrl(self.panel_1, -1, self.fileout, URL=self.fileout))
262 self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(self.fileout, wx.BITMAP_TYPE_ANY)))
263 self.sizer_3.Add( self.listimg[-1], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
264 self.labels.append(wx.StaticText(self.panel_1,-1, txt))
265 self.sizer_3.Add(self.labels[-1], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
266 self.buts.append(wx.Button(self.panel_1, wx.ID_DELETE, name = `len(self.list_graph) - 1`))
267 self.sizer_3.Add(self.buts[-1], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
268 self.sizer_3.Fit(self.panel_1)
271 self.panel_1.Scroll(0,self.panel_1.GetScrollRange(wx.VERTICAL))
272 # elif self.param['typegraph'] == 2 :
273 # parametres = {'gexffile' : self.fileout,
274 # 'titre': 'Le titre',
275 # 'nodemin': self.param['txt_min'],
276 # 'nodemax': self.param['txt_max'],
277 # 'bargraphw' : 60*int(self.param['clnb']),
279 # web = WebExport(self.ira, parametres)
280 # afcout = web.exportafc()
281 # dial = SimpleDialog(self.ira)
282 # dial.link.SetLabel(afcout)
283 # dial.link.SetURL(afcout)
288 class GraphPanel(wx.ScrolledWindow):
289 def __init__(self, parent, dico, list_graph, txt = '', style = wx.TAB_TRAVERSAL):
290 wx.ScrolledWindow.__init__(self, parent, style = style)
294 self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Arial"))
297 self.dirout = os.path.dirname(self.Dict['ira'])
298 self.deb = wx.StaticText(self, -1, txt)
299 for i in range(0,len(list_graph)):
300 if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
301 filename, ext = os.path.splitext(list_graph[i][0])
303 self.listimg.append(hl.HyperLinkCtrl(self, -1, os.path.join(self.dirout,list_graph[i][0]), URL=os.path.join(self.dirout,list_graph[i][0])))
305 self.listimg.append(wx.StaticBitmap(self, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
306 self.labels.append(wx.StaticText(self, -1, list_graph[i][1]))
307 self.Bind(wx.EVT_MOTION, self.onMouseMove)
308 self.__set_properties()
311 def __set_properties(self):
312 self.EnableScrolling(True,True)
313 self.SetScrollRate(20, 20)
317 def __do_layout(self):
318 self.sizer_1 = wx.BoxSizer(wx.VERTICAL)
319 self.sizer_2 = wx.BoxSizer(wx.VERTICAL)
320 self.sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
321 self.sizer_1.Add(self.deb)
322 for i in range(0, len(self.listimg)):
323 self.sizer_1.Add(self.listimg[i], 1, wx.ALIGN_CENTER_HORIZONTAL, 0)
324 self.sizer_1.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
325 self.sizer_2.Add(self.sizer_1, 1, wx.EXPAND, 0)
326 self.SetSizer(self.sizer_1)
327 self.sizer_1.Fit(self)
329 def onMouseMove(self, event):
333 def open_antiprofil(panel, AntiProfile, encoding) :
334 DictAnti = ReadProfileAsDico(AntiProfile, True, encoding)
335 panel.AntiProfNB = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
336 for i in range(0, panel.parametres['clnb']):
337 tabantiprofile = ProfListctrlPanel(panel, panel, DictAnti[str(i + 1)], True, i + 1)
338 panel.AntiProfNB.AddPage(tabantiprofile, 'classe %s' % str(i + 1))
339 panel.TabChdSim.AddPage(panel.AntiProfNB, _(u"Antiprofiles").decode('utf8'))
343 def getlemgram(corpus, lem) :
344 if not lem[6] in corpus.lems :
347 return corpus.lems[lem[6]].gram
350 def __init__(self, parent, corpus, parametres, Alceste=False):
355 self.parametres = parametres
356 self.pathout = PathOut(parametres['ira'])
357 self.pathout.basefiles(ChdTxtPathOut)
358 DictPathOut = self.pathout
359 self.DictPathOut = DictPathOut
360 self.dictpathout = DictPathOut
363 Profile = DictPathOut['PROFILE_OUT']
364 AntiProfile = DictPathOut['ANTIPRO_OUT']
365 self.encoding = self.parametres['encoding']
366 if isinstance(self.corpus, Corpus) :
367 self.corpus.make_ucecl_from_R(self.pathout['uce'])
368 corpname = self.corpus.parametres['corpus_name']
370 corpname = self.corpus.parametres['matrix_name']
371 if os.path.exists(self.pathout['analyse.db']) :
372 self.corpus.read_tableau(self.pathout['analyse.db'])
374 clnb = parametres['clnb']
375 dlg = progressbar(self, maxi = 4 + clnb)
377 print 'lecture des profils'
378 dlg.Update(2, _(u"Reading profiles").decode('utf8'))
380 DictProfile = ReadProfileAsDico(Profile, Alceste, self.encoding)
381 self.DictProfile = DictProfile
382 self.cluster_size = []
384 for i in range(0, clnb) :
385 clusternames[i] = ' '.join([u'%i' % (i + 1), _(u'Cluster').decode('utf8'), u'%i' % (i + 1)])
386 if os.path.exists(self.pathout['classes_names.txt']) :
387 with codecs.open(self.pathout['classes_names.txt'], 'r', self.parent.syscoding) as f :
388 clusternames_ = f.read()
389 clusternames_ = dict([[i, ' '.join([`i + 1`, line])] for i, line in enumerate(clusternames_.splitlines())])
390 clusternames.update(clusternames_)
391 #print 'lecture des antiprofils'
392 #DictAnti = ReadProfileAsDico(self, AntiProfile, Alceste, self.encoding)
394 panel = wx.Panel(parent, -1)
395 sizer1 = wx.BoxSizer(wx.VERTICAL)
397 if os.path.exists(DictPathOut['pre_rapport']):
398 with codecs.open(DictPathOut['pre_rapport'], 'r', self.encoding) as f :
403 # panel.chd_toolbar = wx.ToolBar(panel, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER)
404 # panel.chd_toolbar.SetToolBitmapSize(wx.Size(16, 16))
406 if isinstance(self.corpus, Corpus) :
407 panel.corpus = self.corpus
409 panel.tableau = self.corpus
410 #self.parent.tableau = panel.tableau
411 panel.dictpathout = self.DictPathOut
412 panel.pathout = self.DictPathOut
413 panel.parent = self.parent
414 panel.DictProfile = self.DictProfile
415 panel.cluster_size = self.cluster_size
416 panel.debtext = self.debtext
418 # self.ID_rapport = wx.NewId()
419 # #rap_img = wx.Image(os.path.join(self.parent.images_path,'icone_rap_16.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
420 # #panel.chd_toolbar.AddLabelTool(self.ID_rapport, "rapport", rap_img, shortHelp=u"Produire le rapport", longHelp=u"Exporter un rapport en texte simple")
421 # butrap = wx.Button(panel.chd_toolbar, self.ID_rapport, u"Rapport ")
422 # panel.chd_toolbar.AddControl(butrap)
424 # panel.chd_toolbar.Realize()
425 # sizer1.Add(panel.chd_toolbar,0, wx.EXPAND, 5)
427 #self.TabChdSim = wx.aui.AuiNotebook(self.parent.nb, -1, wx.DefaultPosition)
428 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
429 panel.TabChdSim = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
430 #panel.TabChdSim = LB.LabelBook(panel, -1, agwStyle = INB_TOP|INB_SHOW_ONLY_TEXT|INB_FIT_LABELTEXT)
431 panel.TabChdSim.SetAGWWindowStyleFlag(notebook_flags)
432 panel.TabChdSim.SetArtProvider(aui.ChromeTabArt())
433 sizer1.Add(panel.TabChdSim,10, wx.EXPAND, 5)
434 panel.SetSizer(sizer1)
438 if isinstance(self.corpus, Corpus) :
439 panel.TabChdSim.corpus = corpus
440 panel.TabChdSim.corpus.dictpathout = self.DictPathOut
442 panel.TabChdSim.tableau = corpus
443 panel.TabChdSim.tableau.dictpathout = self.DictPathOut
444 panel.parametres = self.parametres
447 self.notenb = self.parent.nb.GetPageCount()
450 if os.path.exists(self.DictPathOut['liste_graph_chd']) :
451 list_graph = read_list_file(self.DictPathOut['liste_graph_chd'], self.encoding)
452 CHD = GraphPanelDendro(panel.TabChdSim, DictPathOut, list_graph, txt = self.debtext)
453 panel.TabChdSim.AddPage(CHD,'CHD')
455 panel.ProfNB = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
456 notebook_flags |= aui.AUI_NB_WINDOWLIST_BUTTON
457 panel.ProfNB.SetAGWWindowStyleFlag(notebook_flags)
458 #panel.ProfNB.SetArtProvider(aui.ChromeTabArt())
459 #panel.ProfNB = LB.LabelBook(panel, -1, agwStyle = INB_LEFT|INB_SHOW_ONLY_TEXT|INB_FIT_LABELTEXT)
460 #panel.ProfNB = wx.Listbook(self.parent, -1, style = wx.BK_DEFAULT)
461 #panel.ProfNB = wx.Treebook(self.parent, -1, style = wx.BK_DEFAULT)
462 #self.ProfNB.SetTabCtrlHeight(100)
463 #panel.AntiProfNB = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
464 if os.path.exists(DictPathOut['prof_seg']) :
465 prof_seg = ReadProfileAsDico(DictPathOut['prof_seg'], False, self.encoding)
466 self.prof_seg_nb = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
467 for i in range(0, clnb):
468 self.cluster_size.append(DictProfile[str(i + 1)][0][0:3])
469 if isinstance(self.corpus, Corpus) :
470 DictProfile[str(i + 1)][1:] = [val[0:5] + [getlemgram(self.corpus, val)] + val[6:] for val in DictProfile[str(i + 1)][1:]]
471 dlg.Update(3+i, 'Classe %i' %(i+1))
472 ind = '/'.join(DictProfile[str(i + 1)][0][0:2]).strip()
473 indpour = '\n'.join([ind, DictProfile[str(i + 1)][0][2]])
474 self.tabprofile = ProfListctrlPanel(self.parent, self.panel, DictProfile[str(i + 1)], Alceste, i + 1)
475 #self.tabantiprofile = ProfListctrlPanel(self.parent, self, DictAnti[str(i + 1)], Alceste, i + 1)
476 panel.ProfNB.AddPage(self.tabprofile, clusternames[i] + '\n%s%%' % indpour, True)
477 panel.ProfNB.SetPageTextColour(i, '#890909')
478 panel.ProfNB.SetRenamable(i, True)
479 #panel.AntiProfNB.AddPage(self.tabantiprofile, 'classe %s' % str(i + 1))
480 if os.path.exists(DictPathOut['prof_seg']) :
481 self.tab_prof_seg = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
482 self.prof_seg_nb.AddPage(self.tab_prof_seg, _(u"Cluster").decode('utf8') + ' %i' % (i + 1))
483 panel.ProfNB.SetSelection(0)
486 self.TabAFC = aui.AuiNotebook(panel.TabChdSim, -1, wx.DefaultPosition)
488 list_graph=read_list_file(DictPathOut['liste_graph_afc'], self.encoding)
489 self.tabAFCGraph = GraphPanelAfc(self.TabAFC, DictPathOut, list_graph, self.clnb, coding=self.encoding)
490 self.TabAFC.AddPage(self.tabAFCGraph, _(u"CA").decode('utf8'))
492 if os.path.exists(self.DictPathOut['afc_facteur']) :
493 dictrow, first = ReadList(self.DictPathOut['afc_facteur'], self.encoding)
494 self.TabAFC_facteur = ListForSpec(self.parent, parametres, dictrow, first[1:])
495 #dictrow, first = ReadList(self.DictPathOut['afc_row'], self.encoding)
496 #self.TabAFC_ligne = ListForSpec(self.parent, self.parametres, dictrow, first)
497 #dictrow, first = ReadList(self.DictPathOut['afc_col'], self.encoding)
498 #self.TabAFC_colonne = ListForSpec(parent, self.parametres, dictrow, first)
499 self.TabAFC.AddPage(self.TabAFC_facteur, _(u"Factor").decode('utf8'))
500 #self.TabAFC.AddPage(self.TabAFC_colonne, u'Colonnes')
501 #self.TabAFC.AddPage(self.TabAFC_ligne, u'Lignes')
503 sizer_3 = wx.BoxSizer(wx.VERTICAL)
504 self.parent.nb_panel_2 = wx.Panel(panel.TabChdSim, -1)
505 self.parent.button_simi = wx.Button(self.parent.nb_panel_2, -1, "Voyager")
506 self.parent.simi3dpanel = simi3d(self.parent.nb_panel_2, -1)
507 sizer_3.Add(self.parent.simi3dpanel, 1, wx.EXPAND, 0)
508 sizer_3.Add(self.parent.button_simi, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
509 self.parent.nb_panel_2.SetSizer(sizer_3)
510 self.TabAFC.AddPage(self.parent.nb_panel_2, _(u"3D graph").decode('utf8'))
511 self.parent.Bind(wx.EVT_BUTTON, self.onsimi, self.parent.button_simi)
513 panel.TabChdSim.AddPage(panel.ProfNB, _(u"Profiles").decode('utf8'))
514 #panel.TabChdSim.AddPage(panel.AntiProfNB, 'Antiprofils')
515 dlg.Update(4 + self.clnb, 'Affichage...')
517 panel.TabChdSim.AddPage(self.TabAFC, _(u"CA").decode('utf8'))
518 if os.path.exists(DictPathOut['prof_seg']) :
519 panel.TabChdSim.AddPage(self.prof_seg_nb, _(u"Repeated segments profiles").decode('utf8'))
521 # panel.Bind(wx.EVT_BUTTON, self.ongetrapport, id = self.ID_rapport)
522 self.parent.nb.AddPage(panel, _(u"Clustering").decode('utf8') + ' - %s' % corpname)
523 self.parent.ShowTab(True)
524 self.parent.nb.SetSelection(self.parent.nb.GetPageCount() - 1)
525 #for pane in self.parent._mgr.GetAllPanes() :
526 # if isinstance(pane.window, aui.AuiNotebook):
528 # nb.SetAGWWindowStyleFlag(notebook_flags)
529 # nb.SetArtProvider(aui.ChromeTabArt())
531 self.parent._mgr.Update()
533 def onsimi(self,event):
534 outfile = print_simi3d(self)
535 error = exec_rcode(self.parent.RPath, outfile, wait = True)
537 def onclusterstat(self, evt) :
538 dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.csv', 'title': 'Stat par classe'})
539 dial.fbb.SetValue( os.path.join(os.path.dirname(self.corpus.dictpathout['ira']), 'stat_par_classe.csv'))
540 dial.CenterOnParent()
541 res = dial.ShowModal()
543 fileout = dial.fbb.GetValue()
545 self.corpus.get_stat_by_cluster(fileout)
547 dlg = wx.MessageDialog(self.parent, msg, _(u"Stat by cluster").decode('utf8'), wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION)
549 if dlg.ShowModal() == wx.ID_OK :
552 #def onsearchf(self, evt) :
553 # if 'FrameSearch' not in dir(self.panel) :
554 # self.panel.FrameSearch = SearchFrame(self.parent, -1, u"Rechercher...", self.corpus)
555 # self.panel.FrameSearch.Show()
557 def PrintRapport(self, corpus, parametres, istxt = True):
561 |i|R|a|M|u|T|e|Q| - %s
565 """ % datetime.datetime.now().ctime()
567 totocc = corpus.gettotocc()
568 txt += u'nombre de textes: %i%s' % (corpus.getucinb(), sep)
569 txt += u'nombre de segments de textes: %i%s' % (corpus.getucenb(), sep)
570 txt += u'nombre de formes: %i%s' % (len(corpus.formes), sep)
571 txt += u'nombre d\'occurrences: %i%s' % (totocc, sep)
572 txt += u'moyenne d\'occurrences par forme: %f%s' % (float(totocc) / float(len(self.corpus.formes)), sep)
573 txt += u'nombre de lemmes: %i%s' % (len(corpus.lems), sep)
574 txt += u'nombre de formes actives: %i%s' % (corpus.getactivesnb(1), sep)
575 txt += u'nombre de formes supplémentaires: %i%s' % (corpus.getactivesnb(2), sep)
576 txt += u'nombre de formes actives de fréquence >= %i: %i%s' % (parametres['eff_min_forme'], parametres['nbactives'], sep)
577 txt += u'moyenne d\'occurrences par segments :%f%s' % (float(totocc) / float(corpus.getucenb()), sep)
578 if 'tailleuc1' in parametres :
579 if parametres['classif_mode'] == 0 :
580 txt += u'taille rst1 / rst2: %i / %i - %i / %i%s' % (parametres['tailleuc1'], parametres['tailleuc2'], parametres['lenuc1'], parametres['lenuc2'], sep)
582 self.Ucenb = self.nbind
583 txt += u'nombre d\'individus : %i%s' % (self.nbind, sep)
584 txt += u'nombre de classes : %i%s' % (self.clnb, sep)
586 txt += u'nombre de classes : %i%s' % (parametres['clnb'], sep)
587 if parametres['classif_mode'] == 0 or parametres['classif_mode'] == 1 :
588 txt += u'%i segments classés 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)
589 elif self.parametres['classif_mode'] == 2 :
590 txt += u'%i textes classés 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)
592 txt += u'%i segments classées sur %i (%.2f%%)%s' % (self.ucecla, self.Ucenb, (float(self.ucecla) / float(self.Ucenb)) * 100, sep)
595 ###########################
597 ###########################
598 """ % parametres.get('time', '')
599 with open(self.pathout['pre_rapport'], 'w') as f :
603 class SashList(wx.Panel) :
604 def __init__(self, parent) :
605 wx.Panel.__init__(self, parent, -1)
608 #self.gparent=gparent
612 # A window to the left of the client window
613 #self.listlex = listlex
614 self.leftwin1 = wx.SashLayoutWindow(
615 self, -1, wx.DefaultPosition, (200, 300),
616 wx.NO_BORDER|wx.SW_3D
619 self.leftwin1.SetDefaultSize((120, 1000))
620 self.leftwin1.SetOrientation(wx.LAYOUT_VERTICAL)
621 self.leftwin1.SetAlignment(wx.LAYOUT_LEFT)
622 self.leftwin1.SetBackgroundColour(wx.Colour(0, 255, 0))
623 self.leftwin1.SetSashVisible(wx.SASH_RIGHT, True)
624 self.leftwin1.SetExtraBorderSize(10)
626 #textWindow = wx.TextCtrl(
627 # leftwin1, -1, "", wx.DefaultPosition, wx.DefaultSize,
628 # wx.TE_MULTILINE|wx.SUNKEN_BORDER
631 #textWindow.SetValue("A sub window")
633 self.leftWindow1 = self.leftwin1
634 winids.append(self.leftwin1.GetId())
636 rightwin1 = wx.SashLayoutWindow(
637 self, -1, wx.DefaultPosition, (200, 300),
638 wx.NO_BORDER|wx.SW_3D
641 rightwin1.SetDefaultSize((120, 1000))
642 rightwin1.SetOrientation(wx.LAYOUT_VERTICAL)
643 rightwin1.SetAlignment(wx.LAYOUT_LEFT)
644 rightwin1.SetBackgroundColour(wx.Colour(0, 255, 0))
645 rightwin1.SetSashVisible(wx.SASH_RIGHT, True)
646 rightwin1.SetExtraBorderSize(10)
647 #textWindow = wx.TextCtrl(
648 # leftwin1, -1, "", wx.DefaultPosition, wx.DefaultSize,
649 # wx.TE_MULTILINE|wx.SUNKEN_BORDER
652 #textWindow.SetValue("A sub window")
654 self.rightwin1 = rightwin1
655 winids.append(rightwin1.GetId())
658 def __init__(self, page):
660 parametres = self.page.parametres
661 ira = wx.GetApp().GetTopWindow()
662 self.page.tgens, etoiles = ReadList(parametres['tgenspec'], ira.syscoding, sep="\t")
665 for i in range(page.GetPageCount()) :
666 tab = page.GetPage(i)
667 if 'gparent' in dir(tab) :
668 if tab.gparent is not None :
669 gparent = tab.gparent
670 if 'tgen' in dir(tab) :
675 self.page.tgentab.RefreshData(self.page.tgens)
676 self.page.SetSelection(i)
678 self.page.tgentab = ListForSpec(ira, gparent, self.page.tgens, etoiles[1:])
679 self.page.tgentab.tgen = True
680 self.page.AddPage(self.page.tgentab, u'Tgens Specificities')
681 self.page.SetSelection(self.page.GetPageCount() - 1)
684 def __init__(self, ira, corpus, parametres):
685 self.pathout = PathOut(dirout = parametres['pathout'])
687 self.dictpathout = StatTxtPathOut(parametres['pathout'])
688 #self.corpus.read_corpus_from_shelves(self.corpus.dictpathout['db'])
690 self.encoding = self.corpus.parametres['syscoding']
691 self.parametres = parametres
693 self.DictSpec, first = ReadList(self.dictpathout['tablespecf'], self.corpus.parametres['syscoding'])
694 if os.path.exists(self.pathout['banalites.csv']) :
695 self.dictban, firstban = ReadList(self.pathout['banalites.csv'], self.corpus.parametres['syscoding'])
696 self.DictType, firstt = ReadList(self.dictpathout['tablespect'], self.corpus.parametres['syscoding'])
697 self.DictEff, firsteff = ReadList(self.dictpathout['tableafcm'], self.corpus.parametres['syscoding'])
698 self.DictEffType, firstefft = ReadList(self.dictpathout['tabletypem'], self.corpus.parametres['syscoding'])
699 self.DictEffRelForme, firsteffrelf = ReadList(self.dictpathout['eff_relatif_forme'], self.corpus.parametres['syscoding'])
700 self.DictEffRelType, firsteffrelt = ReadList(self.dictpathout['eff_relatif_type'], self.corpus.parametres['syscoding'])
701 self.etoiles = firsteff[1:]
702 #sash = SashList(ira.nb)
705 self.TabStat = aui.AuiNotebook(ira.nb, -1, wx.DefaultPosition)
706 self.TabStat.parametres = parametres
707 self.ListPan = ListForSpec(ira, self, self.DictSpec, self.etoiles)
708 if os.path.exists(self.pathout['banalites.csv']) :
709 self.listban = ListForSpec(ira, self, self.dictban, ['eff'] + self.etoiles)
710 #self.ListPan2 = ListForSpec(sash.rightwin1, self, self.DictSpec, first)
711 self.ListPant = ListForSpec(ira, self, self.DictType, self.etoiles)
712 self.ListPanEff = ListForSpec(ira, self, self.DictEff, self.etoiles)
713 self.ListPanEffType = ListForSpec(ira, self, self.DictEffType, self.etoiles)
714 self.ListPanEffRelForme = ListForSpec(ira, self, self.DictEffRelForme, self.etoiles)
715 self.ListPanEffRelType = ListForSpec(ira, self, self.DictEffRelType, self.etoiles)
717 self.TabStat.AddPage(self.ListPan, u'formes')
718 if os.path.exists(self.pathout['banalites.csv']) :
719 self.TabStat.AddPage(self.listban, u'banalités')
720 self.TabStat.AddPage(self.ListPant, u'Types')
721 self.TabStat.AddPage(self.ListPanEff, u'Effectifs formes')
722 self.TabStat.AddPage(self.ListPanEffType, u'Effectifs Type')
723 self.TabStat.AddPage(self.ListPanEffRelForme, u'Effectifs relatifs formes')
724 self.TabStat.AddPage(self.ListPanEffRelType, u'Effectifs relatifs Type')
725 if self.parametres['clnb'] > 2 :
726 self.TabAFC = aui.AuiNotebook(self.TabStat, -1, wx.DefaultPosition)
727 list_graph=read_list_file(self.dictpathout['liste_graph_afcf'], encoding = self.encoding)
728 self.tabAFCGraph = GraphPanelAfc(self.TabAFC, self.dictpathout, list_graph, self.parametres['clnb'], itempath ='liste_graph_afcf', coding = self.encoding)
729 self.TabAFC.AddPage(self.tabAFCGraph, 'AFC formes')
730 list_graph=read_list_file(self.dictpathout['liste_graph_afct'], encoding = self.encoding)
731 self.tabAFCTGraph = GraphPanelAfc(self.TabAFC, self.dictpathout, list_graph, self.parametres['clnb'], itempath ='liste_graph_afct', coding=self.encoding)
732 self.TabAFC.AddPage(self.tabAFCTGraph, 'AFC type')
733 self.TabStat.AddPage(self.TabAFC, 'AFC')
739 ira.nb.AddPage(self.TabStat, u'Spécificités')
742 self.TabStat.corpus = self.corpus
743 self.TabStat.etoiles = self.etoiles
744 if os.path.exists(os.path.join(self.parametres['pathout'], 'tgenspec.csv')) :
745 self.parametres['tgenspec'] = os.path.join(self.parametres['pathout'], 'tgenspec.csv')
746 TgenLayout(self.TabStat)
747 self.TabStat.SetSelection(0)
748 ira.nb.SetSelection(self.parent.nb.GetPageCount() - 1)
749 ira.ShowAPane("Tab_content")
752 def __init__(self, ira, corpus, parametres):
753 self.pathout = PathOut(dirout = parametres['pathout'])
757 self.TabStat = aui.AuiNotebook(ira.nb, -1, wx.DefaultPosition)
758 self.TabStat.parametres = parametres
759 self.TabStat.corpus = corpus
760 self.TabStat.pathout = self.pathout
761 # CHD = GraphPanel(panel.TabChdSim, DictPathOut, list_graph, txt = self.debtext)
762 # panel.TabChdSim.AddPage(CHD,'CHD')
764 #self.TabStatTot = wx.TextCtrl(self.TabStat, -1, style=wx.NO_BORDER | wx.TE_MULTILINE | wx.TE_RICH2)
765 list_graph = [['zipf.png', 'zipf']]
766 self.TabStatTot = GraphPanel(ira.nb, self.pathout, list_graph, self.result['glob'])
767 self.TabStat.AddPage(self.TabStatTot, 'global')
768 for item in self.result:
770 datam = [['forme', 'nb']]
771 self.ListPan = ListPanel(ira, self, self.result[item])
772 self.TabStat.AddPage(self.ListPan, ' '.join(item.split('_')))
773 ira.nb.AddPage(self.TabStat, '%s' % parametres['name'])
774 ira.nb.SetSelection(ira.nb.GetPageCount() - 1)
775 ira.ShowAPane("Tab_content")
777 def read_result(self) :
778 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'}
781 with open(self.pathout[lcle[key]], 'r') as f :
782 self.result[key] = [line.split(';') for line in f.read().splitlines()]
783 self.result[key] = dict([[i,[line[0],int(line[1]), line[2]]] for i, line in enumerate(self.result[key])])
784 with open(self.pathout['glob.txt'], 'r') as f :
785 self.result['glob'] = f.read()
787 class GraphPanelDendro(wx.Panel):
788 def __init__(self,parent, dico, list_graph, txt=False):
789 wx.Panel.__init__(self,parent)
791 self.dictpathout = dico
792 self.dirout = os.path.dirname(self.dictpathout['ira'])
793 self.list_graph = list_graph
794 self.parent = self.GetParent()#parent
795 self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Arial"))
798 self.tabchd = self.parent.GetParent()
799 self.ira = self.tabchd.GetParent()
800 self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
801 self.panel_1.SetBackgroundColour('white')
802 self.deb = wx.StaticText(self.panel_1, -1, txt)
803 dendro_img = wx.Image(os.path.join(self.ira.images_path,'but_dendro.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
804 self.butdendro = wx.BitmapButton(self, -1, dendro_img)
805 self.butdendrotexte = wx.BitmapButton(self, -1, dendro_img)
806 self.butdendrocloud = wx.BitmapButton(self, -1, dendro_img)
808 for i in range(0,len(list_graph)):
809 if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
810 filename, ext = os.path.splitext(list_graph[i][0])
812 self.listimg.append(hl.HyperLinkCtrl(self.panel_1, -1, os.path.join(self.dirout,list_graph[i][0]), URL=os.path.join(self.dirout,list_graph[i][0])))
814 self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
815 self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1]))
817 self.__set_properties()
820 def __set_properties(self):
821 self.panel_1.EnableScrolling(True,True)
822 #self.panel_1.SetSize((1000,1000))
823 self.panel_1.SetScrollRate(20, 20)
824 self.panel_1.SetFocus()
825 self.Bind(wx.EVT_BUTTON, self.ondendro, self.butdendro)
826 self.Bind(wx.EVT_BUTTON, self.ondendrotexte, self.butdendrotexte)
827 self.Bind(wx.EVT_BUTTON, self.ondendrocloud, self.butdendrocloud)
828 self.param = {'width' : 700,
832 'taille_classe' : True,
836 self.type_dendro = [ u"phylogram", u"cladogram", u"fan", u"unrooted", u"radial" ]
838 def __do_layout(self):
839 self.sizer_1 = wx.BoxSizer(wx.VERTICAL)
840 self.sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
841 self.sizer_3 = wx.BoxSizer(wx.VERTICAL)
842 self.sizer_3.Add(self.deb)
843 self.sizer_1.Add(self.butdendro, 0, 0, 0)
844 self.sizer_1.Add(self.butdendrotexte, 0, 0, 0)
845 self.sizer_1.Add(self.butdendrocloud, 0, 0, 0)
847 for i in range(0, len(self.listimg)):
848 self.sizer_3.Add(self.listimg[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
849 self.sizer_3.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
850 self.panel_1.SetSizer(self.sizer_3)
851 self.sizer_2.Add(self.sizer_1, 0, wx.EXPAND, 0)
852 self.sizer_2.Add(self.panel_1, 1, wx.EXPAND, 0)
853 self.SetSizer(self.sizer_2)
855 def make_param(self, dial):
856 self.param['width'] = dial.m_spinCtrl2.GetValue()
857 self.param['height'] = dial.m_spinCtrl1.GetValue()
858 self.param['type_dendro'] = dial.m_choice1.GetSelection()
859 self.param['color_nb'] = dial.m_radioBox1.GetSelection()
860 self.param['taille_classe'] = dial.m_checkBox1.GetValue()
861 self.param['type_tclasse'] = dial.m_radioBox2.GetSelection()
862 self.param['svg'] = dial.choice_format.GetSelection()
864 def make_dendro(self, dendro = 'simple') :
865 if self.param['svg'] :
869 while os.path.exists(os.path.join(self.dirout, 'dendrogramme_' + str(self.graphnb)+typefile)) :
871 fileout = ffr(os.path.join(self.dirout,'dendrogramme_' + str(self.graphnb)+typefile))
872 width = self.param['width']
873 height = self.param['height']
874 type_dendro = self.type_dendro[self.param['type_dendro']]
875 if self.param['taille_classe'] :
879 if self.param['color_nb'] == 0 :
883 if self.param['type_tclasse'] == 0 :
887 if self.param['svg'] :
891 dendro_path = self.dictpathout['Rdendro']
892 classe_path = self.dictpathout['uce']
897 classes <- read.csv2("%s", row.names=1)
898 classes <- classes[,1]
899 """ % (ffr(dendro_path), ffr(self.ira.RscriptsPath['Rgraph']), ffr(classe_path))
900 if dendro == 'simple' :
902 open_file_graph("%s", width=%i, height=%i)
903 plot.dendropr(tree.cut1$tree.cl, classes, type.dendro="%s", histo=%s, bw=%s, lab=NULL, tclasse=%s)
904 """ % (ffr(fileout), width, height, type_dendro, histo, bw, tclasse)
905 elif dendro == 'texte' :
909 chistable <- chistabletot[1:(debsup-1),]
910 open_file_graph("%s", width=%i, height=%i, svg = %s)
911 plot.dendro.prof(tree.cut1$tree.cl, classes, chistable, nbbycl = 60, type.dendro="%s", bw=%s, lab=NULL)
912 """ % (ffr(self.dictpathout['RData.RData']), ffr(self.ira.RscriptsPath['Rgraph']), ffr(fileout), width, height, svg, type_dendro, bw)
913 elif dendro == 'cloud' :
917 chistable <- chistabletot[1:(debsup-1),]
918 open_file_graph("%s", width=%i, height=%i, svg=%s)
919 plot.dendro.cloud(tree.cut1$tree.cl, classes, chistable, nbbycl = 300, type.dendro="%s", bw=%s, lab=NULL)
920 """ % (ffr(self.dictpathout['RData.RData']), ffr(self.ira.RscriptsPath['Rgraph']), ffr(fileout), width, height, svg, type_dendro, bw)
923 tmpfile = tempfile.mktemp()
924 with open(tmpfile, 'w') as f :
926 error = exec_rcode(self.ira.RPath, tmpfile, wait=True)
927 check_Rresult(self.ira, error)
928 self.list_graph.append([fileout, 'Dendrogramme CHD1 - %s' % type_dendro])
929 print_liste(self.dictpathout['liste_graph_chd'], self.list_graph)
930 if self.param['svg'] :
931 self.sizer_3.Add(hl.HyperLinkCtrl(self.panel_1, -1, fileout, URL=fileout), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
933 self.sizer_3.Add(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(fileout, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
934 self.sizer_3.Add(wx.StaticText(self.panel_1,-1, 'Dendrogramme CHD1 - %s' % type_dendro), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
935 self.sizer_3.Fit(self.panel_1)
937 self.panel_1.Scroll(0,self.panel_1.GetScrollRange(wx.VERTICAL))
940 def ondendro(self, evt):
941 dial = PrefDendro(self.ira, self.param)
942 val = dial.ShowModal()
944 self.make_param(dial)
947 def ondendrotexte(self, evt):
948 dial = PrefDendro(self.ira, self.param)
949 val = dial.ShowModal()
951 self.make_param(dial)
952 self.make_dendro(dendro = 'texte')
954 def ondendrocloud(self, evt):
955 dial = PrefDendro(self.ira, self.param)
956 val = dial.ShowModal()
958 self.make_param(dial)
959 self.make_dendro(dendro = 'cloud')
962 def __init__(self, ira, parametres) :
963 #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)
964 self.panel = CopusPanel(ira, parametres)
965 ira.nb.AddPage(self.panel, 'Description %s' % parametres['corpus_name'])
966 #self.text.write(DoConf().totext(parametres))
967 ira.nb.SetSelection(ira.nb.GetPageCount() - 1)
968 ira.ShowAPane("Tab_content")
971 def __init__(self, ira, matrix):
972 #self.parent.content = self.csvtable
973 self.sheet = MySheet(ira.nb)
974 ira.nb.AddPage(self.sheet, matrix.parametres['matrix_name'])
975 self.sheet.Populate(matrix.csvtable)
976 self.sheet.parametres = matrix.parametres
977 ira.nb.SetSelection(ira.nb.GetPageCount() - 1)
978 ira.ShowAPane("Tab_content")
980 class CopusPanel(wx.Panel) :
981 def __init__(self, parent, parametres) :
982 wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.TAB_TRAVERSAL )
983 self.parametres = parametres
984 fgSizer5 = wx.FlexGridSizer( 0, 2, 0, 0 )
985 fgSizer5.SetFlexibleDirection( wx.BOTH )
986 fgSizer5.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
987 self.fgSizer5 = fgSizer5
989 self.m_staticText18 = wx.StaticText( self, wx.ID_ANY, u"Description du corpus", wx.DefaultPosition, wx.DefaultSize, 0 )
991 self.m_staticText18.Wrap( -1 )
992 fgSizer5.Add( self.m_staticText18, 0, wx.ALL, 5 )
994 self.m_staticText19 = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
995 self.m_staticText19.Wrap( -1 )
996 fgSizer5.Add( self.m_staticText19, 0, wx.ALL, 5 )
998 self.m_staticText20 = wx.StaticText( self, wx.ID_ANY, u"Nom", wx.DefaultPosition, wx.DefaultSize, 0 )
999 self.m_staticText20.Wrap( -1 )
1000 fgSizer5.Add( self.m_staticText20, 0, wx.ALL, 5 )
1002 self.m_staticText21 = wx.StaticText( self, wx.ID_ANY, parametres['corpus_name'], wx.DefaultPosition, wx.DefaultSize, 0 )
1003 self.m_staticText21.Wrap( -1 )
1004 fgSizer5.Add( self.m_staticText21, 0, wx.ALL, 5 )
1006 description = {'lang' : u'langue',
1007 'encoding' : u'encodage',
1008 'ucinb' : u'Nombre de textes',
1009 'ucenb' : u'Nombre de segments de texte',
1010 'formesnb' : u'Nombre de formes',
1011 'hapax' : u'Nombre d\'hapax'
1014 keys = ['lang', 'encoding', 'originalpath', 'pathout', 'date', 'time']
1016 self.addkeys(keys, description)
1018 self.m_staticText18 = wx.StaticText( self, wx.ID_ANY, u"Paramètres", wx.DefaultPosition, wx.DefaultSize, 0 )
1019 self.m_staticText18.Wrap( -1 )
1020 fgSizer5.Add( self.m_staticText18, 0, wx.ALL, 5 )
1022 self.m_staticText19 = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
1023 self.m_staticText19.Wrap( -1 )
1024 fgSizer5.Add( self.m_staticText19, 0, wx.ALL, 5 )
1026 keys = ['ucemethod', 'ucesize', 'keep_caract', 'expressions']
1027 self.addkeys(keys, description)
1029 self.m_staticText18 = wx.StaticText( self, wx.ID_ANY, u"Statistiques", wx.DefaultPosition, wx.DefaultSize, 0 )
1030 self.m_staticText18.Wrap( -1 )
1031 fgSizer5.Add( self.m_staticText18, 0, wx.ALL, 5 )
1033 self.m_staticText19 = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
1034 self.m_staticText19.Wrap( -1 )
1035 fgSizer5.Add( self.m_staticText19, 0, wx.ALL, 5 )
1037 keys = ['ucinb', 'ucenb', 'occurrences', 'formesnb', 'hapax']
1038 self.addkeys(keys, description)
1040 self.SetSizer( fgSizer5 )
1043 def addkeys(self, keys, description) :
1045 option = self.parametres.get(key,u'non défini')
1046 if isinstance(option, int) :
1048 text = wx.StaticText( self, wx.ID_ANY, description.get(key, key), wx.DefaultPosition, wx.DefaultSize, 0 )
1050 self.fgSizer5.Add( text, 0, wx.ALL, 5 )
1052 text = wx.StaticText( self, wx.ID_ANY, option, wx.DefaultPosition, wx.DefaultSize, 0 )
1054 self.fgSizer5.Add( text, 0, wx.ALL, 5 )
1056 class DefaultTextLayout :
1057 def __init__(self, ira, corpus, parametres) :
1058 self.pathout = PathOut(dirout = parametres['pathout'])
1061 self.parametres = parametres
1062 self.corpus = corpus
1065 def dolayout(self) :
1066 log.info('no layout yet')
1068 class WordCloudLayout(DefaultTextLayout):
1070 self.pathout.basefiles(simipath)
1071 self.Tab = aui.AuiNotebook(self.ira.nb, -1, wx.DefaultPosition)
1072 if self.parametres['svg'] :
1073 list_graph = [['nuage_1.svg', 'Nuage']]
1075 list_graph = [['nuage_1.png', 'Nuage']]
1076 self.TabStatTot = GraphPanel(self.ira.nb, self.pathout, list_graph)
1077 self.Tab.AddPage(self.TabStatTot, 'Nuage')
1078 self.Tab.corpus = self.corpus
1079 self.Tab.parametres = self.parametres
1080 self.ira.nb.AddPage(self.Tab, '%s' % self.parametres['name'])
1081 self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
1082 self.ira.ShowAPane("Tab_content")
1084 class SimiLayout(DefaultTextLayout) :
1085 def dolayout(self) :
1086 self.pathout.basefiles(simipath)
1088 self.indices = indices_simi
1089 if os.path.exists(self.pathout['liste_graph']) :
1090 list_graph = read_list_file(self.pathout['liste_graph'])
1092 list_graph = [['','']]
1093 notebook_flags = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_FLOAT
1094 self.tabsimi = aui.AuiNotebook(self.ira.nb, -1, wx.DefaultPosition)
1095 self.tabsimi.SetAGWWindowStyleFlag(notebook_flags)
1096 self.tabsimi.SetArtProvider(aui.ChromeTabArt())
1097 self.tabsimi.corpus = self.corpus
1098 self.tabsimi.parametres = self.parametres
1099 self.graphpan = GraphPanelSimi(self.tabsimi, self.pathout, list_graph)
1100 self.graphpan.Bind(wx.EVT_BUTTON, self.redosimi, self.graphpan.butafc)
1101 self.graphpan.Bind(wx.EVT_BUTTON, self.export, self.graphpan.butexport)
1102 self.tabsimi.AddPage(self.graphpan, 'Graph')
1103 self.ira.nb.AddPage(self.tabsimi, 'Analyse de graph')
1104 self.ira.ShowTab(True)
1105 self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
1107 def redosimi(self, evt) :
1108 with open(self.pathout['selected.csv'],'r') as f :
1110 selected = [int(val) for val in selected.splitlines()]
1111 if self.actives is None :
1112 with codecs.open(self.pathout['actives.csv'], 'r', self.parametres['encoding']) as f :
1113 self.actives = f.read()
1114 self.actives = self.actives.splitlines()#[act for act in self.actives.splitlines()]
1115 if os.path.exists(self.pathout['actives_nb.csv']) :
1116 with open(self.pathout['actives_nb.csv'], 'r') as f :
1118 act_nb = act_nb.splitlines()
1119 dictcol = dict([[i, [self.actives[i], int(act_nb[i])]] for i, val in enumerate(self.actives)])
1121 dictcol = dict([[i, [act, self.corpus.getlemeff(act)]] for i, act in enumerate(self.actives)])
1122 #res = SelectColumn(self.ira, dictcol, self.actives, self.pathout['selected.csv'], selected = selected, dlg = True)
1124 prep = PrepSimi(self.ira, self, self.parametres,self.pathout['selected.csv'], self.actives, indices_simi, wordlist = dictcol, selected = selected)
1125 if prep.val == wx.ID_OK :
1126 self.parametres = prep.parametres
1128 script = PrintSimiScript(self)
1129 script.make_script()
1130 pid = exec_rcode(self.ira.RPath, script.scriptout, wait = True)
1131 check_Rresult(self.ira, pid)
1132 if self.parametres['type_graph'] in [1,3] :
1133 if self.parametres['svg'] :
1134 filename, ext = os.path.splitext(script.filename)
1135 fileout = filename + '.svg'
1136 elif self.parametres['type_graph'] == 3 :
1137 fileout = script.filename
1138 parametres = {'gexffile' : fileout,
1139 'dirout' : os.path.dirname(fileout),
1140 'titre': 'Le titre',
1141 #'nodemin': self.param['txt_min'],
1142 #'nodemax': self.param['txt_max'],
1143 #'bargraphw' : 60*int(self.param['clnb']),
1145 web = WebExport(self.ira, parametres)
1146 fileout = web.exportsimi()
1148 fileout = script.filename
1149 if os.path.exists(self.pathout['liste_graph']):
1150 graph_simi = read_list_file(self.pathout['liste_graph'])
1151 graph_simi.append([os.path.basename(fileout), script.txtgraph])
1153 graph_simi = [[os.path.basename(fileout), script.txtgraph]]
1154 print_liste(self.pathout['liste_graph'], graph_simi)
1155 DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira'])
1156 if self.parametres['type_graph'] in [1,3] :
1157 if self.parametres['svg'] or self.parametres['type_graph'] == 3 :
1158 self.graphpan.sizer_3.Add(hl.HyperLinkCtrl(self.graphpan.panel_1, -1, fileout, URL = fileout), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1160 self.graphpan.sizer_3.Add(wx.StaticBitmap(self.graphpan.panel_1, -1, wx.Bitmap(fileout, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1161 self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1, script.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1162 self.graphpan.sizer_3.Fit(self.graphpan.panel_1)
1163 self.graphpan.Layout()
1164 self.graphpan.panel_1.Scroll(0,self.graphpan.panel_1.GetScrollRange(wx.VERTICAL))
1166 def export(self, evt) :
1168 while os.path.exists(os.path.join(self.pathout.dirout,'graph_'+str(nb)+'.graphml')):
1170 fileout = ffr(os.path.join(self.pathout.dirout,'graph_'+str(nb)+'.graphml'))
1176 graph <- graph.simi$graph
1177 V(graph)$x <- graph.simi$layout[,1]
1178 V(graph)$y <- graph.simi$layout[,2]
1179 if (length(graph.simi$label.cex == 1)) {
1180 V(graph)$weight <- graph.simi$eff
1182 V(graph)$weight <- graph.simi$label.cex
1184 V(graph)$color <- vertex.label.color
1185 V(graph)$frequences <- graph.simi$mat.eff
1186 V(graph)$label <- as.character(graph.simi$v.label)
1187 E(graph)$weight <- graph.simi$we.width
1188 write.graph(graph, fileout, format = 'graphml')
1189 #saveAsGEXF(graph, filepath = fileout)
1190 """ % (self.pathout['RData.RData'], self.parent.RscriptsPath['simi'], fileout)
1191 filetmp = tempfile.mktemp()
1192 with open(filetmp, 'w') as f :
1194 exec_rcode(self.ira.RPath, filetmp)
1195 mss = wx.MessageDialog(self.ira, fileout, u'Fichier exporté', wx.OK)
1196 mss.CenterOnParent()
1200 class DefaultMatLayout :
1201 def __init__(self, parent, tableau, parametres) :
1202 self.pathout = PathOut(dirout = parametres['pathout'])
1204 self.parent = parent
1205 self.tableau = tableau
1206 self.parametres = parametres
1207 if os.path.exists(self.pathout['analyse.db']) :
1208 self.tableau.read_tableau(self.pathout['analyse.db'])
1210 self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
1211 self.ira.ShowAPane("Tab_content")
1213 def dolayout(self) :
1216 class FreqLayout(DefaultMatLayout) :
1217 def dolayout(self) :
1218 self.tab = wx.html.HtmlWindow(self.ira.nb, -1)
1219 res = normpath_win32(self.pathout['resultats.html']).replace('\\','/')
1220 self.tab.LoadPage(res)
1221 self.tab.parametres = self.parametres
1222 self.ira.nb.AddPage(self.tab, u"Fréquences")
1225 class Chi2Layout(DefaultMatLayout) :
1227 self.tab = wx.html.HtmlWindow(self.ira.nb, -1)
1228 if "gtk2" in wx.PlatformInfo:
1229 self.tab.SetStandardFonts()
1230 res = normpath_win32(self.pathout['resultats-chi2.html']).replace('\\','/')
1231 self.tab.LoadPage(res)
1232 self.tab.parametres = self.parametres
1233 self.ira.nb.AddPage(self.tab, ' - '.join([u"Chi2", "%s" % self.parametres['name']]))
1234 #self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
1235 #self.ira.ShowAPane("Tab_content")
1238 class ProtoLayout(DefaultMatLayout) :
1239 def dolayout(self) :
1240 list_graph = [['proto.png', 'Analyse prototypique']]
1241 #self.Tab = aui.AuiNotebook(self.ira.nb, -1, wx.DefaultPosition)
1242 #if self.parametres['svg'] :
1243 # list_graph = [['nuage_1.svg', 'Nuage']]
1245 # list_graph = [['nuage_1.png', 'Nuage']]
1246 self.TabProto = GraphPanel(self.ira.nb, self.pathout, list_graph)
1247 #self.Tab.AddPage(self.TabProto, 'Analyse Prototypique')
1248 #self.Tab.corpus = self.corpus
1249 self.TabProto.parametres = self.parametres
1250 self.ira.nb.AddPage(self.TabProto, 'Analyse Prototypique - %s' % self.parametres['name'])
1251 #self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
1252 #self.ira.ShowAPane("Tab_content")
1255 class SimiMatLayout(DefaultMatLayout) :
1257 self.pathout.basefiles(simipath)
1258 self.indices = indices_simi
1259 if os.path.exists(self.pathout['liste_graph']) :
1260 list_graph = read_list_file(self.pathout['liste_graph'])
1262 list_graph = [['','']]
1263 notebook_flags = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_FLOAT
1264 self.tabsimi = aui.AuiNotebook(self.parent.nb, -1, wx.DefaultPosition)
1265 self.tabsimi.SetAGWWindowStyleFlag(notebook_flags)
1266 self.tabsimi.SetArtProvider(aui.ChromeTabArt())
1267 self.graphpan = GraphPanelSimi(self.tabsimi, self.pathout, list_graph)
1268 self.graphpan.Bind(wx.EVT_BUTTON, self.redosimi, self.graphpan.butafc)
1269 self.graphpan.Bind(wx.EVT_BUTTON, self.export, self.graphpan.butexport)
1270 self.tabsimi.AddPage(self.graphpan, 'Graph')
1271 self.tabsimi.parametres = self.parametres
1272 self.parent.nb.AddPage(self.tabsimi, 'Analyse de graph')
1273 #self.parent.ShowTab(True)
1274 #self.parent.nb.SetSelection(self.parent.nb.GetPageCount() - 1)
1276 def redosimi(self,evt) :
1277 with open(self.pathout['selected.csv'],'r') as f :
1279 selected = [int(val) for val in selected.splitlines()]
1280 #if self.actives is None :
1281 # with codecs.open(self.pathout['actives.csv'], 'r', self.parametres['encoding']) as f :
1282 # self.actives = f.read()
1283 # self.actives = self.actives.splitlines()#[act for act in self.actives.splitlines()]
1285 actives = [[val, self.tableau.actives[val][0]] for val in self.tableau.actives]
1287 actives = [[val, self.tableau.actives[val]] for val in self.tableau.actives]
1289 #self.tableau.make_listactives()
1290 actives = dict([[i, val] for i, val in enumerate(actives)])
1291 #dictcol = dict([[i, [act, self.corpus.getlemeff(act)]] for i, act in enumerate(self.actives)])
1292 self.dial = PrefSimi(self.parent, -1, self.parametres, self.indices, wordlist = actives, selected = selected, actives = self.tableau.listactives)
1293 self.dial.CenterOnParent()
1294 self.val = self.dial.ShowModal()
1295 if self.val == wx.ID_OK :
1296 last = self.dial.listcol.GetFirstSelected()
1297 lastl = [self.dial.listcol.GetFirstSelected()]
1298 indexes = [self.dial.listcol.getColumnText(self.dial.listcol.GetFirstSelected(),0)]
1299 while self.dial.listcol.GetNextSelected(last) != -1:
1300 last = self.dial.listcol.GetNextSelected(last)
1302 indexes.append(self.dial.listcol.getColumnText(last,0))
1303 self.column = [self.tableau.listactives.index(val) for val in indexes]
1305 with open(self.pathout['selected.csv'], 'w') as f :
1306 f.write('\n'.join([`val` for val in self.column]))
1309 self.script = PrintSimiScript(self)
1310 self.script.make_script()
1311 self.tmpfile = self.script.scriptout
1312 dlg = progressbar(self, maxi = 2)
1315 if self.parametres['type_graph'] == 1:
1316 if self.parametres['svg'] :
1317 filename, ext = os.path.splitext(self.script.filename)
1318 fileout = filename + '.svg'
1320 fileout = self.script.filename
1321 fileout = normpath_win32(fileout)
1322 if os.path.exists(self.pathout['liste_graph']):
1323 graph_simi = read_list_file(self.pathout['liste_graph'])
1324 graph_simi.append([os.path.basename(fileout), self.script.txtgraph])
1326 graph_simi = [[os.path.basename(fileout), self.script.txtgraph]]
1327 print_liste(self.pathout['liste_graph'], graph_simi)
1328 DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira'])
1329 if self.parametres['type_graph'] == 1:
1330 if self.parametres['svg'] :
1331 self.graphpan.sizer_3.Add(hl.HyperLinkCtrl(self.graphpan.panel_1, -1, fileout, URL = fileout), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1333 self.graphpan.sizer_3.Add(wx.StaticBitmap(self.graphpan.panel_1, -1, wx.Bitmap(fileout, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1334 self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1, self.script.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1335 self.graphpan.sizer_3.Fit(self.graphpan.panel_1)
1336 self.graphpan.Layout()
1337 self.graphpan.panel_1.Scroll(0,self.graphpan.panel_1.GetScrollRange(wx.VERTICAL))
1342 def make_param(self) :
1343 if self.parametres['first'] :
1346 keep_coord = self.dial.check_coord.GetValue()
1347 #self.select = self.dial.check_colch.GetValue()
1349 paramsimi = {'coeff' : self.dial.choice1.GetSelection(),
1350 'layout' : self.dial.choice2.GetSelection(),
1351 'type_graph' : self.dial.choice3.GetSelection(),
1352 'arbremax' : self.dial.check1.GetValue(),
1353 'coeff_tv' : self.dial.check_s_size.GetValue(),
1354 'coeff_tv_nb' : self.dial.spin_tv.GetValue(),
1355 'tvprop' : self.dial.check2.GetValue(),
1356 'tvmin' : self.dial.spin_tvmin.GetValue(),
1357 'tvmax' : self.dial.spin_tvmax.GetValue(),
1358 'coeff_te' : self.dial.check3.GetValue(),
1359 'coeff_temin' : self.dial.spin_temin.GetValue(),
1360 'coeff_temax' : self.dial.spin_temax.GetValue(),
1361 'label_e' : self.dial.check_elab.GetValue(),
1362 'label_v' : self.dial.check_vlab.GetValue(),
1363 'vcex' : self.dial.check_vcex.GetValue(),
1364 'vcexmin' : self.dial.spin_vcexmin.GetValue(),
1365 'vcexmax' : self.dial.spin_vcexmax.GetValue(),
1366 'cex' : self.dial.spin_cex.GetValue(),
1367 'seuil_ok' : self.dial.check_seuil.GetValue(),
1368 'seuil' : self.dial.spin_seuil.GetValue(),
1369 'cols' : self.dial.cols.GetColour(),
1370 'cola' : self.dial.cola.GetColour(),
1371 'width' : self.dial.spin_width.GetValue(),
1372 'height' : self.dial.spin_height.GetValue(),
1374 'keep_coord' : keep_coord,
1375 'alpha' : self.dial.slider_sphere.GetValue(),
1376 'film' : self.dial.film.GetValue(),
1377 'svg' : self.dial.choix_format.GetSelection(),
1378 'halo' : self.dial.halo.GetValue(),
1379 'com' : self.dial.comcheck.GetValue(),
1380 'communities' : self.dial.choix_com.GetSelection(),
1382 if 'cexfromchi' in self.parametres :
1383 paramsimi['cexfromchi'] = self.dial.checkit.GetValue()
1384 if 'sfromchi' in self.parametres :
1385 paramsimi['sfromchi'] = self.dial.checki.GetValue()
1386 if 'vlabcolor' in self.parametres :
1387 paramsimi['vlabcolor'] = self.parametres['vlabcolor']
1388 if 'check_bystar' in dir(self.dial) :
1389 paramsimi['bystar'] = self.dial.check_bystar.GetValue()
1390 paramsimi['stars'] = self.parametres['stars']
1391 self.parametres.update(paramsimi)
1394 if self.parametres['type_graph'] == 1 :
1400 pid = exec_rcode(self.parent.RPath, self.tmpfile, wait = wait, graph = graph)
1401 if self.parametres['type_graph'] == 1 :
1402 while pid.poll() == None :
1405 check_Rresult(self.parent, pid)
1407 def export(self, evt) :
1409 while os.path.exists(os.path.join(self.pathout.dirout,'graph_'+str(nb)+'.graphml')):
1411 fileout = ffr(os.path.join(self.pathout.dirout,'graph_'+str(nb)+'.graphml'))
1417 graph <- graph.simi$graph
1418 V(graph)$x <- graph.simi$layout[,1]
1419 V(graph)$y <- graph.simi$layout[,2]
1420 if (length(graph.simi$label.cex == 1)) {
1421 V(graph)$weight <- graph.simi$mat.eff
1423 V(graph)$weight <- graph.simi$label.cex
1425 V(graph)$color <- vertex.label.color
1426 V(graph)$frequences <- graph.simi$mat.eff
1427 V(graph)$fprop <- graph.simi$mat.eff/nrow(dm)
1428 V(graph)$label <- as.character(graph.simi$v.label)
1429 E(graph)$weight <- graph.simi$we.width
1430 write.graph(graph, fileout, format = 'graphml')
1431 #saveAsGEXF(graph, filepath = fileout)
1432 """ % (self.pathout['RData.RData'], self.parent.RscriptsPath['simi'], fileout)
1433 filetmp = tempfile.mktemp()
1434 with open(filetmp, 'w') as f :
1436 exec_rcode(self.ira.RPath, filetmp)
1437 mss = wx.MessageDialog(self.ira, fileout, u'Fichier exporté', wx.OK)
1438 mss.CenterOnParent()
1443 class GraphPanelSimi(wx.Panel):
1444 def __init__(self,parent, dico, list_graph):
1445 wx.Panel.__init__(self,parent)
1448 self.dirout = os.path.dirname(self.Dict['ira'])
1449 self.parent = self.GetParent()#parent
1450 self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier"))
1453 self.tabsimi = self.parent.GetParent()
1454 self.ira = self.tabsimi.GetParent()
1455 self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
1456 afc_img = wx.Image(os.path.join(self.ira.images_path,'button_simi.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1457 self.butafc = wx.BitmapButton(self, -1, afc_img)
1458 export_img = wx.Image(os.path.join(self.ira.images_path,'button_export.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1459 self.butexport = wx.BitmapButton(self, -1, export_img)
1460 for i in range(0,len(list_graph)):
1461 if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
1462 filename, ext = os.path.splitext(list_graph[i][0])
1463 if ext in ['.svg', '.html'] :
1464 self.listimg.append(hl.HyperLinkCtrl(self.panel_1, -1, os.path.join(self.dirout,list_graph[i][0]), URL=os.path.join(self.dirout,list_graph[i][0])))
1466 self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
1467 self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1]))
1468 self.panel_1.Bind(wx.EVT_MOTION, self.onMouseMove)
1469 self.__set_properties()
1472 def __set_properties(self):
1473 self.panel_1.EnableScrolling(True,True)
1474 #self.panel_1.SetSize((1000,1000))
1475 self.panel_1.SetScrollRate(20, 20)
1476 self.panel_1.SetFocus()
1478 def __do_layout(self):
1479 self.sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
1480 self.sizer_2 = wx.BoxSizer(wx.VERTICAL)
1481 self.sizer_3 = wx.BoxSizer(wx.VERTICAL)
1482 self.sizer_2.Add(self.butafc, 0, 0, 0)
1483 self.sizer_2.Add(self.butexport, 0, 0, 0)
1484 for i in range(0, len(self.listimg)):
1485 self.sizer_3.Add(self.listimg[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1486 self.sizer_3.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1487 self.panel_1.SetSizer(self.sizer_3)
1488 self.sizer_1.Add(self.sizer_2, 0, wx.EXPAND, 0)
1489 self.sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
1490 self.SetSizer(self.sizer_1)
1492 def onMouseMove(self, event):
1493 self.panel_1.SetFocus()