...+++...
[iramuteq] / ProfList.py
index 73f8ff7..a3c5c94 100644 (file)
@@ -17,10 +17,10 @@ import os
 import sys
 import  wx
 import  wx.lib.mixins.listctrl  as  listmix
-from tabsimi import DoSimi
+#from tabsimi import DoSimi
 from listlex import ListForSpec
 from chemins import ConstructPathOut, ffr
-from dialog import PrefExport, PrefUCECarac, SearchDial
+from dialog import PrefExport, PrefUCECarac, SearchDial, message
 from tableau import Tableau
 from search_tools import SearchFrame
 import webbrowser
@@ -41,6 +41,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
         self.Alceste = Alceste
         self.Source = gparent
         self.cl = cl
+        self.var_mod = {}
 
         line1 = profclasse.pop(0)
         classen = [line for line in profclasse if line[0] != '*' and line[0] != '*****']
@@ -48,15 +49,19 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
             self.lenact = profclasse.index([u'*****', u'*', u'*', u'*', u'*', u'*', '', ''])
             profclasse.pop(self.lenact)
         except ValueError:
-            self.lenact = len(profclasse)
+            try :
+                self.lenact = profclasse.index([u'*', u'*', u'*', u'*', u'*', u'*', '', ''])
+                profclasse.pop(self.lenact)
+            except ValueError:
+                self.lenact = len(profclasse)
         try :
             self.lensup = profclasse.index([u'*', u'*', u'*', u'*', u'*', u'*', '', ''])
             self.lensup = self.lensup - self.lenact
             profclasse.pop(self.lensup)
         except ValueError: 
-            self.lensup = 0
+            self.lensup = len(profclasse) - self.lenact
         self.lenet = len(profclasse) - (self.lenact + self.lensup)
-        print self.lenact, self.lensup, self.lenet
+#        print self.lenact, self.lensup, self.lenet
         for i,  line in enumerate(classen) :
             line[0] = i
         dictdata = dict(zip([i for i in range(0,len(classen))], classen))
@@ -69,6 +74,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
             self.la = []
             self.lchi = []
             self.lfreq = []
+        self.tmpchi = None
             
         #adding some art
         self.il = wx.ImageList(16, 16)
@@ -153,18 +159,9 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
 
     def OnItemSelected(self, event):
         self.currentItem = event.m_itemIndex
-        print 'OnItemSelected: "%s", "%s", "%s", "%s"\n' % (self.currentItem, self.GetItemText(self.currentItem), self.getColumnText(self.currentItem, 1), self.getColumnText(self.currentItem, 2))
-        #self.log.WriteText('OnItemSelected: "%s", "%s", "%s", "%s"\n' %
-        #                   (self.currentItem,
-        #                    self.GetItemText(self.currentItem),
-        #                    self.getColumnText(self.currentItem, 1),
-        #                    self.getColumnText(self.currentItem, 2)))
 
     def OnItemActivated(self, event):
         self.currentItem = event.m_itemIndex
-        print "OnItemActivated: %s\nTopItem: %s\n" % (self.GetItemText(self.currentItem), self.GetTopItem())
-        #self.log.WriteText("OnItemActivated: %s\nTopItem: %s\n" %
-        #                   (self.GetItemText(self.currentItem), self.GetTopItem()))
 
     def getColumnText(self, index, col):
         item = self.GetItem(index, col)
@@ -172,9 +169,6 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
 
     def OnItemDeselected(self, evt):
         pass
-        #self.log.WriteText("OnItemDeselected: %s" % evt.m_itemIndex)
-
-
     #---------------------------------------------------
     # These methods are callbacks for implementing the
     # "virtualness" of the list...
@@ -199,7 +193,6 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
 
     def OnGetItemAttr(self, item):
         index=self.itemIndexMap[item]
-        #genre=self.itemDataMap[index][2]
         if index < self.lenact :
             if item % 2 :
                 return self.attr1
