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) :
119 dial = dialog.SelectColDial(self.ira)
120 listcol = ListForSpec(dial, self, dictcol, ['forme', 'eff'])
121 dial.bSizer2.Add( listcol, 2, wx.ALL|wx.EXPAND, 5 )
122 dial.m_sdbSizer2.AddButton( dial.m_sdbSizer2OK )
123 dial.m_sdbSizer2.Realize()
124 dial.bSizer2.Add( dial.m_sdbSizer2, 0, wx.EXPAND, 5 )
126 if selected is None :
127 for row in xrange(listcol.list.GetItemCount()):
128 listcol.list.Select(row)
130 orderlex = dict([[listcol.getColumnText(i,0),i] for i in range(0,listcol.list.GetItemCount())])
131 for row in selected :
132 listcol.list.Select(orderlex[actives[row]])
133 dial.CenterOnParent()
134 val = dial.ShowModal()
135 last = listcol.list.GetFirstSelected()
136 lastl = [listcol.list.GetFirstSelected()]
137 indexes = [listcol.getColumnText(listcol.list.GetFirstSelected(),0)]
138 while listcol.list.GetNextSelected(last) != -1:
139 last = listcol.list.GetNextSelected(last)
141 indexes.append(listcol.getColumnText(last,0))
143 column = [actives.index(val) for val in indexes]
145 with open(pathout, 'w') as f :
146 f.write('\n'.join([`val` for val in column]))
149 def __init__(self, parent, parametres, indices_simi) :
150 self.parametres = parametres
151 self.dial = dialog.PrefSimi(parent, -1, self.parametres, indices_simi)
152 self.dial.CenterOnParent()
153 self.val = self.dial.ShowModal()
154 if self.val == wx.ID_OK :
157 def make_param(self) :
158 self.select = self.dial.check_colch.GetValue()
159 if self.parametres.get('first', True) :
162 keep_coord = self.dial.check_coord.GetValue()
163 param = {'coeff' : self.dial.choice1.GetSelection(),
164 'layout' : self.dial.choice2.GetSelection(),
165 'type_graph' : self.dial.choice3.GetSelection(),
166 'arbremax' : self.dial.check1.GetValue(),
167 'coeff_tv' : self.dial.check_s_size.GetValue(),
168 'coeff_tv_nb' : self.dial.spin_tv.GetValue(),
169 'tvprop' : self.dial.check2.GetValue(),
170 'tvmin' : self.dial.spin_tvmin.GetValue(),
171 'tvmax' : self.dial.spin_tvmax.GetValue(),
172 'coeff_te' : self.dial.check3.GetValue(),
173 'coeff_temin' : self.dial.spin_temin.GetValue(),
174 'coeff_temax' : self.dial.spin_temax.GetValue(),
175 'label_e' : self.dial.check_elab.GetValue(),
176 'label_v' : self.dial.check_vlab.GetValue(),
177 'vcex' : self.dial.check_vcex.GetValue(),
178 'vcexmin' : self.dial.spin_vcexmin.GetValue(),
179 'vcexmax' : self.dial.spin_vcexmax.GetValue(),
180 'cex' : self.dial.spin_cex.GetValue(),
181 'seuil_ok' : self.dial.check_seuil.GetValue(),
182 'seuil' : self.dial.spin_seuil.GetValue(),
183 'cols' : self.dial.cols.GetColour(),
184 'cola' : self.dial.cola.GetColour(),
185 'width' : self.dial.spin_width.GetValue(),
186 'height' : self.dial.spin_height.GetValue(),
188 'keep_coord' : keep_coord,
189 'alpha' : self.dial.slider_sphere.GetValue(),
190 'film' : self.dial.film.GetValue()
192 if 'cexfromchi' in self.parametres :
193 param['cexfromchi'] = self.dial.checkit.GetValue()
194 if 'sfromchi' in self.parametres :
195 param['sfromchi'] = self.dial.checki.GetValue()
196 if 'vlabcolor' in self.parametres :
197 param['vlabcolor'] = self.parametres['vlabcolor']
198 if 'check_bystar' in dir(self.dial) :
199 param['bystar'] = self.dial.check_bystar.GetValue()
200 param['stars'] = self.parametres['stars']
201 self.parametres.update(param)