From: pierre Date: Fri, 21 Jun 2019 08:33:05 +0000 (+0200) Subject: ... X-Git-Url: http://iramuteq.org/git?a=commitdiff_plain;h=b53cfbfb3916c9510305a4786fa6e57242b4633f;p=iramuteq ... --- diff --git a/dialog.py b/dialog.py index c834e9e..9bf1e38 100755 --- a/dialog.py +++ b/dialog.py @@ -4,6 +4,7 @@ #Copyright (c) 2008-2009 Pierre Ratinaud #License: GNU/GPL import wx +import wx.html import wx.lib.colourselect as csel import wx.lib.sized_controls as sc import wx.lib.filebrowsebutton as filebrowse @@ -11,11 +12,12 @@ import locale from functions import DoConf, exec_rcode, translation_languages import os from shutil import copyfile -from PrintRScript import barplot, ChronoChi2Script, ChronoPropScript +from PrintRScript import barplot, ChronoChi2Script, ChronoPropScript, ChronoggScript import tempfile import sys from KeyFrame import AlcOptFrame import wx.lib.hyperlink as hl + #--------------------------------------------------------------------------- provider = wx.SimpleHelpProvider() wx.HelpProvider_Set(provider) @@ -96,7 +98,7 @@ class FileOptionDialog(wx.Dialog): elif sheet : label = wx.StaticText(self, -1, u"Feuille ") grid_sizer.Add(label, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5) - self.spin1 = wx.SpinCtrl(self, -1, '',size = (100,30), min=1, max=500) + self.spin1 = wx.SpinCtrl(self, -1, '',size = wx.DefaultSize, min=1, max=500) grid_sizer.Add(self.spin1, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5) sizer.Add(grid_sizer, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) @@ -546,54 +548,54 @@ class PrefGraph(wx.Dialog): if self.paramgraph['clnb'] <= 3 : choix = [u'2D', 'web 2D'] else : - choix=[u'2D' ,u'3D', 'web 2D', 'web 3D'] + choix=[u'2D' ,u'3D', 'web 2D', 'web 3D', 'Blender'] self.choicetype = wx.Choice(self, -1, (100,50), choices=choix) self.label_format = wx.StaticText(self, -1, _(u"Picture format").decode('utf8')) self.choix_format = wx.Choice(self, -1, (100,50), choices = ['png', 'svg']) self.label_1 = wx.StaticText(self, -1, _(u"width").decode('utf8')) - self.spin1 = wx.SpinCtrl(self, -1, '',size = (100,30), min=100, max=5000) + self.spin1 = wx.SpinCtrl(self, -1, '',size = wx.DefaultSize, min=100, max=5000) self.label_2 = wx.StaticText(self, -1, _(u"height").decode('utf8')) - self.spin2 = wx.SpinCtrl(self, -1, '', size = (100,30), min=100, max=5000) + self.spin2 = wx.SpinCtrl(self, -1, '', size = wx.DefaultSize, min=100, max=5000) self.label_what = wx.StaticText(self, -1, _(u"Representation").decode('utf8')) self.choice1 = wx.Choice(self, -1, (100,50), choices=[_(u"coordinates").decode('utf8'),_(u"correlations").decode('utf8')]) self.label_qui = wx.StaticText(self, -1, u'Variables') self.choice2 = wx.Choice(self, -1, (100,50), choices=[_(u"actives").decode('utf8') ,_(u"supplementaries").decode('utf8'), _(u"stars").decode('utf8'), _(u"clusters").decode('utf8')]) self.label_3 = wx.StaticText(self, -1, _(u"Text size").decode('utf8')) - self.spin3 = wx.SpinCtrl(self, -1, '', size = (100,30), min=1, max=20) + self.spin3 = wx.SpinCtrl(self, -1, '', size = wx.DefaultSize, min=1, max=20) txt = _(u"Take the x first points").decode('utf8') self.label_4 = wx.StaticText(self, -1, txt) self.check1 = wx.CheckBox(self, -1) - self.spin_nb = wx.SpinCtrl(self, -1, '', size = (100,30), min=2, max=1000) + self.spin_nb = wx.SpinCtrl(self, -1, '', size = wx.DefaultSize, min=2, max=1000) txt = _(u"Take the x first points by cluster").decode('utf8') self.label_chic = wx.StaticText(self, -1, txt) self.check_chic = wx.CheckBox(self, -1) - self.spin_nbchic = wx.SpinCtrl(self, -1, '', size = (100,30), min=2, max=1000) + self.spin_nbchic = wx.SpinCtrl(self, -1, '', size = wx.DefaultSize, min=2, max=1000) txt = _(u"Limit points by cluster chi2").decode('utf8') self.label_5 = wx.StaticText(self, -1, txt) self.check2 = wx.CheckBox(self, -1) - self.spin_chi = wx.SpinCtrl(self, -1, '',size = (100,30), min=2, max=1000) + self.spin_chi = wx.SpinCtrl(self, -1, '',size = wx.DefaultSize, min=2, max=1000) self.label_6 = wx.StaticText(self, -1, _(u"Avoid overlay").decode('utf8')) self.check3 = wx.CheckBox(self, -1) txt = _(u"Text size proportional to frequency").decode('utf8') self.label_7 = wx.StaticText(self, -1, txt) self.check4 = wx.CheckBox(self, -1) self.label_min = wx.StaticText(self, -1, 'min') - self.spin_min = wx.SpinCtrl(self, -1, '',size = (100,30), min = 1, max = 100) + self.spin_min = wx.SpinCtrl(self, -1, '',size = wx.DefaultSize, min = 1, max = 100) self.label_max = wx.StaticText(self, -1, 'max') - self.spin_max = wx.SpinCtrl(self, -1, '',size = (100,30), min = 1, max = 100) + self.spin_max = wx.SpinCtrl(self, -1, '',size = wx.DefaultSize, min = 1, max = 100) txt = _(u"Text size proportional to chi2").decode('utf8') self.label_tchi = wx.StaticText(self, -1, txt) self.check_tchi = wx.CheckBox(self, -1) self.label_min_tchi = wx.StaticText(self, -1, 'min') - self.spin_min_tchi = wx.SpinCtrl(self, -1, '', size = (100,30), min = 1, max = 100) + self.spin_min_tchi = wx.SpinCtrl(self, -1, '', size = wx.DefaultSize, min = 1, max = 100) self.label_max_tchi = wx.StaticText(self, -1, 'max') - self.spin_max_tchi = wx.SpinCtrl(self, -1, '', size = (100,30), min = 1, max = 100) + self.spin_max_tchi = wx.SpinCtrl(self, -1, '', size = wx.DefaultSize, min = 1, max = 100) self.label_8 = wx.StaticText(self, -1, _(u"Factor x : ").decode('utf8')) - self.spin_f1 = wx.SpinCtrl(self, -1, '',size = (100,30), min=1, max=self.paramgraph['clnb']-1) + self.spin_f1 = wx.SpinCtrl(self, -1, '',size = wx.DefaultSize, min=1, max=self.paramgraph['clnb']-1) self.label_9 = wx.StaticText(self, -1, _(u"Factor y : ").decode('utf8')) - self.spin_f2 = wx.SpinCtrl(self, -1, '',size = (100,30), min=1, max=self.paramgraph['clnb']-1) + self.spin_f2 = wx.SpinCtrl(self, -1, '',size = wx.DefaultSize, min=1, max=self.paramgraph['clnb']-1) self.label_f3 = wx.StaticText(self, -1, _(u"Factor z : ").decode('utf8')) - self.spin_f3 = wx.SpinCtrl(self, -1, '',size = (100,30), min=1, max=self.paramgraph['clnb']-1) + self.spin_f3 = wx.SpinCtrl(self, -1, '',size = wx.DefaultSize, min=1, max=self.paramgraph['clnb']-1) self.label_sphere = wx.StaticText(self, -1, _(u"Spheres transparency").decode('utf8')) self.slider_sphere = wx.Slider(self, -1, 10, 1, 100, size = (255,-1), style = wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS) @@ -1109,6 +1111,7 @@ class StatDialog ( wx.Dialog ): # Virtual event handlers, overide them in your derived class def OnKeys( self, event ): dial = AlcOptFrame(self, self.parent) + dial.corpus = self.corpus dial.CenterOnParent() dial.ShowModal() for i in range(0,len(dial.listlabel)): @@ -1267,7 +1270,7 @@ class PrefSegProf(wx.Dialog) : self.m_staticText3.Wrap( -1 ) fgSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - self.spin_min = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, (100,30), wx.SP_ARROW_KEYS, 2, 30, 2 ) + self.spin_min = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 2, 30, 2 ) self.spin_min.SetValue(2) fgSizer1.Add( self.spin_min, 0, wx.ALL, 5 ) @@ -1275,7 +1278,7 @@ class PrefSegProf(wx.Dialog) : self.m_staticText4.Wrap( -1 ) fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - self.spin_max = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, (100,30), wx.SP_ARROW_KEYS, 2, 30, 10 ) + self.spin_max = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 2, 30, 10 ) self.spin_max.SetValue(10) fgSizer1.Add( self.spin_max, 0, wx.ALL, 5 ) @@ -1283,7 +1286,7 @@ class PrefSegProf(wx.Dialog) : self.m_staticText5.Wrap( -1 ) fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - self.spin_eff = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, (100,30), wx.SP_ARROW_KEYS, 4, 1000, 4 ) + self.spin_eff = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 4, 1000, 4 ) self.spin_eff.SetValue(4) fgSizer1.Add( self.spin_eff, 0, wx.ALL, 5 ) @@ -1755,7 +1758,7 @@ class OptLexi(wx.Dialog): def __init__(self, parent, force_chi = False): # begin wxGlade: MyDialog.__init__ #kwds["style"] = wx.DEFAULT_DIALOG_STYLE - wx.Dialog.__init__(self, parent, style = wx.DEFAULT_DIALOG_STYLE) + wx.Dialog.__init__(self, parent, style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.listet = None self.variables = None self.force_chi = force_chi @@ -1770,7 +1773,7 @@ class OptLexi(wx.Dialog): self.label_var = wx.StaticText(self, -1, _(u"Select by").decode('utf8')) self.choice = wx.Choice(self, -1, (100,50), choices = [_(u"variables").decode('utf8'), _(u"modalities").decode('utf8')]) self.label1 = wx.StaticText(self, -1, _(u"Choice").decode('utf8')) - self.list_box_1 = wx.ListBox(self, -1, choices=[], size = wx.Size( 150,200 ), style=wx.LB_EXTENDED | wx.LB_HSCROLL) + self.list_box_1 = wx.ListBox(self, -1, choices=[], size = wx.Size( 300,200 ), style=wx.LB_EXTENDED | wx.LB_HSCROLL) self.button_2 = wx.Button(self, wx.ID_CANCEL, "") self.button_1 = wx.Button(self, wx.ID_OK, "") if not self.force_chi : @@ -1781,7 +1784,7 @@ class OptLexi(wx.Dialog): self.choice_indice = wx.Choice(self, -1, (100,50), choices = indices) if not self.force_chi : self.label = wx.StaticText(self, -1, _(u"Minimum frequency").decode('utf8')) - self.spin = wx.SpinCtrl(self, -1, min = 1, max = 10000, initial = 10) + self.spin = wx.SpinCtrl(self, -1, min = 1, max = 10000, initial = 10, size=wx.DefaultSize) self.Bind(wx.EVT_CHOICE, self.onselect, self.choice) self.Bind(wx.EVT_LISTBOX, self.onchoose, self.list_box_1) self.__set_properties() @@ -1812,7 +1815,7 @@ class OptLexi(wx.Dialog): sizer_2.Add(self.label_var, 0, wx.ALIGN_CENTER_VERTICAL, 3) sizer_2.Add(self.choice, 0, wx.ALIGN_CENTER_VERTICAL, 3) sizer_2.Add(self.label1, 0, wx.ALIGN_CENTER_VERTICAL, 3) - sizer_2.Add(self.list_box_1, 0, wx.ALIGN_RIGHT, 3) + sizer_2.Add(self.list_box_1, 0, wx.ALIGN_RIGHT|wx.EXPAND, 3) sizer_3.Add(self.button_2, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3) sizer_3.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3) sizer_2.Add(self.label_indice, 0, wx.ALIGN_CENTER_VERTICAL, 3) @@ -1850,9 +1853,9 @@ class OptLexi(wx.Dialog): class PrefDendro ( wx.Dialog ): - def __init__( self, parent, param ): + def __init__( self, parent, parametres ): wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Dendrogram").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE ) - self.param = param + self.parametres = parametres self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 ) @@ -1924,7 +1927,7 @@ class PrefDendro ( wx.Dialog ): self.m_staticline41 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) fgSizer1.Add( self.m_staticline41, 0, wx.EXPAND |wx.ALL, 5 ) - if self.param['typedendro'] == 'classique' : + if self.parametres['typedendro'] == 'classique' : self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Color or black and white").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText5.Wrap( -1 ) fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) @@ -1963,13 +1966,13 @@ class PrefDendro ( wx.Dialog ): self.m_staticline8 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) fgSizer1.Add( self.m_staticline8, 0, wx.EXPAND |wx.ALL, 5 ) - if self.param.get('translation', False) : + if self.parametres.get('translation', False) : self.m_staticText66 = wx.StaticText( self, wx.ID_ANY, _(u"Translation").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText66.Wrap( -1 ) fgSizer1.Add( self.m_staticText66, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) m_choice1Choices = [ u"phylogram", u"cladogram", u"fan", u"unrooted", u"radial" ] - self.trans = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, ['None'] + [val[0] for val in self.param['translation']], 0 ) + self.trans = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, ['None'] + [val[0] for val in self.parametres['translation']], 0 ) self.trans.SetSelection( 0 ) fgSizer1.Add( self.trans, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) @@ -1991,14 +1994,14 @@ class PrefDendro ( wx.Dialog ): self.Centre( wx.BOTH ) def __set_properties(self): - self.m_spinCtrl2.SetValue(self.param['width']) - self.m_spinCtrl1.SetValue(self.param['height']) - self.m_choice1.SetSelection(self.param['type_dendro']) - self.choice_format.SetSelection(self.param['svg']) - if self.param['typedendro'] == 'classique' : - self.m_radioBox1.SetSelection(self.param['color_nb']) - self.m_checkBox1.SetValue(self.param['taille_classe']) - self.m_radioBox2.SetSelection(self.param['type_tclasse']) + self.m_spinCtrl2.SetValue(self.parametres['width']) + self.m_spinCtrl1.SetValue(self.parametres['height']) + self.m_choice1.SetSelection(self.parametres['type_dendro']) + self.choice_format.SetSelection(self.parametres['svg']) + if self.parametres['typedendro'] == 'classique' : + self.m_radioBox1.SetSelection(self.parametres['color_nb']) + self.m_checkBox1.SetValue(self.parametres['taille_classe']) + self.m_radioBox2.SetSelection(self.parametres['type_tclasse']) def __del__( self ): pass @@ -2034,7 +2037,7 @@ class PrefWordCloud ( wx.Dialog ): self.m_staticText3.Wrap( -1 ) bSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 ) - self.spin_H = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 100,30 ), wx.SP_ARROW_KEYS, 0, 10000, 600 ) + self.spin_H = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 10000, 600 ) self.spin_H.SetValue( 800 ) bSizer1.Add( self.spin_H, 0, wx.ALL, 5 ) @@ -2046,7 +2049,7 @@ class PrefWordCloud ( wx.Dialog ): self.m_staticText4.Wrap( -1 ) bSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 ) - self.spin_L = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 100,30 ), wx.SP_ARROW_KEYS, 0, 10000, 600 ) + self.spin_L = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 10000, 600 ) self.spin_L.SetValue( 800 ) bSizer3.Add( self.spin_L, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) @@ -2674,6 +2677,7 @@ class ConcordList(wx.HtmlListBox): class message(wx.Frame): def __init__(self, parent, items, title, size, save = True, uceids = None): wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = title, pos = wx.DefaultPosition, size = size, style = wx.CLOSE_BOX|wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.TAB_TRAVERSAL ) + self.parent = parent self.save = save self.uceids = uceids self.ira = wx.GetApp().GetTopWindow() @@ -2692,6 +2696,8 @@ class message(wx.Frame): self.button_1 = wx.Button(self.panel, wx.ID_CANCEL) self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1) + #self.HtmlPage.Bind(wx.wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, self.Download) + self.HtmlPage.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLink) if self.save : self.button_2 = wx.Button(self.panel, wx.ID_SAVE) self.Bind(wx.EVT_BUTTON, self.OnSavePage, self.button_2) @@ -2731,6 +2737,19 @@ class message(wx.Frame): with open(path, 'w') as f : f.write(self.html) + def OnLink(self, evt): + corpus = self.ira.tree.page.corpus + link = evt.GetLinkInfo().GetHref().split('_') + uciid = int(link[0]) + uceid = int(link[1]) + et = '' + ' '.join(corpus.ucis[uciid].etoiles) + '
\n' + txt = corpus.getuciconcorde_uces(uciid, uceid) + txt = '\n'.join([row[1] + '
' if row[0] != uceid else '%s
' % row[1] for row in txt]) + txt = '\n\n' + et + txt + '\n\n' + fullframe = FullText(self.ira) + fullframe.m_htmlWin1.SetPage(txt) + fullframe.Show() + def OnCloseMe(self, event): self.Close(True) @@ -3336,7 +3355,7 @@ class ImageViewer ( wx.Frame ): def OnSaveImage(self, event) : dlg = wx.FileDialog( - self, message=_(u"Save as...").decode('utf8'), defaultDir=os.getcwd(), + self, message=_(u"Save as...").decode('utf8'), defaultDir=self.parametres.get('pathout',os.getcwd()), defaultFile= self.imagename, wildcard=self.parametres['wildcard'], style=wx.SAVE | wx.OVERWRITE_PROMPT ) dlg.SetFilterIndex(0) @@ -3362,9 +3381,12 @@ class BarFrame : if dial.format.GetSelection() == 0 : svg = 'FALSE' wildcard = "png|*.png" + fout = 'image.png' else : svg = 'TRUE' wildcard = "svg|*.svg" + fout = 'image.svg' + pathout = ira.tree.page.pathout[fout] parametres = {'width' : dial.widthsp.GetValue(), 'height': dial.heightsp.GetValue(), 'colnames' : colnames, @@ -3372,7 +3394,9 @@ class BarFrame : 'tmpgraph' : tmpgraph, 'rgraph' : ira.RscriptsPath['Rgraph'], 'svg' : svg, - 'wildcard' : wildcard} + 'wildcard' : wildcard, + 'pathout': pathout + } if tree : parametres['tree'] = tree txt = barplot(table, parametres) @@ -3409,8 +3433,10 @@ class ChronoFrame : self.parametres.update(parametres) if which == 'chi2' : script = ChronoChi2Script(self) - else : + elif which == 'prop' : script = ChronoPropScript(self) + elif which == 'gg' : + script = ChronoggScript(self) script.make_script() exec_rcode(ira.RPath, script.scriptout, wait = True) win = ImageViewer(ira, self.parametres, _(u"Graphic").decode('utf8'), size=(700, 500)) @@ -3796,3 +3822,47 @@ class MergeClusterFrame ( wx.Dialog ): self.m_listBox4.Delete(val) event.Skip() + +class FullText ( wx.Frame ): + + def __init__( self, parent ): + wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 500,600 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) + + self.SetSizeHints( -1, -1 ) + + bSizer1 = wx.BoxSizer( wx.VERTICAL ) + + self.m_panel1 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) + bSizer2 = wx.BoxSizer( wx.VERTICAL ) + + self.m_htmlWin1 = wx.html.HtmlWindow( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.html.HW_SCROLLBAR_AUTO ) + bSizer2.Add( self.m_htmlWin1, 8, wx.ALL | wx.EXPAND, 5 ) + + #self.m_richText1 = wx.richtext.RichTextCtrl( self.m_panel1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0|wx.VSCROLL|wx.HSCROLL|wx.NO_BORDER|wx.WANTS_CHARS ) + #bSizer2.Add( self.m_richText1, 9, wx.EXPAND |wx.ALL, 5 ) + + m_sdbSizer1 = wx.StdDialogButtonSizer() + self.m_sdbSizer1OK = wx.Button( self.m_panel1, wx.ID_OK ) + m_sdbSizer1.AddButton( self.m_sdbSizer1OK ) + self.m_sdbSizer1Cancel = wx.Button( self.m_panel1, wx.ID_CANCEL ) + m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel ) + m_sdbSizer1.Realize(); + + bSizer2.Add( m_sdbSizer1, 0, wx.EXPAND, 5 ) + + + self.m_panel1.SetSizer( bSizer2 ) + self.m_panel1.Layout() + bSizer2.Fit( self.m_panel1 ) + bSizer1.Add( self.m_panel1, 1, wx.EXPAND |wx.ALL, 5 ) + + + self.SetSizer( bSizer1 ) + self.Layout() + + self.Centre( wx.BOTH ) + + def __del__( self ): + pass + + diff --git a/iramuteq.py b/iramuteq.py old mode 100644 new mode 100755 index c84dd0d..501b0f6 --- a/iramuteq.py +++ b/iramuteq.py @@ -45,7 +45,7 @@ from tabsimi import DoSimi from tabrsimple import InputText from tabverges import Prototypical from tabsplitvar import SplitMatrixFromVar -#from textdist import AnalysePam +#frog textdist import AnalysePam from textstat import Stat from textaslexico import Lexico from textlabbe import DistLabbe @@ -54,7 +54,7 @@ from textwordcloud import WordCloud, ClusterCloud from textreinert import Reinert #from textcheckcorpus import checkcorpus from openanalyse import OpenAnalyse -from corpus import Builder, SubBuilder +from corpus import Builder, SubBuilder, MergeClusters from checkinstall import CreateIraDirectory, CheckRPath, FindRPAthWin32, FindRPathNix, CheckRPackages, IsNew, UpgradeConf, CopyConf, RLibsAreInstalled from chemins import RscriptsPath, ConstructConfigPath, ConstructDicoPath, ConstructGlobalPath, PathOut from parse_factiva_xml import ImportFactiva @@ -104,6 +104,7 @@ ID_Fact_copy = wx.NewId() ID_exportmeta = wx.NewId() ID_importdmi = wx.NewId() ID_merge = wx.NewId() +ID_merge_clusters = wx.NewId() ID_labbe = wx.NewId() ########################################################## #elements de configuration @@ -177,6 +178,7 @@ code_langues = {'french' : 'fr_FR', images_analyses = { 'textroot' : 'textroot.png', 'alceste' : 'reinert.png', + 'reinert' : 'reinert.png', 'corpus' : 'textcorpus.png', 'wordcloud' :'wordcloud.png', 'stat' :'stats.png', @@ -211,8 +213,8 @@ images_analyses = { class IraFrame(wx.Frame): def __init__(self, parent, id= -1, title="", pos=wx.DefaultPosition, - size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE | - wx.SUNKEN_BORDER | + size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE | + wx.SUNKEN_BORDER | wx.CLIP_CHILDREN): log.info('Starting... ' ) log.info('version : %s' % ConfigGlob.get('DEFAULT', 'version')) @@ -242,7 +244,7 @@ class IraFrame(wx.Frame): self.setlangue() #self.presLan_fr = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=['fr_FR']) #self.presLan_en = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=['en']) - # tell FrameManager to manage this frame + # tell FrameManager to manage this frame #self._mgr = wx.aui.AuiManager() self._mgr = aui.AuiManager() self._mgr.SetManagedWindow(self) @@ -259,11 +261,11 @@ class IraFrame(wx.Frame): #item.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN)) item.SetBitmap(self.images_analyses['matroot']) file_menu.AppendItem(item) - + item = wx.MenuItem(file_menu, ID_OpenText, _(u"Open a text corpus").decode('utf8'), _(u"Open a text corpus").decode('utf8')) item.SetBitmap(self.images_analyses['textroot']) file_menu.AppendItem(item) - + item = wx.MenuItem(file_menu, ID_OnOpenAnalyse, _(u"Open an analysis").decode('utf8'), _(u"Open an analysis").decode('utf8')) item.SetBitmap(self.images_analyses['iramuteq']) file_menu.AppendItem(item) @@ -283,6 +285,9 @@ class IraFrame(wx.Frame): item = wx.MenuItem(file_menu, ID_merge, _(u'Merge graphs').decode('utf8'), _(u'Merge graphs').decode('utf8')) file_menu.AppendItem(item) + item = wx.MenuItem(file_menu, ID_merge_clusters, _(u'Corpus from merge clusters').decode('utf8'), _(u'Corpus from merge clusters').decode('utf8')) + file_menu.AppendItem(item) + menuFactiva = wx.Menu() fact_from_xml = wx.MenuItem(menuFactiva, ID_Fact_xml, _(u"from xml").decode('utf8')) fact_from_xml.SetBitmap(self.images_analyses['factiva_xml']) @@ -372,7 +377,7 @@ class IraFrame(wx.Frame): #matrix_menu.Append(ID_SIMI, _(u"Similarities Analysis").decode('utf8')) #matrix_menu.Append(ID_proto, _(u"Prototypical Analysis").decode('utf8')) ID_RCODE = wx.NewId() - #matrix_menu.Append(ID_RCODE, u"Code R...") + #matrix_menu.Append(ID_RCODE, u"Code R...") #menu_splittab = wx.Menu() #ID_SPLITVAR = wx.NewId() #splitvar = wx.MenuItem(menu_splittab, ID_SPLITVAR, _(u"Split from variable").decode('utf8')) @@ -414,8 +419,8 @@ class IraFrame(wx.Frame): # menu_classiftxt.Append(ID_TEXTREINERT, _(u"Reinert's Method").decode('utf8')) # #menu_classiftxt.Append(ID_TEXTPAM, u"Par matrice des distances") # text_menu.AppendMenu(-1, _(u"Clustering").decode('utf8'), menu_classiftxt) -# text_menu.Append(ID_SimiTxt, _(u"Similarities Analysis").decode('utf8')) -# +# text_menu.Append(ID_SimiTxt, _(u"Similarities Analysis").decode('utf8')) +# # text_menu.Append(ID_WC, _(u"WordCloud").decode('utf8')) self.text_menu = text_menu @@ -504,7 +509,7 @@ class IraFrame(wx.Frame): self.text_ctrl_txt = wx.TextCtrl(self, -1, "", wx.Point(0, 0), wx.Size(200, 200), wx.NO_BORDER | wx.TE_MULTILINE | wx.TE_RICH2 | wx.TE_READONLY) #self._mgr.AddPane(self.text_ctrl_txt, wx.aui.AuiPaneInfo(). - # Name("Text").CenterPane()) + # Name("Text").CenterPane()) self._mgr.AddPane(self.text_ctrl_txt, aui.AuiPaneInfo(). Name("Text").CenterPane()) #self._mgr.AddPane(IntroPanel(self), wx.aui.AuiPaneInfo().Name("Intro_Text"). @@ -515,6 +520,7 @@ class IraFrame(wx.Frame): # with open(os.path.join(UserConfigPath, 'history.db'), 'w') as f : # f.write('') self.history = History(os.path.join(UserConfigPath, 'history.db')) + #self.history.dostat() self.tree = LeftTree(self) self._mgr.AddPane(self.tree, aui.AuiPaneInfo().Name("lefttree").Caption(_(u"Historic").decode('utf8')). Left().MinSize(wx.Size(200,500)).Layer(1).Position(1).CloseButton(False).MaximizeButton(True). @@ -571,11 +577,11 @@ class IraFrame(wx.Frame): self.ShowAPane("Intro_Text") self._mgr.GetPane("lefttree").Show() self._mgr.GetPane("classif_tb").Hide() - # "commit" all changes made to FrameManager + # "commit" all changes made to FrameManager self._mgr.Update() # Show How To Use The Closing Panes Event -################################################################## +################################################################## self.Bind(wx.EVT_MENU, self.OnAcceuil, id=ID_ACCEUIL) self.Bind(wx.EVT_MENU, self.ShowTab, id=ID_RESULT) self.Bind(wx.EVT_MENU, self.OnOpenData, id=ID_OpenData) @@ -621,6 +627,7 @@ class IraFrame(wx.Frame): self.Bind(wx.EVT_MENU, self.OnImportDMI, id=ID_importdmi) self.Bind(wx.EVT_MENU, self.OnExportMeta, id=ID_exportmeta) self.Bind(wx.EVT_MENU, self.OnMergeGraph, id = ID_merge) + self.Bind(wx.EVT_MENU, self.OnMergeClusters, id = ID_merge_clusters) self.Bind(wx.EVT_CLOSE, self.OnClose) ################################################################## flags = self._mgr.GetAGWFlags() @@ -662,7 +669,7 @@ class IraFrame(wx.Frame): self.ShowMenu('view', True) self.ShowMenu('matrix', False) self.ShowMenu('text', False) - + self._mgr.Update() self.DataPop = False @@ -799,7 +806,7 @@ class IraFrame(wx.Frame): self.filename = self.input_path[0] if inputname: self.OpenText() - + def OnSubText(self, evt, corpus = None, parametres = None): if corpus is None : corpus = self.tree.getcorpus() @@ -816,7 +823,7 @@ class IraFrame(wx.Frame): OpenAnalyse(self, corpus.parametres) self.tree.OnItemAppend(corpus.parametres) del busy - + def OpenText(self): builder = Builder(self, 5) if builder.res == wx.ID_OK : @@ -840,7 +847,7 @@ class IraFrame(wx.Frame): count += 1 keepGoing = builder.dlg.Update(count, u"Chargement du dictionnaire") builder.dlg.Destroy() - + def OnExit(self, event): self.Close() @@ -851,7 +858,7 @@ class IraFrame(wx.Frame): info.Copyright = ConfigGlob.get('DEFAULT', 'copyright') info.Translators = ConfigGlob.get('DEFAULT', 'translators').decode('utf8').split(';') info.Description = u""" -Interface de R pour les Analyses Multidimensionnelles +Interface de R pour les Analyses Multidimensionnelles de Textes et de Questionnaires Un logiciel libre @@ -864,7 +871,7 @@ REPERE info.WebSite = ("http://www.iramuteq.org", u"Site web IRaMuTeQ") dev = ConfigGlob.get('DEFAULT', 'dev').decode('utf8').split(';') info.Developers = dev - info.License = u"""Iramuteq est un logiciel libre ; vous pouvez le diffuser et/ou le modifier + info.License = u"""Iramuteq est un logiciel libre ; vous pouvez le diffuser et/ou le modifier suivant les termes de la Licence Publique Générale GNU telle que publiée par la Free Software Foundation ; soit la version 2 de cette licence, soit (à votre convenance) une version ultérieure. @@ -915,7 +922,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis.""" if self.nb.GetPageCount() == 1 and not notebook : self.LastTabClose() - + def LastTabClose(self) : if self.nb.GetPageCount() == 1 : if self.DataTxt : @@ -1024,6 +1031,17 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis.""" #FIXME AnalyseMerge(self, {'type': 'merge', 'fileout' : '/tmp/test.txt'}, dlg = 5) + def OnMergeClusters(self, evt) : + builder = MergeClusters(self, {}) + if builder.res == wx.ID_OK : + busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self) + wx.SafeYield() + corpus = builder.doanalyse() + self.history.add(corpus.parametres) + OpenAnalyse(self, corpus.parametres) + self.tree.OnItemAppend(corpus.parametres) + del busy + def OnProto(self, evt, matrix = None) : self.analyse_matrix(Prototypical, matrix = matrix, analyse_type = 'proto', dlgnb = 3) #Prototypical(self, {'type' : 'proto'}) @@ -1183,7 +1201,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis.""" def SimiCluster(self, parametres = {}, fromprof = False, tableau = None) : self.analyse_matrix(DoSimi, parametres = parametres, analyse_type = 'simiclustermatrix', matrix = tableau, dlgnb = 5) - + # def OnSimi(self,evt): # try : #print 'ATTENTION !!!! VERGES' @@ -1198,7 +1216,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis.""" def OnHelp(self, event): webbrowser.open('http://www.iramuteq.org/documentation') - + def OnPref(self, event): dlg = PrefDialog(self) dlg.CenterOnParent() @@ -1209,7 +1227,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis.""" if self.check_update: NewVersion(self) else: - print 'pas de verif' + print 'pas de verif' #IsNew(self) #CheckRPackages(self) @@ -1247,8 +1265,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis.""" OpenAnalyse(self, self.filename) if not truepath: print 'This file does not exist' - - + class IntroPanel(wx.Panel): def __init__(self, parent): @@ -1270,7 +1287,7 @@ class IntroPanel(wx.Panel): grid_sizer_1 = wx.FlexGridSizer(1, 4, 0, 0) grid_sizer_3 = wx.FlexGridSizer(1, 4, 0, 0) grid_sizer_2 = wx.BoxSizer(wx.HORIZONTAL) - + iralink = hl.HyperLinkCtrl(self, wx.ID_ANY, u"http://www.iramuteq.org", URL="http://www.iramuteq.org") iralink.SetColours(linkcolor, linkcolor, "RED") iralink.SetBackgroundColour(bckgrdcolor) @@ -1278,19 +1295,19 @@ class IntroPanel(wx.Panel): iralink.SetUnderlines(False, False, True) iralink.SetBold(True) iralink.UpdateLink() - + PanelPres = wx.Panel(self) bckgrdcolor = wx.Colour(randint(0, 255), randint(0, 255), randint(0, 255)) PanelPres.SetBackgroundColour(bckgrdcolor) - + label_1 = wx.StaticText(self, -1, u"IRaMuTeQ", size=(-1, -1)) label_1.SetFont(wx.Font(46, wx.TELETYPE, wx.NORMAL, wx.BOLD, 0, "Purisa")) label_1.SetForegroundColour(wx.RED) - + iraicone = wx.Image(os.path.join(ImagePath,'iraicone100x100.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap() but_ira = wx.StaticBitmap(self, -1, bitmap = iraicone) - + label2 = wx.StaticText(PanelPres, -1 , u'\nVersion ' + ConfigGlob.get('DEFAULT', 'version') + '\n') label2.SetForegroundColour(txtcolour) label2.SetBackgroundColour(bckgrdcolor) @@ -1301,11 +1318,11 @@ class IntroPanel(wx.Panel): self.hyper2.SetUnderlines(False, False, True) self.hyper2.SetBold(True) self.hyper2.UpdateLink() - + label_lerass = wx.StaticText(PanelPres, -1, u'Laboratoire ') label_lerass.SetForegroundColour(txtcolour) label_lerass.SetBackgroundColour(bckgrdcolor) - + self.hyper_lerass = hl.HyperLinkCtrl(PanelPres, -1, u'LERASS', URL="http://www.lerass.com") self.hyper_lerass.SetColours(linkcolor, linkcolor, "RED") self.hyper_lerass.SetBackgroundColour(bckgrdcolor) @@ -1313,18 +1330,18 @@ class IntroPanel(wx.Panel): self.hyper_lerass.SetUnderlines(False, False, True) self.hyper_lerass.SetBold(True) self.hyper_lerass.UpdateLink() - + blank = wx.StaticText(PanelPres, -1, u'\n') blank1 = wx.StaticText(PanelPres, -1, u'\n') - + labellicence = wx.StaticText(PanelPres, -1, _(u"License GNU GPL").decode('utf8')) labellicence.SetForegroundColour(txtcolour) labellicence.SetBackgroundColour(bckgrdcolor) - + labelcopy = wx.StaticText(PanelPres, -1, ConfigGlob.get('DEFAULT', 'copyright')) labelcopy.SetForegroundColour(txtcolour) labelcopy.SetBackgroundColour(bckgrdcolor) - + python_img = wx.Image(os.path.join(ImagePath,'python-logo.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap() r_img = wx.Image(os.path.join(ImagePath,'Rlogo.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap() lexique_img = wx.Image(os.path.join(ImagePath,'LexTexte4.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap() @@ -1334,13 +1351,12 @@ class IntroPanel(wx.Panel): self.Bind(wx.EVT_BUTTON, self.OnPython, but_python) self.Bind(wx.EVT_BUTTON, self.OnLexique, but_lexique) self.Bind(wx.EVT_BUTTON, self.OnR, but_r) - - + grid_sizer_1.Add(self.hyper2, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0) grid_sizer_3.Add(label_lerass, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0) grid_sizer_3.Add(self.hyper_lerass, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0) sizer4.Add(label_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5) - + sizer2.Add(label2, 0, wx.ALIGN_CENTER, 5) sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 5) sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 5) @@ -1357,18 +1373,18 @@ class IntroPanel(wx.Panel): grid_sizer_2.Add(but_python, 1, wx.ALIGN_BOTTOM) grid_sizer_2.Add(but_lexique, 1, wx.ALIGN_BOTTOM) grid_sizer_2.Add(but_r, 1, wx.ALIGN_BOTTOM) - + sizer1.Add(PanelPres, 0, wx.EXPAND |wx.ALL, 10) sizer1.Add(grid_sizer_2, 2, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 1) self.SetSizer(sizer1) sizer1.Fit(self) - + def OnPython(self,evt): webbrowser.open('http://www.python.org') - + def OnLexique(self,evt): webbrowser.open('http://www.lexique.org') - + def OnR(self,evt): webbrowser.open('http://www.r-project.org') @@ -1384,7 +1400,7 @@ class MySplashScreen(wx.SplashScreen): def OnClose(self, evt): evt.Skip() self.Hide() - + if self.fc.IsRunning(): self.fc.Stop() self.ShowMain() @@ -1401,7 +1417,7 @@ class MySplashScreen(wx.SplashScreen): # if self.fc.IsRunning(): # self.Raise() #wx.CallAfter(frame.ShowTip) - + class MyApp(wx.App): def OnInit(self): """ @@ -1409,7 +1425,7 @@ class MyApp(wx.App): the main frame when it is time to do so. """ wx.SystemOptions.SetOptionInt("mac.window-plain-transition", 1) - self.SetAppName("Iramuteq") + self.SetAppName("Iramuteq") splash = MySplashScreen() splash.Show() return True