@@ -218,15 +211,6 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
         else :
             return None
 
-#        if genre=="Rock":
-#            return self.attr2
-#        elif genre=="Jazz":
-#            return self.attr1
-#        elif genre=="New Age":
-#            return self.attr3
-#        else:
-#            return None
-
     #---------------------------------------------------
     # Matt C, 2006/02/22
     # Here's a better SortItems() method --
@@ -367,11 +351,19 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
             corpus = self.Source.corpus
         ClasseCHD(self.parent, corpus, self.cl)
 
+    def getselectedwords(self) :
+        words = [self.getColumnText(self.GetFirstSelected(), 6)]
+        last = self.GetFirstSelected()
+        while self.GetNextSelected(last) != -1:
+            last = self.GetNextSelected(last)
+            words.append(self.getColumnText(last, 6))
+        return words
+
     def quest_var_mod(self, evt) :
         if 'corpus' in dir(self.Source):
             corpus = self.Source.corpus
             if self.var_mod == {} :
-                self.var_mod = treat_var_mod([val for val in corpus.make_etoiles()])
+                self.var_mod = self.Source.corpus.make_etoiles_dict()
         else :
             corpus = self.Source.tableau
             if self.var_mod == {} :
@@ -383,25 +375,29 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
         chistable.pop(0)
         vchistable = [line[1:] for line in chistable]
         fchistable = [line[0] for line in chistable]
-        word = self.getColumnText(self.GetFirstSelected(), 6)
+        word = self.getselectedwords()[0]
+        print self.var_mod
         if len(word.split('_')) > 1 :
-            var = word.split('_')[0]
-            words = [word for word in self.var_mod[var]]
+            var = word.split('_')
+            #words = ['_'.join([var[0],word]) for word in self.var_mod[var[0]]]
+            words = [word for word in self.var_mod[var[0]]]
             words.sort()
             tableout = []
             kwords = []
             for word in words :
+                print word
                 if word in fchistable :
                     tableout.append(vchistable[fchistable.index(word)])
                     kwords.append(word)
             tmpgraph = tempfile.mktemp(dir=self.Source.parent.TEMPDIR)
+            print tableout
             txt = barplot(tableout, kwords, title, self.Source.parent.RscriptsPath['Rgraph'], tmpgraph)
             tmpscript = tempfile.mktemp(dir=self.Source.parent.TEMPDIR)
             file = open(tmpscript,'w')
             file.write(txt)
             file.close()
             exec_rcode(self.Source.parent.RPath, tmpscript, wait = True)
-            win = MessageImage(self, -1, u"Graphique", size=(700, 500),style = wx.DEFAULT_FRAME_STYLE)
+            win = MessageImage(self,u"Graphique", size=(700, 500))
             win.addsaveimage(tmpgraph)
             txt = "<img src='%s'>" % tmpgraph
             win.HtmlPage.SetPage(txt)
@@ -415,7 +411,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
     def quest_simi(self, evt) :
         tableau = self.Source.tableau
         tab = tableau.make_table_from_classe(self.cl, self.la)
-        pathout = ConstructPathOut(self.Source.pathout+'/', 'simi_classe_%i' %self.cl)
+        pathout = ConstructPathOut(os.path.join(self.Source.pathout, 'simi_classe_%i' %self.cl))
         self.filename = os.path.join(pathout,'mat01.csv')
         tableau.printtable(self.filename, tab)
         del tab
@@ -468,108 +464,85 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
 
     def onwordgraph(self, evt):
         word = self.getColumnText(self.GetFirstSelected(), 6)
