1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2008-2011 Pierre Ratinaud
14 def OnOpen(self, type):
16 wildcard = u"Fichiers supportés|*.ods;*.xls;*.csv;*.txt|Openoffice Clac|*.ods|Fichier excel|*.xls|Fichier csv|*.csv|Fichier texte|*.txt|Tous les fichiers|*"
18 wildcard = "Fichier texte|*.txt|Tous les fichiers|*"
19 elif type == "Analyse":
20 wildcard = "Fichier analyse/Corpus|*.ira;*.cira"
21 defaultDir = self.PathPath.get('PATHS', 'lastpath')
22 if defaultDir.strip() == '':
23 defaultDir = self.UserConfigPath.replace('.iramuteq','')
25 self, message="Choisissez un fichier", defaultDir=defaultDir,
26 defaultFile="", wildcard=wildcard, style=wx.OPEN | wx.CHANGE_DIR)
28 if dlg.ShowModal() == wx.ID_OK :
29 fileName = dlg.GetFilename()
32 self.PathPath.set('PATHS', 'lastpath', os.path.dirname(path[0]))
41 elif type == "Analyse":
44 def getfileextension(file) :
45 return os.path.splitext(file)[1]
47 def get_table_param(self, filename) :
48 if getfileextension(filename) == '.csv':
49 dlg = dialog.FileOptionDialog(self, -1, u"Format du fichier", sep=True, size=(350, 200),
50 style=wx.DEFAULT_DIALOG_STYLE)
54 self.tableau.parametre['colsep'] = dlg.colsep[dlg.choice3.GetSelection()]
55 self.tableau.parametre['txtsep'] = dlg.txtsep[dlg.choice4.GetSelection()]
56 if self.tableau.parametre['colsep'] == 'tabulation' :
57 self.tableau.parametre['colsep'] = '\t'
58 self.tableau.parametre['filetype'] = 'csv'
61 elif getfileextension(filename) == '.xls' :
62 dlg = dialog.FileOptionDialog(self, -1, u"Format du fichier", sep=False, sheet = True, size=(350, 200),
63 style=wx.DEFAULT_DIALOG_STYLE)
67 self.tableau.parametre['colsep'] = ';'
68 self.tableau.parametre['txtsep'] = '\"'
69 self.tableau.parametre['encodage'] = sys.getdefaultencoding()
70 self.tableau.parametre['sheetnb'] = dlg.spin1.GetValue()
71 self.tableau.parametre['filetype'] = 'xls'
74 elif getfileextension(filename) == '.ods':
75 dlg = dialog.FileOptionDialog(self, -1, u"Format du fichier", sep=False, size=(350, 200),
76 style=wx.DEFAULT_DIALOG_STYLE)
80 self.tableau.parametre['colsep'] = ';'
81 self.tableau.parametre['txtsep'] = '\"'
82 self.tableau.parametre['filetype'] = 'ods'
88 if dlg.radio_box_1.GetSelection() == 0:
89 self.tableau.firstrowiscolnames = True
91 self.tableau.firstrowiscolnames = False
92 if dlg.radio_box_2.GetSelection() == 0:
93 self.tableau.firstcolisrownames = True
95 self.tableau.firstcolisrownames = False
99 if '_mgr' in dir(ira) :
100 if not ira._mgr.GetPane('Text').IsShown() :
101 if ira.nb.GetPageCount() >= 1:
102 return ira.nb.GetPage(ira.nb.GetSelection())
110 def getCorpus(page) :
111 if 'corpus' in page.__dict__:
112 return copy(page.corpus)
117 def __init__(self, parent, dictcol, actives, pathout, selected = None, dlg = False) :
120 dial = dialog.SelectColDial(self.ira)
121 listcol = ListForSpec(dial, self, dictcol, ['forme', 'eff'])
122 dial.bSizer2.Add( listcol, 2, wx.ALL|wx.EXPAND, 5 )
123 dial.m_sdbSizer2.AddButton( dial.m_sdbSizer2OK )
124 dial.m_sdbSizer2.Realize()
125 dial.bSizer2.Add( dial.m_sdbSizer2, 0, wx.EXPAND, 5 )
127 if selected is None :
128 for row in xrange(listcol.GetItemCount()):
131 orderlex = dict([[listcol.getColumnText(i,0),i] for i in range(0,listcol.GetItemCount())])
132 for row in selected :
133 listcol.Select(orderlex[actives[row]])
134 dial.CenterOnParent()
135 val = dial.ShowModal()
136 last = listcol.GetFirstSelected()
137 lastl = [listcol.GetFirstSelected()]
138 indexes = [listcol.getColumnText(listcol.GetFirstSelected(),0)]
139 while listcol.GetNextSelected(last) != -1:
140 last = listcol.GetNextSelected(last)
142 indexes.append(listcol.getColumnText(last,0))
144 column = [actives.index(val) for val in indexes]
146 with open(pathout, 'w') as f :
147 f.write('\n'.join([`val` for val in column]))
149 with open(pathout, 'w') as f :
150 f.write('\n'.join([`i` for i in range(0,len(actives))]))
153 def __init__(self, parent, parametres, indices_simi) :
154 self.parametres = parametres
155 self.dial = dialog.PrefSimi(parent, -1, self.parametres, indices_simi)
156 self.dial.CenterOnParent()
157 self.val = self.dial.ShowModal()
158 if self.val == wx.ID_OK :
161 def make_param(self) :
162 self.select = self.dial.check_colch.GetValue()
163 if self.parametres.get('first', True) :
166 keep_coord = self.dial.check_coord.GetValue()
167 param = {'coeff' : self.dial.choice1.GetSelection(),
168 'layout' : self.dial.choice2.GetSelection(),
169 'type_graph' : self.dial.choice3.GetSelection(),
170 'arbremax' : self.dial.check1.GetValue(),
171 'coeff_tv' : self.dial.check_s_size.GetValue(),
172 'coeff_tv_nb' : self.dial.spin_tv.GetValue(),
173 'tvprop' : self.dial.check2.GetValue(),
174 'tvmin' : self.dial.spin_tvmin.GetValue(),
175 'tvmax' : self.dial.spin_tvmax.GetValue(),
176 'coeff_te' : self.dial.check3.GetValue(),
177 'coeff_temin' : self.dial.spin_temin.GetValue(),
178 'coeff_temax' : self.dial.spin_temax.GetValue(),
179 'label_e' : self.dial.check_elab.GetValue(),
180 'label_v' : self.dial.check_vlab.GetValue(),
181 'vcex' : self.dial.check_vcex.GetValue(),
182 'vcexmin' : self.dial.spin_vcexmin.GetValue(),
183 'vcexmax' : self.dial.spin_vcexmax.GetValue(),
184 'cex' : self.dial.spin_cex.GetValue(),
185 'seuil_ok' : self.dial.check_seuil.GetValue(),
186 'seuil' : self.dial.spin_seuil.GetValue(),
187 'cols' : self.dial.cols.GetColour(),
188 'cola' : self.dial.cola.GetColour(),
189 'width' : self.dial.spin_width.GetValue(),
190 'height' : self.dial.spin_height.GetValue(),
192 'keep_coord' : keep_coord,
193 'alpha' : self.dial.slider_sphere.GetValue(),
194 'film' : self.dial.film.GetValue()
196 if 'cexfromchi' in self.parametres :
197 param['cexfromchi'] = self.dial.checkit.GetValue()
198 if 'sfromchi' in self.parametres :
199 param['sfromchi'] = self.dial.checki.GetValue()
200 if 'vlabcolor' in self.parametres :
201 param['vlabcolor'] = self.parametres['vlabcolor']
202 if 'check_bystar' in dir(self.dial) :
203 param['bystar'] = self.dial.check_bystar.GetValue()
204 param['stars'] = self.parametres['stars']
205 self.parametres.update(param)