From: Pierre Date: Mon, 31 Dec 2012 14:28:03 +0000 (+0100) Subject: message X-Git-Url: http://iramuteq.org/git?a=commitdiff_plain;h=655d1e1ab00740c37712f476dc89dff7965c2161;p=iramuteq message --- diff --git a/ProfList.py b/ProfList.py index 7a9c245..0e3fab7 100644 --- a/ProfList.py +++ b/ProfList.py @@ -57,7 +57,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col except ValueError: self.lensup = 0 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)) @@ -154,7 +154,7 @@ 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)) + #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), @@ -163,7 +163,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col def OnItemActivated(self, event): self.currentItem = event.m_itemIndex - print "OnItemActivated: %s\nTopItem: %s\n" % (self.GetItemText(self.currentItem), self.GetTopItem()) + #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())) @@ -410,7 +410,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 = "" % tmpgraph win.HtmlPage.SetPage(txt) @@ -641,7 +641,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 = '\n' + '

'.join(['
'.join([ucis_txt[i], 'score : ' + str(ntab2[i][0]), ucestxt[i]]) for i in range(0,len(ucestxt))]) + '\n' win.HtmlPage.SetPage(win.html) dlg.Destroy() @@ -670,7 +670,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col 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 = "" % tmpgraph win.HtmlPage.SetPage(txt) @@ -714,7 +714,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 = "" % tmpgraph win.HtmlPage.SetPage(txt) @@ -729,7 +729,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 = ['\n

Concordancier

\n'] toshow.append('

' % color + ' '.join(ListWord) + '