-        dlg = progressbar(self, 2)
-        corpus = self.Source.corpus
-        uces = corpus.lc[self.cl-1]
-        dlg.Update(1, u'Tableau...')
-        #tab = corpus.make_table_with_classe(uces, self.la)
-        pathout = ConstructPathOut(self.Source.pathout.dirout + '/' , 'simi_%s' % word)
-        self.filename = os.path.join(pathout,'mat01.csv')
-        dlg.Update(2, u'Ecriture...')
-        #corpus.write_tab(tab, self.filename)
-        #del tab
-        corpus.make_and_write_sparse_matrix_from_classe(self.la, uces, self.filename)
-        dlg.Destroy()
-        paramsimi = {'coeff' : 0,
-                          'layout' : 2,
-                          'type' : 1,
-                          'arbremax' : 0,
-                          'coeff_tv' : 1,
-                          'coeff_tv_nb' : 0,
-                          'tvprop' : 0,
-                          'tvmin' : 5,
-                          'tvmax' : 30,
-                          'coeff_te' : 1,
-                          'coeff_temin' : 1,
-                          'coeff_temax' : 10,
-                          'label_v': 1,
-                          'label_e': 0,
-                          'vcex' : 1,
-                          'vcexmin' : 10,
-                          'vcexmax' : 25, 
-                          'cex' : 10,
-                          'seuil_ok' : 1,
-                          'seuil' : 1,
-                          'cols' : (255,0,0),
-                          'cola' : (200,200,200),
-                          'width' : 600,
-                          'height' : 600,
-                          'first' : True,
-                          'keep_coord' : True,
-                          'alpha' : 20,
-                          'film': False,
-                          }
-        self.tableau = Tableau(self.parent, '')
-        self.tableau.listactives = self.la
-        self.tableau.actives = {}
-        for i, val in enumerate(self.la) :
-            self.tableau.actives[val] = [self.lfreq[i]]
-        DoSimi(self, param = paramsimi, fromprof = ffr(self.filename), pathout = pathout, wordgraph = word)
+        if self.tmpchi is None :
+            self.tmpchi = tempfile.mktemp(dir=self.Source.parent.TEMPDIR)
+            with open(self.tmpchi, 'w') as f:
+                f.write('\n'.join([str(val) for val in self.lchi]))
+        index = self.la.index(word)
+        parametres = {'type' : 'clustersimitxt', 
+                        'pathout' : self.Source.parametres['pathout'],
+                        'word' : index ,
+                        'lem' : self.Source.parametres['lem'],
+                        'tmpchi' : self.tmpchi}
+        #try :
+        self.parent.SimiFromCluster(self.parent, self.Source.corpus, self.la, self.cl - 1, parametres = parametres, dlg = progressbar(self, 4))
+        #except :
+        #    print 'not acitve'
 
     def on_graph(self, evt):
