X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=guifunct.py;h=e97c04b7d5314a74f10e32b5987e61e0d3356c64;hp=4f6fa05162b8571891f91a14111eb162e8b82e7b;hb=3414a4710a5bdf52e2172e08f6da20465ca92e4a;hpb=2560c66bef5e023dbce18c556363ec956bd15e47;ds=sidebyside diff --git a/guifunct.py b/guifunct.py index 4f6fa05..e97c04b 100644 --- a/guifunct.py +++ b/guifunct.py @@ -10,7 +10,11 @@ from copy import copy from dialog import FileOptionDialog, SelectColDial, OptLexi, PrefSimpleFile from listlex import * from vitemspicker import VItemsPicker, EVT_IP_SELECTION_CHANGED, IP_SORT_CHOICES, IP_SORT_SELECTED, IP_REMOVE_FROM_CHOICES -from functions import treat_var_mod +from functions import treat_var_mod, print_liste, exec_rcode, check_Rresult, DoConf, read_list_file, indices_simi +import codecs +import wx.lib.hyperlink as hl +from webexport import WebExport +from PrintRScript import PrintSimiScript #from wx import GetTopLevelWindows @@ -252,7 +256,7 @@ class PrefSimi ( wx.Dialog ): self.m_staticText5.Wrap( -1 ) fgSizer3.Add( self.m_staticText5, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) - choice3Choices = [ u"dynamique", u"statique", u"3D"]#, u'web2D', u"web3D" ] + choice3Choices = [ u"dynamique", u"statique", u"3D", u'web2D', u"web3D" ] self.choice3 = wx.Choice( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choice3Choices, 0 ) self.choice3.SetSelection( 0 ) @@ -982,7 +986,7 @@ class PrepSimi : param['vlabcolor'] = self.parametres['vlabcolor'] if 'check_bystar' in dir(self.dial) : param['bystar'] = self.dial.check_bystar.GetValue() - param['stars'] = self.parametres['stars'] + param['stars'] = self.parametres.get('stars', 0) self.parametres.update(param) class CreateTgenDialog ( wx.Frame ): @@ -999,36 +1003,43 @@ class CreateTgenDialog ( wx.Frame ): bSizer2 = wx.BoxSizer( wx.VERTICAL ) + namepan = wx.Panel(self, -1) + fgSizer3 = wx.FlexGridSizer( 0, 2, 0, 0 ) fgSizer3.SetFlexibleDirection( wx.BOTH ) fgSizer3.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) - self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"Name").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText3 = wx.StaticText( namepan, wx.ID_ANY, _(u"Name").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText3.Wrap( -1 ) + fgSizer3.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 ) - self.m_textCtrl1 = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_textCtrl1 = wx.TextCtrl( namepan, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_textCtrl1.SetMinSize( wx.Size( 250,-1 ) ) - fgSizer3.Add( self.m_textCtrl1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + namepan.SetSizer( fgSizer3 ) - bSizer2.Add( fgSizer3, 1, wx.ALIGN_CENTER_HORIZONTAL, 5 ) + bSizer2.Add( namepan, 1, wx.EXPAND, 5 ) self.ip = VItemsPicker(self,-1, lemlist, _(u'Forms').decode('utf8'), _('Selection').decode('utf8')) self.ip._source.SetMinSize( wx.Size( 350, 400 ) ) bSizer2.Add( self.ip, 0, wx.ALL, 5 ) + butpanel = wx.Panel(self, -1) + m_sdbSizer3 = wx.StdDialogButtonSizer() - self.m_sdbSizer3OK = wx.Button( self, wx.ID_OK ) + self.m_sdbSizer3OK = wx.Button( butpanel, wx.ID_OK ) m_sdbSizer3.AddButton( self.m_sdbSizer3OK ) - self.m_sdbSizer3Cancel = wx.Button( self, wx.ID_CANCEL ) + self.m_sdbSizer3Cancel = wx.Button( butpanel, wx.ID_CANCEL ) m_sdbSizer3.AddButton( self.m_sdbSizer3Cancel ) m_sdbSizer3.Realize(); - bSizer2.Add( m_sdbSizer3, 1, wx.EXPAND, 5 ) + butpanel.SetSizer( m_sdbSizer3 ) + + bSizer2.Add( butpanel, 1, wx.EXPAND, 5 ) self.SetSizer( bSizer2 ) @@ -1148,6 +1159,7 @@ class TGenFrame ( wx.Frame ): bSizer1.Add( fgSizer1, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 ) + m_sdbSizer2 = wx.StdDialogButtonSizer() self.m_sdbSizer2OK = wx.Button( self.panel, wx.ID_OK ) m_sdbSizer2.AddButton( self.m_sdbSizer2OK ) @@ -1248,9 +1260,81 @@ class ExportMetaTable : fileout = dial.fbb.GetValue() dial.Destroy() corpus.export_meta_table(fileout) - dlg = wx.MessageDialog(self.ira, _("Done !").decode('utf8'), _(u"Export metadata").decode('utf8'), wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION) + dlg = wx.MessageDialog(self.ira, _("Done !").decode('utf8'), _(u"Export metadata").decode('utf8'), wx.OK | wx.ICON_INFORMATION) dlg.CenterOnParent() dlg.ShowModal() dlg.Destroy() else : dial.Destroy() + + +def redosimi(self, evt) : + with open(self.pathout['selected.csv'],'r') as f : + selected = f.read() + selected = [int(val) for val in selected.splitlines()] + if self.actives is None : + with codecs.open(self.pathout['actives.csv'], 'r', self.parametres['encoding']) as f : + self.actives = f.read() + self.actives = self.actives.splitlines()#[act for act in self.actives.splitlines()] + if os.path.exists(self.pathout['actives_nb.csv']) : + with open(self.pathout['actives_nb.csv'], 'r') as f : + act_nb = f.read() + act_nb = act_nb.splitlines() + dictcol = dict([[i, [self.actives[i], int(act_nb[i])]] for i, val in enumerate(self.actives)]) + else : + dictcol = dict([[i, [act, self.corpus.getlemeff(act)]] for i, act in enumerate(self.actives)]) + #res = SelectColumn(self.ira, dictcol, self.actives, self.pathout['selected.csv'], selected = selected, dlg = True) + #if res.ok : + if evt is not None : + prep = PrepSimi(self.ira, self, self.parametres,self.pathout['selected.csv'], self.actives, indices_simi, wordlist = dictcol, selected = selected) + else : + class EmptyBase(object): pass + prep = EmptyBase() + prep.val = wx.ID_OK + prep.parametres = self.parametres + order_actives = [[i, act, self.corpus.getlemeff(act)] for i, act in enumerate(self.actives)] + order_actives = sorted(order_actives, key=itemgetter(2), reverse = True) + with open(self.pathout['selected.csv'], 'w') as f : + f.write('\n'.join([`order_actives[val][0]` for val in self.parametres['selected']])) + if prep.val == wx.ID_OK or evt is None: + self.parametres = prep.parametres + + script = PrintSimiScript(self) + script.make_script() + pid = exec_rcode(self.ira.RPath, script.scriptout, wait = True) + check_Rresult(self.ira, pid) + if self.parametres['type_graph'] in [1,3] : + if self.parametres['svg'] : + filename, ext = os.path.splitext(script.filename) + fileout = filename + '.svg' + elif self.parametres['type_graph'] == 3 : + fileout = script.filename + parametres = {'gexffile' : fileout, + 'dirout' : os.path.dirname(fileout), + 'titre': 'Le titre', + #'nodemin': self.param['txt_min'], + #'nodemax': self.param['txt_max'], + #'bargraphw' : 60*int(self.param['clnb']), + } + web = WebExport(self.ira, parametres) + fileout = web.exportsimi() + else : + fileout = script.filename + if os.path.exists(self.pathout['liste_graph']): + graph_simi = read_list_file(self.pathout['liste_graph']) + graph_simi.append([os.path.basename(fileout), script.txtgraph]) + else : + graph_simi = [[os.path.basename(fileout), script.txtgraph]] + self.fileout = fileout + print_liste(self.pathout['liste_graph'], graph_simi) + DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira']) + if evt is not None : + if self.parametres['type_graph'] in [1,3] : + if self.parametres['svg'] or self.parametres['type_graph'] == 3 : + self.graphpan.sizer_3.Add(hl.HyperLinkCtrl(self.graphpan.panel_1, -1, fileout, URL = fileout), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) + else : + 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) + self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1, script.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) + self.graphpan.sizer_3.Fit(self.graphpan.panel_1) + self.graphpan.Layout() + self.graphpan.panel_1.Scroll(0,self.graphpan.panel_1.GetScrollRange(wx.VERTICAL)) \ No newline at end of file