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 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, check_Rresult, progressbar
14 from ProfList import ProfListctrlPanel
15 from guiparam3d import param3d, simi3d
16 from PrintRScript import write_afc_graph, print_simi3d, PrintSimiScript
17 from profile_segment import ProfileSegment
18 from functions import ReadList
21 from search_tools import SearchFrame
22 from dialog import PrefGraph, PrefExport, PrefSimpleFile, PrefDendro, SimpleDialog
23 from guifunct import SelectColumn, PrepSimi, PrefSimi
24 from webexport import WebExport
25 from corpus import Corpus
26 from sheet import MySheet
30 from time import sleep
35 log = logging.getLogger('iramuteq.layout')
38 class GraphPanelAfc(wx.Panel):
39 def __init__(self, parent, dico, list_graph, clnb, itempath = 'liste_graph_afc', coding = sys.getdefaultencoding()):
40 wx.Panel.__init__(self,parent)
45 self.itempath = itempath
46 self.parent = self.GetParent()#parent
47 self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Arial"))
51 self.list_graph = list_graph
52 self.TabCHD = self.parent.GetParent()
53 self.nb = self.TabCHD.GetParent()
54 self.ira = self.nb.GetParent()
55 self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
56 afc_img = wx.Image(os.path.join(self.ira.images_path,'button_afc.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
57 self.butafc = wx.BitmapButton(self, -1, afc_img)
58 self.Bind(wx.EVT_BUTTON, self.afc_graph, self.butafc)
59 self.dirout = os.path.dirname(self.Dict['ira'])
62 for i in range(0,len(list_graph)):
63 if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
64 filename, ext = os.path.splitext(list_graph[i][0])
65 if ext == '.svg' or ext == '.html':
66 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])))
68 self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
69 if os.path.exists(os.path.join(self.dirout,list_graph[i][0] + '_notplotted.csv')) :
70 txt = _(u"List of not plotted points : ").decode('utf8') + '%s' % os.path.join(self.dirout,list_graph[i][0] + '_notplotted.csv')
73 self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1] + txt))
74 self.buts.append(wx.Button(self.panel_1, wx.ID_DELETE, name = `i - b`))
78 self.list_graph = [graph for i, graph in enumerate(self.list_graph) if i not in todel]
80 self.param = { 'typegraph' : 0,
87 'do_select_chi_classe' : 0,
105 self.__set_properties()
108 def __set_properties(self):
109 self.panel_1.EnableScrolling(True,True)
110 #self.panel_1.SetSize((1000,1000))
111 self.panel_1.SetScrollRate(20, 20)
112 self.panel_1.SetFocus()
114 def __do_layout(self):
115 self.sizer_1 = wx.BoxSizer(wx.VERTICAL)
116 self.sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
117 self.sizer_3 = wx.BoxSizer(wx.VERTICAL)
118 self.sizer_2.Add(self.butafc, 0, 0, 0)
119 for i in range(0, len(self.listimg)):
120 self.sizer_3.Add(self.listimg[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
121 self.sizer_3.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
122 self.sizer_3.Add(self.buts[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
123 self.Bind(wx.EVT_BUTTON, self.on_delete_image, self.buts[i])
124 self.panel_1.SetSizer(self.sizer_3)
125 self.sizer_2.Add(self.panel_1, 1, wx.EXPAND, 0)
126 self.SetSizer(self.sizer_2)
128 def on_delete_image(self, event) :
129 image_id = int(event.GetEventObject().GetName())
130 image_path = self.list_graph[image_id][0]
131 message = _(u'This file will be delete : ') + '%s.\n' % os.path.join(self.dirout, image_path) + _('Are you sure ?')
132 dial = wx.MessageDialog(self, message, style = wx.YES_NO)
133 res = dial.ShowModal()
134 if res == wx.ID_YES :
136 log.info('delete image %i' % image_id)
137 oldimg = self.listimg.pop(image_id)
139 oldlab = self.labels.pop(image_id)
141 oldbut = self.buts.pop(image_id)
143 for i, but in enumerate(self.buts) :
145 todel = self.list_graph.pop(image_id)
146 os.remove(os.path.join(self.dirout, todel[0]))
147 print_liste(self.Dict[self.itempath], self.list_graph)
148 self.sizer_3.Fit(self.panel_1)
154 def afc_graph(self,event):
155 #dirout = os.path.dirname(self.Dict['ira'])
156 dial = PrefGraph(self.parent,-1,self.param,'')
157 dial.CenterOnParent()
158 val = dial.ShowModal()
160 if dial.choix_format.GetSelection() == 0 :
164 typegraph = dial.choicetype.GetSelection()
166 if self.clnb <= 3 and typegraph == 1 :
170 while os.path.exists(os.path.join(self.dirout,'graph_afc_'+str(self.afcnb)+typefile)):
172 self.fileout = ffr(os.path.join(self.dirout,'graph_afc_'+str(self.afcnb)+typefile))
174 self.param = {'typegraph' : typegraph,
175 'width' : dial.spin1.GetValue(),
176 'height' : dial.spin2.GetValue(),
177 'what' : dial.choice1.GetSelection(),
178 'qui' : dial.choice2.GetSelection(),
179 'do_select_nb' : dial.check1.GetValue(),
180 'do_select_chi' : dial.check2.GetValue(),
181 'do_select_chi_classe' : dial.check_chic.GetValue(),
182 'select_nb' : dial.spin_nb.GetValue(),
183 'select_chi' : dial.spin_chi.GetValue(),
184 'nbchic' : dial.spin_nbchic.GetValue(),
185 'over' : dial.check3.GetValue(),
186 'cex_txt' : dial.check4.GetValue(),
187 'txt_min' : dial.spin_min.GetValue(),
188 'txt_max' : dial.spin_max.GetValue(),
189 'tchi' : dial.check_tchi.GetValue(),
190 'tchi_min' : dial.spin_min_tchi.GetValue(),
191 'tchi_max' : dial.spin_max_tchi.GetValue(),
192 'taillecar' : dial.spin3.GetValue(),
193 'facteur' : [dial.spin_f1.GetValue(),dial.spin_f2.GetValue(), dial.spin_f3.GetValue()],
195 'film' : str(dial.film.GetValue()).upper(),
196 'alpha' : dial.slider_sphere.GetValue(),
199 self.nb.parent = self.ira
200 self.DictPathOut = self.Dict
201 self.RscriptsPath = self.ira.RscriptsPath
204 """ % self.DictPathOut['RData']
205 if self.itempath == 'liste_graph_afcf' :
208 afc_table <- afcf_table
209 chistabletot <- specfp
211 elif self.itempath == 'liste_graph_afct' :
214 afc_table <- afct_table
215 chistabletot <- spectp
217 txt += write_afc_graph(self)
218 filetmp = tempfile.mktemp()
219 with open(filetmp, 'w') as f :
221 pid = exec_rcode(self.ira.RPath, filetmp)
222 check_Rresult(self.ira, pid)
223 if self.param['typegraph'] in [0,2] :
225 if self.param['qui'] == 0 : value = u'actives'
226 if self.param['qui'] == 1 : value = u'supplémentaires'
227 if self.param['qui'] == 2 : value = u'étoilées'
228 if self.param['qui'] == 3 : value = u'classes'
230 if self.param['what'] == 0 : value = u'Coordonnées'
231 if self.param['what'] == 1 : value = u'Corrélations'
232 txt += value + u' - facteur %i / %i' % (self.param['facteur'][0], self.param['facteur'][1])
233 if self.param['do_select_nb'] : txt += u' - sélection de %i variables' % self.param['select_nb']
234 if self.param['do_select_chi'] : txt += u' - sélection des variables avec chi2 > %i ' % self.param['select_chi']
235 if self.param['over'] : txt += u' - Eviter les recouvrements'
236 if self.param['cex_txt'] : txt += u' - taille du texte proportionnel à la masse'
237 if self.param['tchi'] : txt += u' - taille du texte proportionnel au chi2 d\'association'
238 #list_graph = read_list_file(self.DictPathOut[self.itempath], self.coding)
239 if self.param['svg'] :
240 filename, ext = os.path.splitext(self.fileout)
241 self.fileout = filename + '.svg'
242 if self.param['typegraph'] == 2 :
243 parametres = {'gexffile' : self.fileout,
245 'nodemin': self.param['txt_min'],
246 'nodemax': self.param['txt_max'],
247 'bargraphw' : 60*int(self.param['clnb']),
249 web = WebExport(self.ira, parametres)
250 self.fileout = web.exportafc()
251 self.list_graph.append([os.path.basename(self.fileout), txt])
252 print_liste(self.DictPathOut[self.itempath], self.list_graph)
253 if self.param['svg'] or self.param['typegraph'] == 2:
254 self.listimg.append(hl.HyperLinkCtrl(self.panel_1, -1, self.fileout, URL=self.fileout))
257 self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(self.fileout, wx.BITMAP_TYPE_ANY)))
258 self.sizer_3.Add( self.listimg[-1], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
259 self.labels.append(wx.StaticText(self.panel_1,-1, txt))
260 self.sizer_3.Add(self.labels[-1], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
261 self.buts.append(wx.Button(self.panel_1, wx.ID_DELETE, name = `len(self.list_graph) - 1`))
262 self.sizer_3.Add(self.buts[-1], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
263 self.sizer_3.Fit(self.panel_1)
266 self.panel_1.Scroll(0,self.panel_1.GetScrollRange(wx.VERTICAL))
267 # elif self.param['typegraph'] == 2 :
268 # parametres = {'gexffile' : self.fileout,
269 # 'titre': 'Le titre',
270 # 'nodemin': self.param['txt_min'],
271 # 'nodemax': self.param['txt_max'],
272 # 'bargraphw' : 60*int(self.param['clnb']),
274 # web = WebExport(self.ira, parametres)
275 # afcout = web.exportafc()
276 # dial = SimpleDialog(self.ira)
277 # dial.link.SetLabel(afcout)
278 # dial.link.SetURL(afcout)
283 class GraphPanel(wx.ScrolledWindow):
284 def __init__(self, parent, dico, list_graph, txt = '', style = wx.TAB_TRAVERSAL):
285 wx.ScrolledWindow.__init__(self, parent, style = style)
289 self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Arial"))
292 self.dirout = os.path.dirname(self.Dict['ira'])
293 self.deb = wx.StaticText(self, -1, txt)
294 for i in range(0,len(list_graph)):
295 if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
296 filename, ext = os.path.splitext(list_graph[i][0])
298 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])))
300 self.listimg.append(wx.StaticBitmap(self, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
301 self.labels.append(wx.StaticText(self, -1, list_graph[i][1]))
302 self.Bind(wx.EVT_MOTION, self.onMouseMove)
303 self.__set_properties()
306 def __set_properties(self):
307 self.EnableScrolling(True,True)
308 self.SetScrollRate(20, 20)
312 def __do_layout(self):
313 self.sizer_1 = wx.BoxSizer(wx.VERTICAL)
314 self.sizer_2 = wx.BoxSizer(wx.VERTICAL)
315 self.sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
316 self.sizer_1.Add(self.deb)
317 for i in range(0, len(self.listimg)):
318 self.sizer_1.Add(self.listimg[i], 1, wx.ALIGN_CENTER_HORIZONTAL, 0)
319 self.sizer_1.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
320 self.sizer_2.Add(self.sizer_1, 1, wx.EXPAND, 0)
321 self.SetSizer(self.sizer_1)
322 self.sizer_1.Fit(self)
324 def onMouseMove(self, event):
328 def open_antiprofil(panel, AntiProfile, encoding) :
329 DictAnti = ReadProfileAsDico(AntiProfile, True, encoding)
330 panel.AntiProfNB = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
331 for i in range(0, panel.parametres['clnb']):
332 tabantiprofile = ProfListctrlPanel(panel, panel, DictAnti[str(i + 1)], True, i + 1)
333 panel.AntiProfNB.AddPage(tabantiprofile, 'classe %s' % str(i + 1))
334 panel.TabChdSim.AddPage(panel.AntiProfNB, _(u"Antiprofiles").decode('utf8'))
338 def getlemgram(corpus, lem) :
339 if not lem[6] in corpus.lems :
342 return corpus.lems[lem[6]].gram
345 def __init__(self, parent, corpus, parametres, Alceste=False):
350 self.parametres = parametres
351 self.pathout = PathOut(parametres['ira'])
352 self.pathout.basefiles(ChdTxtPathOut)
353 DictPathOut = self.pathout
354 self.DictPathOut = DictPathOut
355 self.dictpathout = DictPathOut
358 Profile = DictPathOut['PROFILE_OUT']
359 AntiProfile = DictPathOut['ANTIPRO_OUT']
360 self.encoding = self.parametres['encoding']
361 if isinstance(self.corpus, Corpus) :
362 self.corpus.make_ucecl_from_R(self.pathout['uce'])
363 corpname = self.corpus.parametres['corpus_name']
365 corpname = self.corpus.parametres['matrix_name']
366 if os.path.exists(self.pathout['analyse.db']) :
367 self.corpus.read_tableau(self.pathout['analyse.db'])
369 clnb = parametres['clnb']
370 dlg = progressbar(self, maxi = 4 + clnb)
372 print 'lecture des profils'
373 dlg.Update(2, _(u"Reading profiles").decode('utf8'))
375 DictProfile = ReadProfileAsDico(Profile, Alceste, self.encoding)
376 self.DictProfile = DictProfile
377 self.cluster_size = []
378 #print 'lecture des antiprofils'
379 #DictAnti = ReadProfileAsDico(self, AntiProfile, Alceste, self.encoding)
381 panel = wx.Panel(parent, -1)
382 sizer1 = wx.BoxSizer(wx.VERTICAL)
384 if os.path.exists(DictPathOut['pre_rapport']):
385 with codecs.open(DictPathOut['pre_rapport'], 'r', self.encoding) as f :
390 # panel.chd_toolbar = wx.ToolBar(panel, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER)
391 # panel.chd_toolbar.SetToolBitmapSize(wx.Size(16, 16))
393 if isinstance(self.corpus, Corpus) :
394 panel.corpus = self.corpus
396 panel.tableau = self.corpus
397 #self.parent.tableau = panel.tableau
398 panel.dictpathout = self.DictPathOut
399 panel.pathout = self.DictPathOut
400 panel.parent = self.parent
401 panel.DictProfile = self.DictProfile
402 panel.cluster_size = self.cluster_size
403 panel.debtext = self.debtext
405 # self.ID_rapport = wx.NewId()
406 # #rap_img = wx.Image(os.path.join(self.parent.images_path,'icone_rap_16.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
407 # #panel.chd_toolbar.AddLabelTool(self.ID_rapport, "rapport", rap_img, shortHelp=u"Produire le rapport", longHelp=u"Exporter un rapport en texte simple")
408 # butrap = wx.Button(panel.chd_toolbar, self.ID_rapport, u"Rapport ")
409 # panel.chd_toolbar.AddControl(butrap)
411 # panel.chd_toolbar.Realize()
412 # sizer1.Add(panel.chd_toolbar,0, wx.EXPAND, 5)
414 #self.TabChdSim = wx.aui.AuiNotebook(self.parent.nb, -1, wx.DefaultPosition)
415 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
416 panel.TabChdSim = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
417 panel.TabChdSim.SetAGWWindowStyleFlag(notebook_flags)
418 panel.TabChdSim.SetArtProvider(aui.ChromeTabArt())
419 sizer1.Add(panel.TabChdSim,10, wx.EXPAND, 5)
420 panel.SetSizer(sizer1)
424 if isinstance(self.corpus, Corpus) :
425 panel.TabChdSim.corpus = corpus
426 panel.TabChdSim.corpus.dictpathout = self.DictPathOut
428 panel.TabChdSim.tableau = corpus
429 panel.TabChdSim.tableau.dictpathout = self.DictPathOut
430 panel.parametres = self.parametres
433 self.notenb = self.parent.nb.GetPageCount()
436 if os.path.exists(self.DictPathOut['liste_graph_chd']) :
437 list_graph = read_list_file(self.DictPathOut['liste_graph_chd'], self.encoding)
438 CHD = GraphPanelDendro(panel.TabChdSim, DictPathOut, list_graph, txt = self.debtext)
439 panel.TabChdSim.AddPage(CHD,'CHD')
441 panel.ProfNB = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
442 panel.ProfNB.SetArtProvider(aui.ChromeTabArt())
443 #self.ProfNB.SetTabCtrlHeight(100)
444 #panel.AntiProfNB = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
445 if os.path.exists(DictPathOut['prof_seg']) :
446 prof_seg = ReadProfileAsDico(DictPathOut['prof_seg'], False, self.encoding)
447 self.prof_seg_nb = aui.AuiNotebook(panel, -1, wx.DefaultPosition)
448 for i in range(0, clnb):
449 self.cluster_size.append(DictProfile[str(i + 1)][0][0:3])
450 if isinstance(self.corpus, Corpus) :
451 DictProfile[str(i + 1)][1:] = [val[0:5] + [getlemgram(self.corpus, val)] + val[6:] for val in DictProfile[str(i + 1)][1:]]
452 dlg.Update(3+i, 'Classe %i' %(i+1))
453 ind = '/'.join(DictProfile[str(i + 1)][0][0:2])
454 indpour = ' - '.join([ind, DictProfile[str(i + 1)][0][2]])
455 self.tabprofile = ProfListctrlPanel(self.parent, self.panel, DictProfile[str(i + 1)], Alceste, i + 1)
456 #self.tabantiprofile = ProfListctrlPanel(self.parent, self, DictAnti[str(i + 1)], Alceste, i + 1)
457 panel.ProfNB.AddPage(self.tabprofile, _(u"Cluster").decode('utf8') + ' %s %s(%s%%)' % (str(i + 1), sep, indpour))
458 #panel.AntiProfNB.AddPage(self.tabantiprofile, 'classe %s' % str(i + 1))
459 if os.path.exists(DictPathOut['prof_seg']) :
460 self.tab_prof_seg = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
461 self.prof_seg_nb.AddPage(self.tab_prof_seg, _(u"Cluster").decode('utf8') + ' %i' % (i + 1))
464 self.TabAFC = aui.AuiNotebook(panel.TabChdSim, -1, wx.DefaultPosition)
466 list_graph=read_list_file(DictPathOut['liste_graph_afc'], self.encoding)
467 self.tabAFCGraph = GraphPanelAfc(self.TabAFC, DictPathOut, list_graph, self.clnb, coding=self.encoding)
468 self.TabAFC.AddPage(self.tabAFCGraph, _(u"CA").decode('utf8'))
470 if os.path.exists(self.DictPathOut['afc_facteur']) :
471 dictrow, first = ReadList(self.DictPathOut['afc_facteur'], self.encoding)
472 self.TabAFC_facteur = ListForSpec(self.parent, parametres, dictrow, first)
473 #dictrow, first = ReadList(self.DictPathOut['afc_row'], self.encoding)
474 #self.TabAFC_ligne = ListForSpec(self.parent, self.parametres, dictrow, first)
475 #dictrow, first = ReadList(self.DictPathOut['afc_col'], self.encoding)
476 #self.TabAFC_colonne = ListForSpec(parent, self.parametres, dictrow, first)
477 self.TabAFC.AddPage(self.TabAFC_facteur, _(u"Factor").decode('utf8'))
478 #self.TabAFC.AddPage(self.TabAFC_colonne, u'Colonnes')
479 #self.TabAFC.AddPage(self.TabAFC_ligne, u'Lignes')
481 sizer_3 = wx.BoxSizer(wx.VERTICAL)
482 self.parent.nb_panel_2 = wx.Panel(panel.TabChdSim, -1)
483 self.parent.button_simi = wx.Button(self.parent.nb_panel_2, -1, "Voyager")
484 self.parent.simi3dpanel = simi3d(self.parent.nb_panel_2, -1)
485 sizer_3.Add(self.parent.simi3dpanel, 1, wx.EXPAND, 0)
486 sizer_3.Add(self.parent.button_simi, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
487 self.parent.nb_panel_2.SetSizer(sizer_3)
488 self.TabAFC.AddPage(self.parent.nb_panel_2, _(u"3D graph").decode('utf8'))
489 self.parent.Bind(wx.EVT_BUTTON, self.onsimi, self.parent.button_simi)
491 panel.TabChdSim.AddPage(panel.ProfNB, _(u"Profiles").decode('utf8'))
492 #panel.TabChdSim.AddPage(panel.AntiProfNB, 'Antiprofils')
493 dlg.Update(4 + self.clnb, 'Affichage...')
495 panel.TabChdSim.AddPage(self.TabAFC, _(u"CA").decode('utf8'))
496 if os.path.exists(DictPathOut['prof_seg']) :
497 panel.TabChdSim.AddPage(self.prof_seg_nb, _(u"Repeated segments profiles").decode('utf8'))
499 # panel.Bind(wx.EVT_BUTTON, self.ongetrapport, id = self.ID_rapport)
500 self.parent.nb.AddPage(panel, _(u"Clustering").decode('utf8') + ' - %s' % corpname)
501 self.parent.ShowTab(True)
502 self.parent.nb.SetSelection(self.parent.nb.GetPageCount() - 1)
503 #for pane in self.parent._mgr.GetAllPanes() :
504 # if isinstance(pane.window, aui.AuiNotebook):
506 # nb.SetAGWWindowStyleFlag(notebook_flags)
507 # nb.SetArtProvider(aui.ChromeTabArt())
509 self.parent._mgr.Update()
511 def onsimi(self,event):
512 outfile = print_simi3d(self)
513 error = exec_rcode(self.parent.RPath, outfile, wait = True)
515 def onclusterstat(self, evt) :
516 dial = PrefSimpleFile(self, self.parent, **{'mask' : '*.csv', 'title': 'Stat par classe'})
517 dial.fbb.SetValue( os.path.join(os.path.dirname(self.corpus.dictpathout['ira']), 'stat_par_classe.csv'))
518 dial.CenterOnParent()
519 res = dial.ShowModal()
521 fileout = dial.fbb.GetValue()
523 self.corpus.get_stat_by_cluster(fileout)
525 dlg = wx.MessageDialog(self.parent, msg, _(u"Stat by cluster").decode('utf8'), wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION)
527 if dlg.ShowModal() == wx.ID_OK :
530 #def onsearchf(self, evt) :
531 # if 'FrameSearch' not in dir(self.panel) :
532 # self.panel.FrameSearch = SearchFrame(self.parent, -1, u"Rechercher...", self.corpus)
533 # self.panel.FrameSearch.Show()
535 def PrintRapport(self, corpus, parametres, istxt = True):
539 |i|R|a|M|u|T|e|Q| - %s
543 """ % datetime.datetime.now().ctime()
545 totocc = corpus.gettotocc()
546 txt += u'nombre de textes: %i%s' % (corpus.getucinb(), sep)
547 txt += u'nombre de segments de textes: %i%s' % (corpus.getucenb(), sep)
548 txt += u'nombre de formes: %i%s' % (len(corpus.formes), sep)
549 txt += u'nombre d\'occurrences: %i%s' % (totocc, sep)
550 txt += u'moyenne d\'occurrences par forme: %f%s' % (float(totocc) / float(len(self.corpus.formes)), sep)
551 txt += u'nombre de lemmes: %i%s' % (len(corpus.lems), sep)
552 txt += u'nombre de formes actives: %i%s' % (corpus.getactivesnb(1), sep)
553 txt += u'nombre de formes supplémentaires: %i%s' % (corpus.getactivesnb(2), sep)
554 txt += u'nombre de formes actives de fréquence >= %i: %i%s' % (parametres['eff_min_forme'], parametres['nbactives'], sep)
555 txt += u'moyenne d\'occurrences par segments :%f%s' % (float(totocc) / float(corpus.getucenb()), sep)
556 if 'tailleuc1' in parametres :
557 if parametres['classif_mode'] == 0 :
558 txt += u'taille rst1 / rst2: %i / %i - %i / %i%s' % (parametres['tailleuc1'], parametres['tailleuc2'], parametres['lenuc1'], parametres['lenuc2'], sep)
560 self.Ucenb = self.nbind
561 txt += u'nombre d\'individus : %i%s' % (self.nbind, sep)
562 txt += u'nombre de classes : %i%s' % (self.clnb, sep)
564 txt += u'nombre de classes : %i%s' % (parametres['clnb'], sep)
565 if parametres['classif_mode'] == 0 or parametres['classif_mode'] == 1 :
566 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)
567 elif self.parametres['classif_mode'] == 2 :
568 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)
570 txt += u'%i segments classées sur %i (%.2f%%)%s' % (self.ucecla, self.Ucenb, (float(self.ucecla) / float(self.Ucenb)) * 100, sep)
573 ###########################
575 ###########################
576 """ % parametres.get('time', '')
577 with open(self.pathout['pre_rapport'], 'w') as f :
581 class SashList(wx.Panel) :
582 def __init__(self, parent) :
583 wx.Panel.__init__(self, parent, -1)
586 #self.gparent=gparent
590 # A window to the left of the client window
591 #self.listlex = listlex
592 self.leftwin1 = wx.SashLayoutWindow(
593 self, -1, wx.DefaultPosition, (200, 300),
594 wx.NO_BORDER|wx.SW_3D
597 self.leftwin1.SetDefaultSize((120, 1000))
598 self.leftwin1.SetOrientation(wx.LAYOUT_VERTICAL)
599 self.leftwin1.SetAlignment(wx.LAYOUT_LEFT)
600 self.leftwin1.SetBackgroundColour(wx.Colour(0, 255, 0))
601 self.leftwin1.SetSashVisible(wx.SASH_RIGHT, True)
602 self.leftwin1.SetExtraBorderSize(10)
604 #textWindow = wx.TextCtrl(
605 # leftwin1, -1, "", wx.DefaultPosition, wx.DefaultSize,
606 # wx.TE_MULTILINE|wx.SUNKEN_BORDER
609 #textWindow.SetValue("A sub window")
611 self.leftWindow1 = self.leftwin1
612 winids.append(self.leftwin1.GetId())
614 rightwin1 = wx.SashLayoutWindow(
615 self, -1, wx.DefaultPosition, (200, 300),
616 wx.NO_BORDER|wx.SW_3D
619 rightwin1.SetDefaultSize((120, 1000))
620 rightwin1.SetOrientation(wx.LAYOUT_VERTICAL)
621 rightwin1.SetAlignment(wx.LAYOUT_LEFT)
622 rightwin1.SetBackgroundColour(wx.Colour(0, 255, 0))
623 rightwin1.SetSashVisible(wx.SASH_RIGHT, True)
624 rightwin1.SetExtraBorderSize(10)
625 #textWindow = wx.TextCtrl(
626 # leftwin1, -1, "", wx.DefaultPosition, wx.DefaultSize,
627 # wx.TE_MULTILINE|wx.SUNKEN_BORDER
630 #textWindow.SetValue("A sub window")
632 self.rightwin1 = rightwin1
633 winids.append(rightwin1.GetId())
636 def __init__(self, page):
638 parametres = self.page.parametres
639 ira = wx.GetApp().GetTopWindow()
640 self.page.tgens, etoiles = ReadList(parametres['tgenspec'], ira.syscoding, sep="\t")
642 for i in range(page.GetPageCount()) :
643 tab = page.GetPage(i)
644 if 'tgen' in dir(tab) :
649 self.page.tgentab.RefreshData(self.page.tgens)
650 self.page.SetSelection(i)
652 self.page.tgentab = ListForSpec(ira, None, self.page.tgens, etoiles[1:])
653 self.page.tgentab.tgen = True
654 self.page.AddPage(self.page.tgentab, u'Tgens Specificities')
655 self.page.SetSelection(self.page.GetPageCount() - 1)
658 def __init__(self, ira, corpus, parametres):
659 self.pathout = PathOut(dirout = parametres['pathout'])
661 self.dictpathout = StatTxtPathOut(parametres['pathout'])
662 #self.corpus.read_corpus_from_shelves(self.corpus.dictpathout['db'])
664 self.encoding = self.corpus.parametres['syscoding']
665 self.parametres = parametres
667 self.DictSpec, first = ReadList(self.dictpathout['tablespecf'], self.corpus.parametres['syscoding'])
668 if os.path.exists(self.pathout['banalites.csv']) :
669 self.dictban, firstban = ReadList(self.pathout['banalites.csv'], self.corpus.parametres['syscoding'])
670 self.DictType, firstt = ReadList(self.dictpathout['tablespect'], self.corpus.parametres['syscoding'])
671 self.DictEff, firsteff = ReadList(self.dictpathout['tableafcm'], self.corpus.parametres['syscoding'])
672 self.DictEffType, firstefft = ReadList(self.dictpathout['tabletypem'], self.corpus.parametres['syscoding'])
673 self.DictEffRelForme, firsteffrelf = ReadList(self.dictpathout['eff_relatif_forme'], self.corpus.parametres['syscoding'])
674 self.DictEffRelType, firsteffrelt = ReadList(self.dictpathout['eff_relatif_type'], self.corpus.parametres['syscoding'])
675 self.etoiles = firsteff[1:]
676 #sash = SashList(ira.nb)
679 self.TabStat = aui.AuiNotebook(ira.nb, -1, wx.DefaultPosition)
680 self.TabStat.parametres = parametres
681 self.ListPan = ListForSpec(ira, self, self.DictSpec, self.etoiles)
682 if os.path.exists(self.pathout['banalites.csv']) :
683 self.listban = ListForSpec(ira, self, self.dictban, ['eff'] + self.etoiles)
684 #self.ListPan2 = ListForSpec(sash.rightwin1, self, self.DictSpec, first)
685 self.ListPant = ListForSpec(ira, self, self.DictType, self.etoiles)
686 self.ListPanEff = ListForSpec(ira, self, self.DictEff, self.etoiles)
687 self.ListPanEffType = ListForSpec(ira, self, self.DictEffType, self.etoiles)
688 self.ListPanEffRelForme = ListForSpec(ira, self, self.DictEffRelForme, self.etoiles)
689 self.ListPanEffRelType = ListForSpec(ira, self.parent, self.DictEffRelType, self.etoiles)
691 self.TabStat.AddPage(self.ListPan, u'formes')
692 if os.path.exists(self.pathout['banalites.csv']) :
693 self.TabStat.AddPage(self.listban, u'banalités')
694 self.TabStat.AddPage(self.ListPant, u'Types')
695 self.TabStat.AddPage(self.ListPanEff, u'Effectifs formes')
696 self.TabStat.AddPage(self.ListPanEffType, u'Effectifs Type')
697 self.TabStat.AddPage(self.ListPanEffRelForme, u'Effectifs relatifs formes')
698 self.TabStat.AddPage(self.ListPanEffRelType, u'Effectifs relatifs Type')
699 if self.parametres['clnb'] > 2 :
700 self.TabAFC = aui.AuiNotebook(self.TabStat, -1, wx.DefaultPosition)
701 list_graph=read_list_file(self.dictpathout['liste_graph_afcf'], encoding = self.encoding)
702 self.tabAFCGraph = GraphPanelAfc(self.TabAFC, self.dictpathout, list_graph, self.parametres['clnb'], itempath ='liste_graph_afcf', coding = self.encoding)
703 self.TabAFC.AddPage(self.tabAFCGraph, 'AFC formes')
704 list_graph=read_list_file(self.dictpathout['liste_graph_afct'], encoding = self.encoding)
705 self.tabAFCTGraph = GraphPanelAfc(self.TabAFC, self.dictpathout, list_graph, self.parametres['clnb'], itempath ='liste_graph_afct', coding=self.encoding)
706 self.TabAFC.AddPage(self.tabAFCTGraph, 'AFC type')
707 self.TabStat.AddPage(self.TabAFC, 'AFC')
713 ira.nb.AddPage(self.TabStat, u'Spécificités')
716 self.TabStat.corpus = self.corpus
717 self.TabStat.etoiles = self.etoiles
718 if os.path.exists(os.path.join(self.parametres['pathout'], 'tgenspec.csv')) :
719 self.parametres['tgenspec'] = os.path.join(self.parametres['pathout'], 'tgenspec.csv')
720 TgenLayout(self.TabStat)
721 self.TabStat.SetSelection(0)
722 ira.nb.SetSelection(self.parent.nb.GetPageCount() - 1)
723 ira.ShowAPane("Tab_content")
726 def __init__(self, ira, corpus, parametres):
727 self.pathout = PathOut(dirout = parametres['pathout'])
731 self.TabStat = aui.AuiNotebook(ira.nb, -1, wx.DefaultPosition)
732 self.TabStat.parametres = parametres
733 self.TabStat.corpus = corpus
734 self.TabStat.pathout = self.pathout
735 # CHD = GraphPanel(panel.TabChdSim, DictPathOut, list_graph, txt = self.debtext)
736 # panel.TabChdSim.AddPage(CHD,'CHD')
738 #self.TabStatTot = wx.TextCtrl(self.TabStat, -1, style=wx.NO_BORDER | wx.TE_MULTILINE | wx.TE_RICH2)
739 list_graph = [['zipf.png', 'zipf']]
740 self.TabStatTot = GraphPanel(ira.nb, self.pathout, list_graph, self.result['glob'])
741 self.TabStat.AddPage(self.TabStatTot, 'global')
742 for item in self.result:
744 datam = [['forme', 'nb']]
745 self.ListPan = ListPanel(ira, self, self.result[item])
746 self.TabStat.AddPage(self.ListPan, ' '.join(item.split('_')))
747 ira.nb.AddPage(self.TabStat, '%s' % parametres['name'])
748 ira.nb.SetSelection(ira.nb.GetPageCount() - 1)
749 ira.ShowAPane("Tab_content")
751 def read_result(self) :
752 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'}
755 with open(self.pathout[lcle[key]], 'r') as f :
756 self.result[key] = [line.split(';') for line in f.read().splitlines()]
757 self.result[key] = dict([[i,[line[0],int(line[1]), line[2]]] for i, line in enumerate(self.result[key])])
758 with open(self.pathout['glob.txt'], 'r') as f :
759 self.result['glob'] = f.read()
761 class GraphPanelDendro(wx.Panel):
762 def __init__(self,parent, dico, list_graph, txt=False):
763 wx.Panel.__init__(self,parent)
765 self.dictpathout = dico
766 self.dirout = os.path.dirname(self.dictpathout['ira'])
767 self.list_graph = list_graph
768 self.parent = self.GetParent()#parent
769 self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Arial"))
772 self.tabchd = self.parent.GetParent()
773 self.ira = self.tabchd.GetParent()
774 self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
775 self.panel_1.SetBackgroundColour('white')
776 self.deb = wx.StaticText(self.panel_1, -1, txt)
777 dendro_img = wx.Image(os.path.join(self.ira.images_path,'but_dendro.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
778 self.butdendro = wx.BitmapButton(self, -1, dendro_img)
779 self.butdendrotexte = wx.BitmapButton(self, -1, dendro_img)
780 self.butdendrocloud = wx.BitmapButton(self, -1, dendro_img)
782 for i in range(0,len(list_graph)):
783 if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
784 self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
785 self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1]))
787 self.__set_properties()
790 def __set_properties(self):
791 self.panel_1.EnableScrolling(True,True)
792 #self.panel_1.SetSize((1000,1000))
793 self.panel_1.SetScrollRate(20, 20)
794 self.panel_1.SetFocus()
795 self.Bind(wx.EVT_BUTTON, self.ondendro, self.butdendro)
796 self.Bind(wx.EVT_BUTTON, self.ondendrotexte, self.butdendrotexte)
797 self.Bind(wx.EVT_BUTTON, self.ondendrocloud, self.butdendrocloud)
798 self.param = {'width' : 700,
802 'taille_classe' : True,
805 self.type_dendro = [ u"phylogram", u"cladogram", u"fan", u"unrooted", u"radial" ]
807 def __do_layout(self):
808 self.sizer_1 = wx.BoxSizer(wx.VERTICAL)
809 self.sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
810 self.sizer_3 = wx.BoxSizer(wx.VERTICAL)
811 self.sizer_3.Add(self.deb)
812 self.sizer_1.Add(self.butdendro, 0, 0, 0)
813 self.sizer_1.Add(self.butdendrotexte, 0, 0, 0)
814 self.sizer_1.Add(self.butdendrocloud, 0, 0, 0)
816 for i in range(0, len(self.listimg)):
817 self.sizer_3.Add(self.listimg[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
818 self.sizer_3.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
819 self.panel_1.SetSizer(self.sizer_3)
820 self.sizer_2.Add(self.sizer_1, 0, wx.EXPAND, 0)
821 self.sizer_2.Add(self.panel_1, 1, wx.EXPAND, 0)
822 self.SetSizer(self.sizer_2)
824 def make_param(self, dial):
825 self.param['width'] = dial.m_spinCtrl2.GetValue()
826 self.param['height'] = dial.m_spinCtrl1.GetValue()
827 self.param['type_dendro'] = dial.m_choice1.GetSelection()
828 self.param['color_nb'] = dial.m_radioBox1.GetSelection()
829 self.param['taille_classe'] = dial.m_checkBox1.GetValue()
830 self.param['type_tclasse'] = dial.m_radioBox2.GetSelection()
832 def make_dendro(self, dendro = 'simple') :
833 while os.path.exists(os.path.join(self.dirout, 'dendrogramme_' + str(self.graphnb)+'.png')) :
835 fileout = ffr(os.path.join(self.dirout,'dendrogramme_' + str(self.graphnb)+'.png'))
836 width = self.param['width']
837 height = self.param['height']
838 type_dendro = self.type_dendro[self.param['type_dendro']]
839 if self.param['taille_classe'] :
843 if self.param['color_nb'] == 0 :
847 if self.param['type_tclasse'] == 0 :
851 dendro_path = self.dictpathout['Rdendro']
852 classe_path = self.dictpathout['uce']
857 classes <- read.csv2("%s", row.names=1)
858 classes <- classes[,1]
859 """ % (ffr(dendro_path), ffr(self.ira.RscriptsPath['Rgraph']), ffr(classe_path))
860 if dendro == 'simple' :
862 open_file_graph("%s", width=%i, height=%i)
863 plot.dendropr(tree.cut1$tree.cl, classes, type.dendro="%s", histo=%s, bw=%s, lab=NULL, tclasse=%s)
864 """ % (ffr(fileout), width, height, type_dendro, histo, bw, tclasse)
865 elif dendro == 'texte' :
869 chistable <- chistabletot[1:(debsup-1),]
870 open_file_graph("%s", width=%i, height=%i)
871 plot.dendro.prof(tree.cut1$tree.cl, classes, chistable, nbbycl = 60, type.dendro="%s", bw=%s, lab=NULL)
872 """ % (ffr(self.dictpathout['RData.RData']), ffr(self.ira.RscriptsPath['Rgraph']), ffr(fileout), width, height, type_dendro, bw)
873 elif dendro == 'cloud' :
877 chistable <- chistabletot[1:(debsup-1),]
878 open_file_graph("%s", width=%i, height=%i)
879 plot.dendro.cloud(tree.cut1$tree.cl, classes, chistable, nbbycl = 300, type.dendro="%s", bw=%s, lab=NULL)
880 """ % (ffr(self.dictpathout['RData.RData']), ffr(self.ira.RscriptsPath['Rgraph']), ffr(fileout), width, height, type_dendro, bw)
883 tmpfile = tempfile.mktemp()
884 with open(tmpfile, 'w') as f :
886 error = exec_rcode(self.ira.RPath, tmpfile, wait=True)
887 check_Rresult(self.ira, error)
888 self.list_graph.append([fileout, 'Dendrogramme CHD1 - %s' % type_dendro])
889 print_liste(self.dictpathout['liste_graph_chd'], self.list_graph)
890 self.sizer_3.Add(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(fileout, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
891 self.sizer_3.Add(wx.StaticText(self.panel_1,-1, 'Dendrogramme CHD1 - %s' % type_dendro), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
892 self.sizer_3.Fit(self.panel_1)
894 self.panel_1.Scroll(0,self.panel_1.GetScrollRange(wx.VERTICAL))
897 def ondendro(self, evt):
898 dial = PrefDendro(self.ira, self.param)
899 val = dial.ShowModal()
901 self.make_param(dial)
904 def ondendrotexte(self, evt):
905 dial = PrefDendro(self.ira, self.param)
906 val = dial.ShowModal()
908 self.make_param(dial)
909 self.make_dendro(dendro = 'texte')
911 def ondendrocloud(self, evt):
912 dial = PrefDendro(self.ira, self.param)
913 val = dial.ShowModal()
915 self.make_param(dial)
916 self.make_dendro(dendro = 'cloud')
919 def __init__(self, ira, parametres) :
920 #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)
921 self.panel = CopusPanel(ira, parametres)
922 ira.nb.AddPage(self.panel, 'Description %s' % parametres['corpus_name'])
923 #self.text.write(DoConf().totext(parametres))
924 ira.nb.SetSelection(ira.nb.GetPageCount() - 1)
925 ira.ShowAPane("Tab_content")
928 def __init__(self, ira, matrix):
929 #self.parent.content = self.csvtable
930 self.sheet = MySheet(ira.nb)
931 ira.nb.AddPage(self.sheet, matrix.parametres['matrix_name'])
932 self.sheet.Populate(matrix.csvtable)
933 self.sheet.parametres = matrix.parametres
934 #self.ira.ShowMenu(_(u"View").decode('utf8'))
935 #self.ira.ShowMenu(_(u"Matrix analysis").decode('utf8'))
936 #self.ira.ShowMenu(_(u"Text analysis").decode('utf8'), False)
937 #self.parent.type = "Data"
938 #self.parent.DataPop = False
939 ira.nb.SetSelection(ira.nb.GetPageCount() - 1)
940 ira.ShowAPane("Tab_content")
941 #self.ira.OnViewData('')
946 class CopusPanel(wx.Panel) :
947 def __init__(self, parent, parametres) :
948 wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.TAB_TRAVERSAL )
949 self.parametres = parametres
950 fgSizer5 = wx.FlexGridSizer( 0, 2, 0, 0 )
951 fgSizer5.SetFlexibleDirection( wx.BOTH )
952 fgSizer5.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
953 self.fgSizer5 = fgSizer5
955 self.m_staticText18 = wx.StaticText( self, wx.ID_ANY, u"Description du corpus", wx.DefaultPosition, wx.DefaultSize, 0 )
957 self.m_staticText18.Wrap( -1 )
958 fgSizer5.Add( self.m_staticText18, 0, wx.ALL, 5 )
960 self.m_staticText19 = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
961 self.m_staticText19.Wrap( -1 )
962 fgSizer5.Add( self.m_staticText19, 0, wx.ALL, 5 )
964 self.m_staticText20 = wx.StaticText( self, wx.ID_ANY, u"Nom", wx.DefaultPosition, wx.DefaultSize, 0 )
965 self.m_staticText20.Wrap( -1 )
966 fgSizer5.Add( self.m_staticText20, 0, wx.ALL, 5 )
968 self.m_staticText21 = wx.StaticText( self, wx.ID_ANY, parametres['corpus_name'], wx.DefaultPosition, wx.DefaultSize, 0 )
969 self.m_staticText21.Wrap( -1 )
970 fgSizer5.Add( self.m_staticText21, 0, wx.ALL, 5 )
972 description = {'lang' : u'langue',
973 'encoding' : u'encodage',
974 'ucinb' : u'Nombre de textes',
975 'ucenb' : u'Nombre de segments de texte',
976 'formesnb' : u'Nombre de formes',
977 'hapax' : u'Nombre d\'hapax'
980 keys = ['lang', 'encoding', 'originalpath', 'pathout', 'date', 'time']
982 self.addkeys(keys, description)
984 self.m_staticText18 = wx.StaticText( self, wx.ID_ANY, u"Paramètres", wx.DefaultPosition, wx.DefaultSize, 0 )
985 self.m_staticText18.Wrap( -1 )
986 fgSizer5.Add( self.m_staticText18, 0, wx.ALL, 5 )
988 self.m_staticText19 = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
989 self.m_staticText19.Wrap( -1 )
990 fgSizer5.Add( self.m_staticText19, 0, wx.ALL, 5 )
992 keys = ['ucemethod', 'ucesize', 'keep_caract', 'expressions']
993 self.addkeys(keys, description)
995 self.m_staticText18 = wx.StaticText( self, wx.ID_ANY, u"Statistiques", wx.DefaultPosition, wx.DefaultSize, 0 )
996 self.m_staticText18.Wrap( -1 )
997 fgSizer5.Add( self.m_staticText18, 0, wx.ALL, 5 )
999 self.m_staticText19 = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
1000 self.m_staticText19.Wrap( -1 )
1001 fgSizer5.Add( self.m_staticText19, 0, wx.ALL, 5 )
1003 keys = ['ucinb', 'ucenb', 'occurrences', 'formesnb', 'hapax']
1004 self.addkeys(keys, description)
1006 self.SetSizer( fgSizer5 )
1009 def addkeys(self, keys, description) :
1011 option = self.parametres.get(key,u'non défini')
1012 if isinstance(option, int) :
1014 text = wx.StaticText( self, wx.ID_ANY, description.get(key, key), wx.DefaultPosition, wx.DefaultSize, 0 )
1016 self.fgSizer5.Add( text, 0, wx.ALL, 5 )
1018 text = wx.StaticText( self, wx.ID_ANY, option, wx.DefaultPosition, wx.DefaultSize, 0 )
1020 self.fgSizer5.Add( text, 0, wx.ALL, 5 )
1022 class DefaultTextLayout :
1023 def __init__(self, ira, corpus, parametres) :
1024 self.pathout = PathOut(dirout = parametres['pathout'])
1027 self.parametres = parametres
1028 self.corpus = corpus
1031 def dolayout(self) :
1032 log.info('no layout yet')
1034 class WordCloudLayout(DefaultTextLayout):
1036 self.pathout.basefiles(simipath)
1037 self.Tab = aui.AuiNotebook(self.ira.nb, -1, wx.DefaultPosition)
1038 if self.parametres['svg'] :
1039 list_graph = [['nuage_1.svg', 'Nuage']]
1041 list_graph = [['nuage_1.png', 'Nuage']]
1042 self.TabStatTot = GraphPanel(self.ira.nb, self.pathout, list_graph)
1043 self.Tab.AddPage(self.TabStatTot, 'Nuage')
1044 self.Tab.corpus = self.corpus
1045 self.Tab.parametres = self.parametres
1046 self.ira.nb.AddPage(self.Tab, '%s' % self.parametres['name'])
1047 self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
1048 self.ira.ShowAPane("Tab_content")
1050 class SimiLayout(DefaultTextLayout) :
1051 def dolayout(self) :
1052 self.pathout.basefiles(simipath)
1054 self.indices = indices_simi
1055 if os.path.exists(self.pathout['liste_graph']) :
1056 list_graph = read_list_file(self.pathout['liste_graph'])
1058 list_graph = [['','']]
1059 notebook_flags = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_FLOAT
1060 self.tabsimi = aui.AuiNotebook(self.ira.nb, -1, wx.DefaultPosition)
1061 self.tabsimi.SetAGWWindowStyleFlag(notebook_flags)
1062 self.tabsimi.SetArtProvider(aui.ChromeTabArt())
1063 self.tabsimi.corpus = self.corpus
1064 self.tabsimi.parametres = self.parametres
1065 self.graphpan = GraphPanelSimi(self.tabsimi, self.pathout, list_graph)
1066 self.graphpan.Bind(wx.EVT_BUTTON, self.redosimi, self.graphpan.butafc)
1067 self.graphpan.Bind(wx.EVT_BUTTON, self.export, self.graphpan.butexport)
1068 self.tabsimi.AddPage(self.graphpan, 'Graph')
1069 self.ira.nb.AddPage(self.tabsimi, 'Analyse de graph')
1070 self.ira.ShowTab(True)
1071 self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
1073 def redosimi(self, evt) :
1074 with open(self.pathout['selected.csv'],'r') as f :
1076 selected = [int(val) for val in selected.splitlines()]
1077 if self.actives is None :
1078 with codecs.open(self.pathout['actives.csv'], 'r', self.parametres['encoding']) as f :
1079 self.actives = f.read()
1080 self.actives = self.actives.splitlines()#[act for act in self.actives.splitlines()]
1081 if os.path.exists(self.pathout['actives_nb.csv']) :
1082 with open(self.pathout['actives_nb.csv'], 'r') as f :
1084 act_nb = act_nb.splitlines()
1085 dictcol = dict([[i, [self.actives[i], int(act_nb[i])]] for i, val in enumerate(self.actives)])
1087 dictcol = dict([[i, [act, self.corpus.getlemeff(act)]] for i, act in enumerate(self.actives)])
1088 #res = SelectColumn(self.ira, dictcol, self.actives, self.pathout['selected.csv'], selected = selected, dlg = True)
1090 prep = PrepSimi(self.ira, self, self.parametres,self.pathout['selected.csv'], self.actives, indices_simi, wordlist = dictcol, selected = selected)
1091 if prep.val == wx.ID_OK :
1092 self.parametres = prep.parametres
1094 script = PrintSimiScript(self)
1095 script.make_script()
1096 pid = exec_rcode(self.ira.RPath, script.scriptout, wait = True)
1097 check_Rresult(self.ira, pid)
1098 if self.parametres['type_graph'] in [1,3] :
1099 if self.parametres['svg'] :
1100 filename, ext = os.path.splitext(script.filename)
1101 fileout = filename + '.svg'
1102 elif self.parametres['type_graph'] == 3 :
1103 fileout = script.filename
1104 parametres = {'gexffile' : fileout,
1105 'dirout' : os.path.dirname(fileout),
1106 'titre': 'Le titre',
1107 #'nodemin': self.param['txt_min'],
1108 #'nodemax': self.param['txt_max'],
1109 #'bargraphw' : 60*int(self.param['clnb']),
1111 web = WebExport(self.ira, parametres)
1112 fileout = web.exportsimi()
1114 fileout = script.filename
1115 if os.path.exists(self.pathout['liste_graph']):
1116 graph_simi = read_list_file(self.pathout['liste_graph'])
1117 graph_simi.append([os.path.basename(fileout), script.txtgraph])
1119 graph_simi = [[os.path.basename(fileout), script.txtgraph]]
1120 print_liste(self.pathout['liste_graph'], graph_simi)
1121 DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira'])
1122 if self.parametres['type_graph'] in [1,3] :
1123 if self.parametres['svg'] or self.parametres['type_graph'] == 3 :
1124 self.graphpan.sizer_3.Add(hl.HyperLinkCtrl(self.graphpan.panel_1, -1, fileout, URL = fileout), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1126 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)
1127 self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1, script.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1128 self.graphpan.sizer_3.Fit(self.graphpan.panel_1)
1129 self.graphpan.Layout()
1130 self.graphpan.panel_1.Scroll(0,self.graphpan.panel_1.GetScrollRange(wx.VERTICAL))
1132 def export(self, evt) :
1134 while os.path.exists(os.path.join(self.pathout.dirout,'graph_'+str(nb)+'.graphml')):
1136 fileout = ffr(os.path.join(self.pathout.dirout,'graph_'+str(nb)+'.graphml'))
1142 graph <- graph.simi$graph
1143 V(graph)$x <- graph.simi$layout[,1]
1144 V(graph)$y <- graph.simi$layout[,2]
1145 if (length(graph.simi$label.cex == 1)) {
1146 V(graph)$weight <- graph.simi$eff
1148 V(graph)$weight <- graph.simi$label.cex
1150 V(graph)$color <- vertex.label.color
1151 V(graph)$frequences <- graph.simi$mat.eff
1152 V(graph)$label <- as.character(graph.simi$v.label)
1153 E(graph)$weight <- graph.simi$we.width
1154 write.graph(graph, fileout, format = 'graphml')
1155 #saveAsGEXF(graph, filepath = fileout)
1156 """ % (self.pathout['RData.RData'], self.parent.RscriptsPath['simi'], fileout)
1157 filetmp = tempfile.mktemp()
1158 with open(filetmp, 'w') as f :
1160 exec_rcode(self.ira.RPath, filetmp)
1161 mss = wx.MessageDialog(self.ira, fileout, u'Fichier exporté', wx.OK)
1162 mss.CenterOnParent()
1166 class DefaultMatLayout :
1167 def __init__(self, parent, tableau, parametres) :
1168 self.pathout = PathOut(dirout = parametres['pathout'])
1170 self.parent = parent
1171 self.tableau = tableau
1172 self.parametres = parametres
1173 if os.path.exists(self.pathout['analyse.db']) :
1174 self.tableau.read_tableau(self.pathout['analyse.db'])
1176 self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
1177 self.ira.ShowAPane("Tab_content")
1179 def dolayout(self) :
1182 class FreqLayout(DefaultMatLayout) :
1183 def dolayout(self) :
1184 self.tab = wx.html.HtmlWindow(self.ira.nb, -1)
1185 if "gtk2" in wx.PlatformInfo:
1186 self.tab.SetStandardFonts()
1187 self.tab.LoadPage(self.pathout['resultats.html'])
1188 self.tab.parametres = self.parametres
1189 self.ira.nb.AddPage(self.tab, u"Fréquences")
1192 class Chi2Layout(DefaultMatLayout) :
1194 self.tab = wx.html.HtmlWindow(self.ira.nb, -1)
1195 if "gtk2" in wx.PlatformInfo:
1196 self.tab.SetStandardFonts()
1197 self.tab.LoadPage(self.pathout['resultats-chi2.html'])
1198 self.tab.parametres = self.parametres
1199 self.ira.nb.AddPage(self.tab, ' - '.join([u"Chi2", "%s" % self.parametres['name']]))
1200 #self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
1201 #self.ira.ShowAPane("Tab_content")
1204 class ProtoLayout(DefaultMatLayout) :
1205 def dolayout(self) :
1206 list_graph = [['proto.png', 'Analyse prototypique']]
1207 #self.Tab = aui.AuiNotebook(self.ira.nb, -1, wx.DefaultPosition)
1208 #if self.parametres['svg'] :
1209 # list_graph = [['nuage_1.svg', 'Nuage']]
1211 # list_graph = [['nuage_1.png', 'Nuage']]
1212 self.TabProto = GraphPanel(self.ira.nb, self.pathout, list_graph)
1213 #self.Tab.AddPage(self.TabProto, 'Analyse Prototypique')
1214 #self.Tab.corpus = self.corpus
1215 self.TabProto.parametres = self.parametres
1216 self.ira.nb.AddPage(self.TabProto, 'Analyse Prototypique - %s' % self.parametres['name'])
1217 #self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
1218 #self.ira.ShowAPane("Tab_content")
1221 class SimiMatLayout(DefaultMatLayout) :
1223 self.pathout.basefiles(simipath)
1224 self.indices = indices_simi
1225 if os.path.exists(self.pathout['liste_graph']) :
1226 list_graph = read_list_file(self.pathout['liste_graph'])
1228 list_graph = [['','']]
1229 notebook_flags = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_FLOAT
1230 self.tabsimi = aui.AuiNotebook(self.parent.nb, -1, wx.DefaultPosition)
1231 self.tabsimi.SetAGWWindowStyleFlag(notebook_flags)
1232 self.tabsimi.SetArtProvider(aui.ChromeTabArt())
1233 self.graphpan = GraphPanelSimi(self.tabsimi, self.pathout, list_graph)
1234 self.graphpan.Bind(wx.EVT_BUTTON, self.redosimi, self.graphpan.butafc)
1235 self.graphpan.Bind(wx.EVT_BUTTON, self.export, self.graphpan.butexport)
1236 self.tabsimi.AddPage(self.graphpan, 'Graph')
1237 self.tabsimi.parametres = self.parametres
1238 self.parent.nb.AddPage(self.tabsimi, 'Analyse de graph')
1239 #self.parent.ShowTab(True)
1240 #self.parent.nb.SetSelection(self.parent.nb.GetPageCount() - 1)
1242 def redosimi(self,evt) :
1243 with open(self.pathout['selected.csv'],'r') as f :
1245 selected = [int(val) for val in selected.splitlines()]
1246 #if self.actives is None :
1247 # with codecs.open(self.pathout['actives.csv'], 'r', self.parametres['encoding']) as f :
1248 # self.actives = f.read()
1249 # self.actives = self.actives.splitlines()#[act for act in self.actives.splitlines()]
1251 actives = [[val, self.tableau.actives[val][0]] for val in self.tableau.actives]
1253 actives = [[val, self.tableau.actives[val]] for val in self.tableau.actives]
1255 #self.tableau.make_listactives()
1256 actives = dict([[i, val] for i, val in enumerate(actives)])
1257 #dictcol = dict([[i, [act, self.corpus.getlemeff(act)]] for i, act in enumerate(self.actives)])
1258 self.dial = PrefSimi(self.parent, -1, self.parametres, self.indices, wordlist = actives, selected = selected, actives = self.tableau.listactives)
1259 self.dial.CenterOnParent()
1260 self.val = self.dial.ShowModal()
1261 if self.val == wx.ID_OK :
1262 last = self.dial.listcol.GetFirstSelected()
1263 lastl = [self.dial.listcol.GetFirstSelected()]
1264 indexes = [self.dial.listcol.getColumnText(self.dial.listcol.GetFirstSelected(),0)]
1265 while self.dial.listcol.GetNextSelected(last) != -1:
1266 last = self.dial.listcol.GetNextSelected(last)
1268 indexes.append(self.dial.listcol.getColumnText(last,0))
1269 self.column = [self.tableau.listactives.index(val) for val in indexes]
1271 with open(self.pathout['selected.csv'], 'w') as f :
1272 f.write('\n'.join([`val` for val in self.column]))
1275 self.script = PrintSimiScript(self)
1276 self.script.make_script()
1277 self.tmpfile = self.script.scriptout
1278 dlg = progressbar(self, maxi = 2)
1281 if self.parametres['type_graph'] == 1:
1282 if self.parametres['svg'] :
1283 filename, ext = os.path.splitext(self.script.filename)
1284 fileout = filename + '.svg'
1286 fileout = self.script.filename
1287 if os.path.exists(self.pathout['liste_graph']):
1288 graph_simi = read_list_file(self.pathout['liste_graph'])
1289 graph_simi.append([os.path.basename(fileout), self.script.txtgraph])
1291 graph_simi = [[os.path.basename(fileout), self.script.txtgraph]]
1292 print_liste(self.pathout['liste_graph'], graph_simi)
1293 DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira'])
1294 if self.parametres['type_graph'] == 1:
1295 if self.parametres['svg'] :
1296 self.graphpan.sizer_3.Add(hl.HyperLinkCtrl(self.graphpan.panel_1, -1, fileout, URL = fileout), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1298 self.graphpan.sizer_3.Add(wx.StaticBitmap(self.graphpan.panel_1, -1, wx.Bitmap(self.script.filename, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1299 self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1, self.script.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1300 self.graphpan.sizer_3.Fit(self.graphpan.panel_1)
1301 self.graphpan.Layout()
1302 self.graphpan.panel_1.Scroll(0,self.graphpan.panel_1.GetScrollRange(wx.VERTICAL))
1307 def make_param(self) :
1308 if self.parametres['first'] :
1311 keep_coord = self.dial.check_coord.GetValue()
1312 #self.select = self.dial.check_colch.GetValue()
1314 paramsimi = {'coeff' : self.dial.choice1.GetSelection(),
1315 'layout' : self.dial.choice2.GetSelection(),
1316 'type_graph' : self.dial.choice3.GetSelection(),
1317 'arbremax' : self.dial.check1.GetValue(),
1318 'coeff_tv' : self.dial.check_s_size.GetValue(),
1319 'coeff_tv_nb' : self.dial.spin_tv.GetValue(),
1320 'tvprop' : self.dial.check2.GetValue(),
1321 'tvmin' : self.dial.spin_tvmin.GetValue(),
1322 'tvmax' : self.dial.spin_tvmax.GetValue(),
1323 'coeff_te' : self.dial.check3.GetValue(),
1324 'coeff_temin' : self.dial.spin_temin.GetValue(),
1325 'coeff_temax' : self.dial.spin_temax.GetValue(),
1326 'label_e' : self.dial.check_elab.GetValue(),
1327 'label_v' : self.dial.check_vlab.GetValue(),
1328 'vcex' : self.dial.check_vcex.GetValue(),
1329 'vcexmin' : self.dial.spin_vcexmin.GetValue(),
1330 'vcexmax' : self.dial.spin_vcexmax.GetValue(),
1331 'cex' : self.dial.spin_cex.GetValue(),
1332 'seuil_ok' : self.dial.check_seuil.GetValue(),
1333 'seuil' : self.dial.spin_seuil.GetValue(),
1334 'cols' : self.dial.cols.GetColour(),
1335 'cola' : self.dial.cola.GetColour(),
1336 'width' : self.dial.spin_width.GetValue(),
1337 'height' : self.dial.spin_height.GetValue(),
1339 'keep_coord' : keep_coord,
1340 'alpha' : self.dial.slider_sphere.GetValue(),
1341 'film' : self.dial.film.GetValue(),
1342 'svg' : self.dial.choix_format.GetSelection(),
1343 'halo' : self.dial.halo.GetValue(),
1344 'com' : self.dial.comcheck.GetValue(),
1345 'communities' : self.dial.choix_com.GetSelection(),
1347 if 'cexfromchi' in self.parametres :
1348 paramsimi['cexfromchi'] = self.dial.checkit.GetValue()
1349 if 'sfromchi' in self.parametres :
1350 paramsimi['sfromchi'] = self.dial.checki.GetValue()
1351 if 'vlabcolor' in self.parametres :
1352 paramsimi['vlabcolor'] = self.parametres['vlabcolor']
1353 if 'check_bystar' in dir(self.dial) :
1354 paramsimi['bystar'] = self.dial.check_bystar.GetValue()
1355 paramsimi['stars'] = self.parametres['stars']
1356 self.parametres.update(paramsimi)
1359 if self.parametres['type_graph'] == 1 :
1365 pid = exec_rcode(self.parent.RPath, self.tmpfile, wait = wait, graph = graph)
1366 if self.parametres['type_graph'] == 1 :
1367 while pid.poll() == None :
1370 check_Rresult(self.parent, pid)
1372 def export(self, evt) :
1374 while os.path.exists(os.path.join(self.pathout.dirout,'graph_'+str(nb)+'.graphml')):
1376 fileout = ffr(os.path.join(self.pathout.dirout,'graph_'+str(nb)+'.graphml'))
1382 graph <- graph.simi$graph
1383 V(graph)$x <- graph.simi$layout[,1]
1384 V(graph)$y <- graph.simi$layout[,2]
1385 if (length(graph.simi$label.cex == 1)) {
1386 V(graph)$weight <- graph.simi$mat.eff
1388 V(graph)$weight <- graph.simi$label.cex
1390 V(graph)$color <- vertex.label.color
1391 V(graph)$frequences <- graph.simi$mat.eff
1392 V(graph)$fprop <- graph.simi$mat.eff/nrow(dm)
1393 V(graph)$label <- as.character(graph.simi$v.label)
1394 E(graph)$weight <- graph.simi$we.width
1395 write.graph(graph, fileout, format = 'graphml')
1396 #saveAsGEXF(graph, filepath = fileout)
1397 """ % (self.pathout['RData.RData'], self.parent.RscriptsPath['simi'], fileout)
1398 filetmp = tempfile.mktemp()
1399 with open(filetmp, 'w') as f :
1401 exec_rcode(self.ira.RPath, filetmp)
1402 mss = wx.MessageDialog(self.ira, fileout, u'Fichier exporté', wx.OK)
1403 mss.CenterOnParent()
1408 class GraphPanelSimi(wx.Panel):
1409 def __init__(self,parent, dico, list_graph):
1410 wx.Panel.__init__(self,parent)
1413 self.dirout = os.path.dirname(self.Dict['ira'])
1414 self.parent = self.GetParent()#parent
1415 self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier"))
1418 self.tabsimi = self.parent.GetParent()
1419 self.ira = self.tabsimi.GetParent()
1420 self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
1421 afc_img = wx.Image(os.path.join(self.ira.images_path,'button_simi.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1422 self.butafc = wx.BitmapButton(self, -1, afc_img)
1423 export_img = wx.Image(os.path.join(self.ira.images_path,'button_export.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1424 self.butexport = wx.BitmapButton(self, -1, export_img)
1425 for i in range(0,len(list_graph)):
1426 if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
1427 filename, ext = os.path.splitext(list_graph[i][0])
1428 if ext in ['.svg', '.html'] :
1429 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])))
1431 self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
1432 self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1]))
1433 self.panel_1.Bind(wx.EVT_MOTION, self.onMouseMove)
1434 self.__set_properties()
1437 def __set_properties(self):
1438 self.panel_1.EnableScrolling(True,True)
1439 #self.panel_1.SetSize((1000,1000))
1440 self.panel_1.SetScrollRate(20, 20)
1441 self.panel_1.SetFocus()
1443 def __do_layout(self):
1444 self.sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
1445 self.sizer_2 = wx.BoxSizer(wx.VERTICAL)
1446 self.sizer_3 = wx.BoxSizer(wx.VERTICAL)
1447 self.sizer_2.Add(self.butafc, 0, 0, 0)
1448 self.sizer_2.Add(self.butexport, 0, 0, 0)
1449 for i in range(0, len(self.listimg)):
1450 self.sizer_3.Add(self.listimg[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1451 self.sizer_3.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1452 self.panel_1.SetSizer(self.sizer_3)
1453 self.sizer_1.Add(self.sizer_2, 0, wx.EXPAND, 0)
1454 self.sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
1455 self.SetSizer(self.sizer_1)
1457 def onMouseMove(self, event):
1458 self.panel_1.SetFocus()