-        dlg = progressbar(self, 2)
-        corpus = self.Source.corpus
-        uces = corpus.lc[self.cl-1]
-        dlg.Update(1, u'Tableau...')
-        #tab = corpus.make_table_with_classe(uces, self.la)
-        pathout = ConstructPathOut(self.Source.pathout.dirout+'/', 'simi_classe_%i' %self.cl)
-        self.filename = os.path.join(pathout,'mat01.csv')
-        dlg.Update(2, u'Ecriture...')
-        #corpus.write_tab(tab, self.filename)
-        #del tab
-        corpus.make_and_write_sparse_matrix_from_classe(self.la, uces, self.filename)
-        dlg.Destroy()
-        paramsimi = {'coeff' : 0,
-                          'layout' : 2,
-                          'type' : 1,
-                          'arbremax' : 1,
-                          'coeff_tv' : 1,
-                          'coeff_tv_nb' : 0,
-                          'tvprop' : 0,
-                          'tvmin' : 5,
-                          'tvmax' : 30,
-                          'coeff_te' : 1,
-                          'coeff_temin' : 1,
-                          'coeff_temax' : 10,
-                          'label_v': 1,
-                          'label_e': 0,
-                          'vcex' : 0,
-                          'vcexmin' : 10,
-                          'vcexmax' : 25,
-                          'cex' : 10,
-                          'cexfromchi' : True,
-                          'sfromchi': False,
-                          'seuil_ok' : 0,
-                          'seuil' : 1,
-                          'cols' : (255,0,0),
-                          'cola' : (200,200,200),
-                          'width' : 1000,
-                          'height' : 1000,
-                          'first' : True,
-                          'keep_coord' : True,
-                          'alpha' : 20,
-                          'film': False,
-                          }
-        self.tableau = Tableau(self.parent, '')
-        self.tableau.listactives = self.la
-        self.tableau.actives = {}
-        self.tableau.lchi = self.lchi
-        self.tableau.chi = {}
-        self.tableau.parametre['fromprof'] = True
-        for i, val in enumerate(self.la) :
-            self.tableau.actives[val] = [self.lfreq[i]]
-            self.tableau.chi[val] = [self.lchi[i]]
-        DoSimi(self, param = paramsimi, fromprof = ffr(self.filename), pathout = pathout)
+        if self.tmpchi is None :
+            self.tmpchi = tempfile.mktemp(dir=self.Source.parent.TEMPDIR)
+            with open(self.tmpchi, 'w') as f:
+                f.write('\n'.join([str(val) for val in self.lchi]))
+        parametres = {'type' : 'clustersimitxt', 
+                        'pathout' : self.Source.parametres['pathout'],
+                        'lem' : self.Source.parametres['lem'],
+                        'tmpchi' : self.tmpchi}
+
+        self.parent.SimiFromCluster(self.parent, self.Source.corpus, self.la, self.cl - 1, parametres = parametres, dlg = progressbar(self, 4))
+        #dlg = progressbar(self, 2)
+        #corpus = self.Source.corpus
+        #uces = corpus.lc[self.cl-1]
+        #dlg.Update(1, u'Tableau...')
+        ##tab = corpus.make_table_with_classe(uces, self.la)
+        #pathout = ConstructPathOut(self.Source.pathout.dirout+'/', 'simi_classe_%i' %self.cl)
+        #self.filename = os.path.join(pathout,'mat01.csv')
+        #dlg.Update(2, u'Ecriture...')
+        ##corpus.write_tab(tab, self.filename)
+        ##del tab
+        #corpus.make_and_write_sparse_matrix_from_classe(self.la, uces, self.filename)
+        #dlg.Destroy()
+        #paramsimi = {'coeff' : 0,
+        #                  'layout' : 2,
+        #                  'type' : 1,
+        #                  'arbremax' : 1,
+        #                  'coeff_tv' : 1,
+        #                  'coeff_tv_nb' : 0,
+        #                  'tvprop' : 0,
+        #                  'tvmin' : 5,
+        #                  'tvmax' : 30,
+        #                  'coeff_te' : 1,
+        #                  'coeff_temin' : 1,
+        #                  'coeff_temax' : 10,
+        #                  'label_v': 1,
+        #                  'label_e': 0,
+        #                  'vcex' : 0,
+        #                  'vcexmin' : 10,
+        #                  'vcexmax' : 25,
+        #                  'cex' : 10,
+        #                  'cexfromchi' : True,
+        #                  'sfromchi': False,
+        #                  'seuil_ok' : 0,
+        #                  'seuil' : 1,
+        #                  'cols' : (255,0,0),
+        #                  'cola' : (200,200,200),
+        #                  'width' : 1000,
+        #                  'height' : 1000,
+        #                  'first' : True,
+        #                  'keep_coord' : True,
+        #                  'alpha' : 20,
+        #                  'film': False,
+        #                  }
+        #self.tableau = Tableau(self.parent, '')
+        #self.tableau.listactives = self.la
+        #self.tableau.actives = {}
+        #self.tableau.lchi = self.lchi
+        #self.tableau.chi = {}
+        #self.tableau.parametre['fromprof'] = True
+        #for i, val in enumerate(self.la) :
+        #    self.tableau.actives[val] = [self.lfreq[i]]
+        #    self.tableau.chi[val] = [self.lchi[i]]
+        #DoSimi(self, param = paramsimi, fromprof = ffr(self.filename), pathout = pathout)
 
     def on_segments(self,evt) :
         dlg = progressbar(self, 2)