') duce = {} @@ -1265,7 +1265,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 = '\n' + '
'.join([' : '.join([str(val) for val in forme]) for forme in rep]) + '\n' win.HtmlPage.SetPage(win.html) win.Show(True) @@ -1588,17 +1588,23 @@ 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) +class message(wx.Dialog): + def __init__(self, parent, title, size): + wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = title, pos = wx.DefaultPosition, size = size, style = wx.DEFAULT_DIALOG_STYLE ) + + self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) + + #kwds["style"] = wx.DEFAULT_FRAME_STYLE + #wx.Frame.__init__(self, *args, **kwds) 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') - self.button_1 = wx.Button(self, -1, "Fermer") - self.button_2 = wx.Button(self, -1, u"Enregistrer...") + + self.button_1 = wx.Button(self, wx.ID_CANCEL) + self.button_2 = wx.Button(self, wx.ID_SAVE) self.Bind(wx.EVT_BUTTON, self.OnSavePage, self.button_2) self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1) @@ -1606,15 +1612,21 @@ class message(wx.Frame): self.__do_layout() def __do_layout(self): - sizer_1 = wx.BoxSizer(wx.VERTICAL) + #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) + sizer_2.Add(self.HtmlPage, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0) + m_sdbSizer1 = wx.StdDialogButtonSizer() + m_sdbSizer1.AddButton( self.button_1 ) + m_sdbSizer1.AddButton( self.button_2 ) + m_sdbSizer1.Realize() + #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) + sizer_2.Add(m_sdbSizer1, 1, wx.EXPAND, 5) + #self.SetAutoLayout(True) + self.SetSizer(sizer_2) self.Layout() + sizer_2.Fit( self ) def OnSavePage(self, evt) : dlg = wx.FileDialog( diff --git a/analysetxt.py b/analysetxt.py index 60b0e05..afaf355 100644 --- a/analysetxt.py +++ b/analysetxt.py @@ -205,9 +205,9 @@ class Alceste(AnalyseText) : def print_graph_files(self) : mess_afc = u"La position des points n'est peut être pas exacte" - afc_graph_list = [[os.path.basename(self.pathout['AFC2DL_OUT']), u'Variables actives - coordonnées - 30 points par classes - facteurs 1 / 2\n%s' % mess_afc], - [os.path.basename(self.pathout['AFC2DSL_OUT']), u'variables supplémentaires - coordonnées - 30 points par classes - facteurs 1 / 2\n%s' % mess_afc], - [os.path.basename(self.pathout['AFC2DEL_OUT']), u'Variables illustratives - Coordonnées - 30 points par classes - facteur 1 / 2\n%s' % mess_afc], + afc_graph_list = [[os.path.basename(self.pathout['AFC2DL_OUT']), u'Variables actives - coordonnées - 30 points par classes - facteurs 1 / 2 - %s' % mess_afc], + [os.path.basename(self.pathout['AFC2DSL_OUT']), u'variables supplémentaires - coordonnées - 30 points par classes - facteurs 1 / 2 - %s' % mess_afc], + [os.path.basename(self.pathout['AFC2DEL_OUT']), u'Variables illustratives - Coordonnées - 30 points par classes - facteur 1 / 2 - %s' % mess_afc], [os.path.basename(self.pathout['AFC2DCL_OUT']), u'Classes - Coordonnées - facteur 1 / 2']] #[os.path.basename(self.pathout['AFC2DCoul']), u'Variables actives - Corrélation - facteur 1 / 2'], #[os.path.basename(self.pathout['AFC2DCoulSup']), u'Variables supplémentaires - Corrélation - facteur 1 / 2'], diff --git a/dialog.py b/dialog.py index 1b01aa3..0c1c757 100755 --- a/dialog.py +++ b/dialog.py @@ -481,7 +481,7 @@ bibliothèques de R""" m_sdbSizer1.AddButton( self.m_sdbSizer1OK ) self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL ) m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel ) - m_sdbSizer1.Realize(); + m_sdbSizer1.Realize() bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 ) self.SetSizer( bSizer1 ) diff --git a/functions.py b/functions.py index e575359..175fb02 100644 --- a/functions.py +++ b/functions.py @@ -595,47 +595,51 @@ def read_list_file(filename, encoding = sys.getdefaultencoding()): ncontent=[line.replace('\n','').split(';') for line in content if line.strip() != ''] return ncontent -class MessageImage(wx.Frame): - def __init__(self, *args, **kwds): +class MessageImage(wx.Dialog): + def __init__(self, parent,title, size): # begin wxGlade: MyFrame.__init__ - kwds["style"] = wx.DEFAULT_FRAME_STYLE - wx.Frame.__init__(self, *args, **kwds) + # kwds["style"] = wx.DEFAULT_FRAME_STYLE + #wx.Dialog.__init__(self, *args, **kwds) + wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = title, pos = wx.DefaultPosition, size = size, style = wx.DEFAULT_DIALOG_STYLE ) + self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) #self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE) self.imageFile = False self.imagename = u"chi_classe.png" self.HtmlPage = wx.html.HtmlWindow(self, -1) + self.HtmlPage.SetMinSize(size) if "gtk2" in wx.PlatformInfo: self.HtmlPage.SetStandardFonts() self.HtmlPage.SetFonts('Courier', 'Courier') - self.button_1 = wx.Button(self, -1, u"Fermer") + self.button_1 = wx.Button(self, wx.ID_CANCEL) + self.button_2 = wx.Button(self, wx.ID_SAVE) self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1) - self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) - self.__do_layout() + self.Bind(wx.EVT_BUTTON, self.OnSaveImage, self.button_2) + self.do_layout() # end wxGlade - def __do_layout(self): + def do_layout(self): # begin wxGlade: MyFrame.__do_layout - sizer_1 = wx.BoxSizer(wx.VERTICAL) - self.sizer_2 = wx.BoxSizer(wx.VERTICAL) - self.sizer_2.Add(self.HtmlPage, 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0) - self.sizer_2.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ADJUST_MINSIZE, 0) - sizer_1.Add(self.sizer_2, 1, wx.EXPAND, 0) - self.SetAutoLayout(True) - self.SetSizer(sizer_1) + self.sizer_1 = wx.BoxSizer(wx.VERTICAL) + self.sizer_2 = wx.BoxSizer(wx.HORIZONTAL) + self.sizer_1.Add(self.HtmlPage, 0, wx.EXPAND, 0) + #self.sizer_2.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ADJUST_MINSIZE, 0) + #self.sizer_1.Add(self.sizer_2, 1, wx.EXPAND, 0) + + self.m_sdbSizer1 = wx.StdDialogButtonSizer() + self.m_sdbSizer1.AddButton( self.button_2 ) + self.m_sdbSizer1.AddButton( self.button_1 ) + self.m_sdbSizer1.Realize() + self.sizer_1.Add(self.m_sdbSizer1, 0, wx.EXPAND, 5) + self.SetSizer(self.sizer_1) + self.Layout() + self.sizer_1.Fit( self ) # end wxGlade def addsaveimage(self, imageFile) : self.imageFile = imageFile - self.button_2 = wx.Button(self, -1, u"Enregistrer l'image...") - self.Bind(wx.EVT_BUTTON, self.OnSaveImage, self.button_2) - self.sizer_2.Add(self.button_2, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ADJUST_MINSIZE, 0) - self.Layout() - + def OnCloseMe(self, event): - self.Close(True) - - def OnCloseWindow(self, event): self.Destroy() def OnSaveImage(self, event) : diff --git a/layout.py b/layout.py index bee04ee..3f9dfe0 100644 --- a/layout.py +++ b/layout.py @@ -45,6 +45,8 @@ class GraphPanelAfc(wx.Panel): self.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "courier")) self.labels = [] self.listimg = [] + self.buts = [] + self.list_graph = list_graph self.TabCHD = self.parent.GetParent() self.nb = self.TabCHD.GetParent() self.ira = self.nb.GetParent() @@ -53,10 +55,15 @@ class GraphPanelAfc(wx.Panel): self.butafc = wx.BitmapButton(self, -1, afc_img) self.Bind(wx.EVT_BUTTON, self.afc_graph, self.butafc) self.dirout = os.path.dirname(self.Dict['ira']) + b = 0 for i in range(0,len(list_graph)): if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) : self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY))) self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1])) + self.buts.append(wx.Button(self.panel_1, wx.ID_DELETE, name = `i - b`)) + else : + self.list_graph.pop(i) + b += 1 self.param = { 'typegraph' : 0, 'width' : 800, @@ -91,6 +98,7 @@ class GraphPanelAfc(wx.Panel): self.panel_1.SetScrollRate(20, 20) def __do_layout(self): + log.info('do layout') self.sizer_1 = wx.BoxSizer(wx.VERTICAL) self.sizer_2 = wx.BoxSizer(wx.HORIZONTAL) self.sizer_3 = wx.BoxSizer(wx.VERTICAL) @@ -98,10 +106,37 @@ class GraphPanelAfc(wx.Panel): for i in range(0, len(self.listimg)): self.sizer_3.Add(self.listimg[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0) self.sizer_3.Add(self.labels[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0) + self.sizer_3.Add(self.buts[i], 0, wx.ALIGN_CENTER_HORIZONTAL, 0) + self.Bind(wx.EVT_BUTTON, self.on_delete_image, self.buts[i]) self.panel_1.SetSizer(self.sizer_3) self.sizer_2.Add(self.panel_1, 1, wx.EXPAND, 0) self.SetSizer(self.sizer_2) + def on_delete_image(self, event) : + image_id = int(event.GetEventObject().GetName()) + image_path = self.list_graph[image_id][0] + message = 'This file will be delete : %s.\nAre you sure ?' % os.path.join(self.dirout, image_path) + dial = wx.MessageDialog(self, message, style = wx.YES_NO) + res = dial.ShowModal() + if res == wx.ID_YES : + dial.Destroy() + log.info('delete image %i' % image_id) + oldimg = self.listimg.pop(image_id) + oldimg.Destroy() + oldlab = self.labels.pop(image_id) + oldlab.Destroy() + No = [but.Destroy() for but in self.buts] + self.buts = [wx.Button(self.panel_1, wx.ID_DELETE, name = `i`) for i, img in enumerate(self.listimg)] + todel = self.list_graph.pop(image_id) + os.remove(os.path.join(self.dirout, todel[0])) + print_liste(self.Dict[self.itempath], self.list_graph) + self.__do_layout() + self.sizer_3.Fit(self.panel_1) + self.Layout() + else : + dial.Destroy() + + def afc_graph(self,event): #dirout = os.path.dirname(self.Dict['ira']) while os.path.exists(os.path.join(self.dirout,'graph_afc_'+str(self.afcnb)+'.png')): @@ -181,11 +216,15 @@ class GraphPanelAfc(wx.Panel): if self.param['over'] : txt += u' - Eviter les recouvrements' if self.param['cex_txt'] : txt += u' - taille du texte proportionnel à la masse' if self.param['tchi'] : txt += u' - taille du texte proportionnel au chi2 d\'association' - list_graph = read_list_file(self.DictPathOut[self.itempath], self.coding) - list_graph.append([self.fileout, txt]) - print_liste(self.DictPathOut[self.itempath], list_graph) - self.sizer_3.Add(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(self.fileout, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) - self.sizer_3.Add(wx.StaticText(self.panel_1,-1, txt), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) + #list_graph = read_list_file(self.DictPathOut[self.itempath], self.coding) + self.list_graph.append([self.fileout, txt]) + print_liste(self.DictPathOut[self.itempath], self.list_graph) + self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(self.fileout, wx.BITMAP_TYPE_ANY))) + self.sizer_3.Add( self.listimg[-1], 0, wx.ALIGN_CENTER_HORIZONTAL, 0) + self.labels.append(wx.StaticText(self.panel_1,-1, txt)) + self.sizer_3.Add(self.labels[-1], 0, wx.ALIGN_CENTER_HORIZONTAL, 0) + self.buts.append(wx.Button(self.panel_1, wx.ID_DELETE, name = `len(self.list_graph) - 1`)) + self.sizer_3.Add(self.buts[-1], 0, wx.ALIGN_CENTER_HORIZONTAL, 0) self.sizer_3.Fit(self.panel_1) self.Layout() @@ -269,8 +308,8 @@ class OpenCHDS(): DictProfile = ReadProfileAsDico(self, Profile, Alceste, self.encoding) self.DictProfile = DictProfile - print 'lecture des antiprofils' - DictAnti = ReadProfileAsDico(self, AntiProfile, Alceste, self.encoding) + #print 'lecture des antiprofils' + #DictAnti = ReadProfileAsDico(self, AntiProfile, Alceste, self.encoding) panel = wx.Panel(parent, -1) sizer1 = wx.BoxSizer(wx.VERTICAL) @@ -360,7 +399,6 @@ class OpenCHDS(): dlg.Update(3+i, 'Classe %i' %(i+1)) ind = '/'.join(DictProfile[str(i + 1)][0][0:2]) indpour = ' - '.join([ind, DictProfile[str(i + 1)][0][2]]) - print 'construction liste classe %i' % i self.tabprofile = ProfListctrlPanel(self.parent, self, DictProfile[str(i + 1)], Alceste, i + 1) #self.tabantiprofile = ProfListctrlPanel(self.parent, self, DictAnti[str(i + 1)], Alceste, i + 1) panel.ProfNB.AddPage(self.tabprofile, 'classe %s %s(%s%%)' % (str(i + 1), sep, indpour)) @@ -371,7 +409,7 @@ class OpenCHDS(): if clnb > 2 : self.TabAFC = aui.AuiNotebook(panel.TabChdSim, -1, wx.DefaultPosition) - + log.info('read AFC') list_graph=read_list_file(DictPathOut['liste_graph_afc'], self.encoding) self.tabAFCGraph = GraphPanelAfc(self.TabAFC, DictPathOut, list_graph, self.clnb, coding=self.encoding) self.TabAFC.AddPage(self.tabAFCGraph, 'AFC')