@@ -632,7 +605,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
             #ucestxt = [corpus.make_concord(self.la, ' '.join(uce), 'red') for uce in ucestxt]
             dlg.Update(4, u'texte...')
             #ucis_txt = [' '.join(corpus.ucis[val[1][0]][0]) for val in ntab2]
-            win = message(self, -1, u"UCE caractéristiques - Classe %i" % self.cl, size=(600, 500), style=wx.DEFAULT_FRAME_STYLE)
+            win = message(self, u"UCE caractéristiques - Classe %i" % self.cl, (750, 600))
             win.html = '<html>\n' + '<br><br>'.join(['<br>'.join([ucis_txt[i], 'score : ' + str(ntab2[i][0]), ucestxt[i]]) for i in range(0,len(ucestxt))]) + '\n</html>'
             win.HtmlPage.SetPage(win.html)
             dlg.Destroy()
@@ -650,24 +623,23 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
         chistable.pop(0)
         vchistable = [line[1:] for line in chistable]
         fchistable = [line[0] for line in chistable]
-        words = [self.getColumnText(self.GetFirstSelected(), 6)]
-        tableout = [vchistable[fchistable.index(words[0])]]
-        last = self.GetFirstSelected()
-        while self.GetNextSelected(last) != -1:
-            last = self.GetNextSelected(last)
-            word = self.getColumnText(last, 6)
-            words.append(word)
-            tableout.append(vchistable[fchistable.index(word)])
+        words = self.getselectedwords()
+        tableout = [vchistable[fchistable.index(word)] for word in words]
         tmpgraph = tempfile.mktemp(dir=self.Source.parent.TEMPDIR)
         nbcl = len(title)
+        nbwords = len(words)
         txt = barplot(tableout, words, title, self.Source.parent.RscriptsPath['Rgraph'], tmpgraph)
         tmpscript = tempfile.mktemp(dir=self.Source.parent.TEMPDIR)
         file = open(tmpscript,'w')
         file.write(txt)
         file.close()
-        
         exec_rcode(self.Source.parent.RPath, tmpscript, wait = True)
-        win = MessageImage(self, -1, u"Graphique", size=(700, 500),style = wx.DEFAULT_FRAME_STYLE)
+        w = 100 + (20 * nbwords) + (100 * nbcl)
+        h = 100 + (nbwords * 15)
+        if w > 1100 : w = 1100
+        if h > 800 : h = 800
+        if h < 450 : h = 450
+        win = MessageImage(self, u"Graphique", size=(w, h))
         win.addsaveimage(tmpgraph)
         txt = "<img src='%s'>" % tmpgraph
         win.HtmlPage.SetPage(txt)
@@ -685,14 +657,8 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
         chistable.pop(0)
         vchistable = [line[1:] for line in chistable]
         fchistable = [line[0] for line in chistable]
-        words = [self.getColumnText(self.GetFirstSelected(), 6)]
-        tableout = [vchistable[fchistable.index(words[0])]]
-        last = self.GetFirstSelected()
-        while self.GetNextSelected(last) != -1:
-            last = self.GetNextSelected(last)
-            word = self.getColumnText(last, 6)
-            words.append(word)
-            tableout.append(vchistable[fchistable.index(word)])
+        words = self.getselectedwords()
+        tableout = [vchistable[fchistable.index(word)] for word in words]
         tmpgraph = tempfile.mktemp(dir=self.Source.parent.TEMPDIR)
         txttable = 'c(' + ','.join([','.join(line) for line in tableout]) + ')'
         rownames = 'c("' + '","'.join(words) + '")'
@@ -717,7 +683,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
         file.write(txt)
         file.close()
         exec_rcode(self.Source.parent.RPath, tmpscript, wait = True)
-        win = MessageImage(self, -1, u"Graphique", size=(700, 500),style = wx.DEFAULT_FRAME_STYLE)
+        win = MessageImage(self, u"Graphique", size=(700, 500))
         win.addsaveimage(tmpgraph)
         txt = "<img src='%s'>" % tmpgraph
         win.HtmlPage.SetPage(txt)
@@ -732,7 +698,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
             last = self.GetNextSelected(last)
             ListWord.append(self.getColumnText(last, 6))
         listmot = [forme for item in ListWord for forme in corpus.getlems()[item].formes]
-        win = message(self, -1, title, size=(600, 500), style=wx.DEFAULT_FRAME_STYLE)
+        win = message(self, title, size=(750, 600))
         toshow = ['<html>\n<H1>Concordancier</H1>\n']
         toshow.append('<h3><font color=%s>' % color + ' '.join(ListWord) + '</font></h3><br>')
         duce = {}
@@ -1268,7 +1234,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
             if ucef != [] :
                 nb = len(ucef)
                 rep.append([corpus.getforme(forme).forme, nb])
-        win = message(self, -1, u"Formes associées", size=(300, 200), style=wx.DEFAULT_FRAME_STYLE)
+        win = message(self, u"Formes associées", wx.Size(300, 200))
         win.html = '<html>\n' + '<br>'.join([' : '.join([str(val) for val in forme]) for forme in rep]) + '\n</html>'
         win.HtmlPage.SetPage(win.html)
         win.Show(True)
@@ -1591,81 +1557,55 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col
 #    def OnCloseWindow(self, event):
 #        self.Destroy()
 #
-class message(wx.Frame):
-    def __init__(self, *args, **kwds):
-        kwds["style"] = wx.DEFAULT_FRAME_STYLE
-        wx.Frame.__init__(self, *args, **kwds)
-        self.html = ""
-        self.HtmlPage=wx.html.HtmlWindow(self, -1)
-        if "gtk2" in wx.PlatformInfo:
-            self.HtmlPage.SetStandardFonts()
-        self.HtmlPage.SetFonts('Courier','Courier')
-        self.button_1 = wx.Button(self, -1, "Fermer")
-        self.button_2 = wx.Button(self, -1, u"Enregistrer...")
-
-        self.Bind(wx.EVT_BUTTON, self.OnSavePage, self.button_2)
-        self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1)
-        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
-        self.__do_layout()
-
-    def __do_layout(self):
-        sizer_1 = wx.BoxSizer(wx.VERTICAL)
-        sizer_2 = wx.BoxSizer(wx.VERTICAL)
-        sizer_2.Add(self.HtmlPage, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        sizer_2.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ADJUST_MINSIZE, 0)
-        sizer_2.Add(self.button_2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ADJUST_MINSIZE, 0)
-        sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
-        self.SetAutoLayout(True)
-        self.SetSizer(sizer_1)
-        self.Layout()
-
-    def OnSavePage(self, evt) :
-        dlg = wx.FileDialog(
-            self, message="Enregistrer sous...", defaultDir=os.getcwd(),
-            defaultFile="concordancier.html", wildcard="html|*.html", style=wx.SAVE | wx.OVERWRITE_PROMPT
-            )
-        dlg.SetFilterIndex(2)
-        dlg.CenterOnParent()
-        if dlg.ShowModal() == wx.ID_OK:
-            path = dlg.GetPath()
-            with open(path, 'w') as f :
-                f.write(self.html)
-
-    def OnCloseMe(self, event):
-        self.Close(True)
-
-    def OnCloseWindow(self, event):
-        self.Destroy()
+#class message(wx.Dialog):
+#    def __init__(self, parent, title, size, save = True):
+#        wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = title, pos = wx.DefaultPosition, size = size, style = wx.DEFAULT_DIALOG_STYLE )
+#      self.save = save        
+#        self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
+#
+#        self.html = ""
+#        self.HtmlPage=wx.html.HtmlWindow(self, -1)
+#        self.HtmlPage.SetMinSize( size )
+#        if "gtk2" in wx.PlatformInfo:
+#            self.HtmlPage.SetStandardFonts()
+#        self.HtmlPage.SetFonts('Courier','Courier')
 #
-#def getSmallUpArrowData():
-#    return \
-#'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
-#\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
-#\x00\x00<IDAT8\x8dcddbf\xa0\x040Q\xa4{h\x18\xf0\xff\xdf\xdf\xffd\x1b\x00\xd3\
-#\x8c\xcf\x10\x9c\x06\xa0k\xc2e\x08m\xc2\x00\x97m\xd8\xc41\x0c \x14h\xe8\xf2\
-#\x8c\xa3)q\x10\x18\x00\x00R\xd8#\xec\xb2\xcd\xc1Y\x00\x00\x00\x00IEND\xaeB`\
-#\x82' 
+#        self.button_1 = wx.Button(self, wx.ID_CANCEL)
 #
-#def getSmallUpArrowBitmap():
-#    return wx.BitmapFromImage(getSmallUpArrowImage())
+#        self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1)
+#        if self.save :
+#            self.button_2 = wx.Button(self, wx.ID_SAVE)
+#            self.Bind(wx.EVT_BUTTON, self.OnSavePage, self.button_2)
+#        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
+#        self.__do_layout()
 #
-#def getSmallUpArrowImage():
-#    stream = cStringIO.StringIO(getSmallUpArrowData())
-#    return wx.ImageFromStream(stream)
+#    def __do_layout(self):
+#        sizer_2 = wx.BoxSizer(wx.VERTICAL)
+#        sizer_2.Add(self.HtmlPage, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+#        m_sdbSizer1 = wx.StdDialogButtonSizer()
+#        m_sdbSizer1.AddButton(  self.button_1 )
+#        if self.save :
+#            m_sdbSizer1.AddButton(  self.button_2 )
+#        m_sdbSizer1.Realize()
+#        sizer_2.Add(m_sdbSizer1, 1, wx.EXPAND, 5)
+#        self.SetSizer(sizer_2)
+#        self.Layout()
+#        sizer_2.Fit( self )
 #
-##----------------------------------------------------------------------
-#def getSmallDnArrowData():
-#    return \
-#"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
-#\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
-#\x00\x00HIDAT8\x8dcddbf\xa0\x040Q\xa4{\xd4\x00\x06\x06\x06\x06\x06\x16t\x81\
-#\xff\xff\xfe\xfe'\xa4\x89\x91\x89\x99\x11\xa7\x0b\x90%\ti\xc6j\x00>C\xb0\x89\
-#\xd3.\x10\xd1m\xc3\xe5*\xbc.\x80i\xc2\x17.\x8c\xa3y\x81\x01\x00\xa1\x0e\x04e\
-#?\x84B\xef\x00\x00\x00\x00IEND\xaeB`\x82" 
+#    def OnSavePage(self, evt) :
+#        dlg = wx.FileDialog(
+#            self, message="Enregistrer sous...", defaultDir=os.getcwd(),
+#            defaultFile="concordancier.html", wildcard="html|*.html", style=wx.SAVE | wx.OVERWRITE_PROMPT
+#            )
+#        dlg.SetFilterIndex(2)
+#        dlg.CenterOnParent()
+#        if dlg.ShowModal() == wx.ID_OK:
+#            path = dlg.GetPath()
+#            with open(path, 'w') as f :
+#                f.write(self.html)
 #
-#def getSmallDnArrowBitmap():
-#    return wx.BitmapFromImage(getSmallDnArrowImage())
+#    def OnCloseMe(self, event):
+#        self.Close(True)
 #
-#def getSmallDnArrowImage():
-#    stream = cStringIO.StringIO(getSmallDnArrowData())
-#    return wx.ImageFromStream(stream)
+#    def OnCloseWindow(self, event):
+#        self.Destroy()