2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2008-2016, Pierre Ratinaud
7 from optparse import OptionParser
9 parser = OptionParser()
10 parser.add_option("-f", "--file", dest="filename",
11 help="open FILE", metavar="FILE", default=False)
12 (options, args) = parser.parse_args()
20 from random import randint
21 from ConfigParser import ConfigParser, RawConfigParser
25 #------------------------------------
27 import wx.lib.agw.aui as aui
30 import wx.lib.hyperlink as hl
31 #------------------------------------
32 from functions import BugReport, PlaySound, History, progressbar
33 from checkversion import NewVersion
34 from guifunct import *
35 from tableau import Tableau
36 from dialog import PrefDialog
37 from tabfrequence import Frequences, FreqMultiple
38 from tabchi2 import ChiSquare
39 from tabchi2mcnemar import McNemar
40 #from tabstudent import MakeStudent
41 from tabchddist import ChdCluster
42 from tabafcm import DoAFCM
43 from tabchdalc import AnalyseQuest
44 from tabsimi import DoSimi
45 from tabrsimple import InputText
46 from tabverges import Prototypical
47 from tabsplitvar import SplitMatrixFromVar
48 #frog textdist import AnalysePam
49 from textstat import Stat
50 from textaslexico import Lexico
51 from textlabbe import DistLabbe
52 from textsimi import SimiTxt, SimiFromCluster
53 from textwordcloud import WordCloud, ClusterCloud
54 from textreinert import Reinert
55 #from textcheckcorpus import checkcorpus
56 from openanalyse import OpenAnalyse
57 from corpus import Builder, SubBuilder, MergeClusters
58 from checkinstall import CreateIraDirectory, CheckRPath, FindRPAthWin32, FindRPathNix, CheckRPackages, IsNew, UpgradeConf, CopyConf, RLibsAreInstalled
59 from chemins import RscriptsPath, ConstructConfigPath, ConstructDicoPath, ConstructGlobalPath, PathOut
60 from parse_factiva_xml import ImportFactiva
61 from parse_dmi import ImportDMI
62 from tools import Extract
63 from analyse_merge import AnalyseMerge
65 from tree import LeftTree
66 ##########################################################
67 ID_OpenData = wx.NewId()
68 ID_Import = wx.NewId()
69 ID_OpenText = wx.NewId()
70 ID_OnOpenAnalyse = wx.NewId()
73 ID_Chi2mc = wx.NewId()
74 ID_Student = wx.NewId()
75 ID_CHDSIM = wx.NewId()
76 ID_CHDReinert = wx.NewId()
77 ID_TEXTAFCM = wx.NewId()
78 ID_TEXTSTAT = wx.NewId()
80 ID_TEXTREINERT = wx.NewId()
81 ID_TEXTPAM = wx.NewId()
82 ID_CHECKCORPUS = wx.NewId()
83 ID_Tabcontent = wx.NewId()
86 ID_CloseTab = wx.NewId()
87 ID_SaveTab = wx.NewId()
88 ID_CreateText = wx.NewId()
89 ID_ACCEUIL = wx.NewId()
90 ID_RESULT = wx.NewId()
91 ID_HTMLcontent = wx.NewId()
92 ID_SimiTxt = wx.NewId()
94 ID_ImportTXM = wx.NewId()
95 ID_FreqMulti = wx.NewId()
96 ID_Splitfromvar = wx.NewId()
97 ID_Subtxtfrommeta = wx.NewId()
98 ID_Subtxtfromthem = wx.NewId()
100 ID_ImportEuro = wx.NewId()
101 ID_Fact_xml = wx.NewId()
102 ID_Fact_mail = wx.NewId()
103 ID_Fact_copy = wx.NewId()
104 ID_exportmeta = wx.NewId()
105 ID_importdmi = wx.NewId()
106 ID_merge = wx.NewId()
107 ID_merge_clusters = wx.NewId()
108 ID_labbe = wx.NewId()
109 ##########################################################
110 #elements de configuration
111 ##########################################################
113 if sys.platform == 'darwin' :
114 sys.setdefaultencoding('UTF-8')
115 wx.SetDefaultPyEncoding('UTF-8')
117 sys.setdefaultencoding(locale.getpreferredencoding())
119 #chemin de l'application
120 AppliPath = os.path.abspath(os.path.dirname(os.path.realpath(sys.argv[0])))
122 ImagePath = os.path.join(AppliPath, 'images')
123 #configuration generale
124 DictConfigPath = ConstructGlobalPath(AppliPath)
125 ConfigGlob = ConfigParser()
126 ConfigGlob.read(DictConfigPath['global'])
127 DefaultConf = ConfigParser()
128 DefaultConf.read(DictConfigPath['preferences'])
129 #repertoire de l'utilisateur
130 user_home = os.getenv('HOME')
131 if user_home is None :
132 user_home = os.path.expanduser('~')
134 UserConfigPath = os.path.abspath(os.path.join(user_home, '.iramuteq-%s' % ConfigGlob.get('DEFAULT', 'version_nb')))
135 #Si pas de fichiers de config utilisateur, on cree le repertoire
136 CreateIraDirectory(UserConfigPath, AppliPath)
137 #fichiers log pour windows (py2exe)
138 log = logging.getLogger('iramuteq')
139 fh = logging.FileHandler(os.path.join(UserConfigPath,'stdout.log'))
140 formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
141 fh.setFormatter(formatter)
143 if sys.platform != 'win32' and sys.platform != 'darwin':
144 ch = logging.StreamHandler()
145 ch.setFormatter(formatter)
147 log.setLevel(logging.INFO)
149 class writer(object):
150 def write(self, data):
151 if data.strip() != '' :
152 log.info('ERROR : %s' % data)
154 class printer(object) :
155 def write(self, data) :
156 if data.strip() != '' :
157 log.info('Print : %s' % data)
159 sys.stderr = writer()
160 sys.stdout = printer()
162 ConfigPath = ConstructConfigPath(UserConfigPath)
164 langues = {'french' : wx.LANGUAGE_FRENCH,
165 'english' : wx.LANGUAGE_ENGLISH,
166 'portuguese' : wx.LANGUAGE_PORTUGUESE,
167 'italian' : wx.LANGUAGE_ITALIAN,
168 'spanish' : wx.LANGUAGE_SPANISH
171 code_langues = {'french' : 'fr_FR',
173 'portuguese' : 'pt_PT',
179 'textroot' : 'textroot.png',
180 'alceste' : 'reinert.png',
181 'reinert' : 'reinert.png',
182 'corpus' : 'textcorpus.png',
183 'wordcloud' :'wordcloud.png',
185 'simitxt' : 'simitxt.png',
186 'clustersimitxt' :'clustersimitxt.png',
187 'clustercloud' : 'clustercloud.png',
189 'matroot' : 'matroot.png',
190 'matrix' : 'matrix.png',
191 'freq' : 'frequences.png',
192 'freqmulti' : 'frequences.png',
194 'chi2mcnemar' : 'chi2.png',
195 'reinertmatrix' : 'reinertmatrix.png',
196 'simimatrix' : 'simimatrix.png',
197 'simiclustermatrix' : 'simimatrix.png',
198 'proto' : 'proto.png',
200 'europress' : 'europress.png',
201 'factiva_xml' : 'factiva_xml.png',
202 'factiva_copy' : 'factiva_copy.png',
203 'factiva_mail': 'factiva_mail.png',
204 'iramuteq' : 'iraicone.png',
205 'subcorpusmeta' : 'subcorpusmeta.png',
206 'subcorpusthema' : 'subcorpusthema.png',
207 'preferences' : 'preferences.png',
208 'exportmetatable' : 'exportmetatable.png',
209 'importdmi' : 'twitter.png',
212 #####################################################################
214 class IraFrame(wx.Frame):
215 def __init__(self, parent, id= -1, title="", pos=wx.DefaultPosition,
216 size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE |
219 log.info('Starting... ' )
220 log.info('version : %s' % ConfigGlob.get('DEFAULT', 'version'))
221 wx.Frame.__init__(self, parent, id, title, pos, size, style)
223 self.AppliPath = AppliPath
224 self.images_path = os.path.join(AppliPath,'images')
225 self.UserConfigPath = UserConfigPath
226 #self.RscriptsPath = ConstructRscriptsPath(AppliPath)
227 self.RscriptsPath = PathOut(dirout=os.path.join(AppliPath, 'Rscripts'))
228 self.RscriptsPath.basefiles(RscriptsPath)
229 #self.DictPath = ConstructDicoPath(AppliPath)
230 self.DictPath = ConstructDicoPath(UserConfigPath)
231 self.ConfigGlob = ConfigGlob
232 self.ConfigPath = ConstructConfigPath(UserConfigPath)
233 self.pref = RawConfigParser()
234 #workaround for import problem
235 self.SimiFromCluster = SimiFromCluster
237 gettext.install('iramuteq', os.path.join(AppliPath,'locale'), unicode=True)
238 #langues = ['fr_FR', 'en', 'pt_PT']
242 for langue in code_langues :
243 self.preslangue[langue] = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=[code_langues[langue]])
245 #self.presLan_fr = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=['fr_FR'])
246 #self.presLan_en = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=['en'])
247 # tell FrameManager to manage this frame
248 #self._mgr = wx.aui.AuiManager()
249 self._mgr = aui.AuiManager()
250 self._mgr.SetManagedWindow(self)
253 #--------------------------------------------------------------------------------
254 self.images_analyses = images_analyses
255 for img in images_analyses :
256 self.images_analyses[img] = wx.Image(os.path.join(self.images_path, self.images_analyses[img]), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()
257 self.mb = wx.MenuBar()
259 file_menu = wx.Menu()
260 item = wx.MenuItem(file_menu, ID_OpenData, _(u"Open a matrix").decode('utf8'), _(u"Open a matrix").decode('utf8'))
261 #item.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN))
262 item.SetBitmap(self.images_analyses['matroot'])
263 file_menu.AppendItem(item)
265 item = wx.MenuItem(file_menu, ID_OpenText, _(u"Open a text corpus").decode('utf8'), _(u"Open a text corpus").decode('utf8'))
266 item.SetBitmap(self.images_analyses['textroot'])
267 file_menu.AppendItem(item)
269 item = wx.MenuItem(file_menu, ID_OnOpenAnalyse, _(u"Open an analysis").decode('utf8'), _(u"Open an analysis").decode('utf8'))
270 item.SetBitmap(self.images_analyses['iramuteq'])
271 file_menu.AppendItem(item)
273 item = wx.MenuItem(file_menu, ID_ImportTXM, _(u"Import from TXM").decode('utf8'), _(u"Import from TXM").decode('utf8'))
274 item.SetBitmap(self.images_analyses['TXM'])
275 file_menu.AppendItem(item)
277 item = wx.MenuItem(file_menu, ID_ImportEuro, _(u"Import from Europress").decode('utf8'), _(u"Import from Europress").decode('utf8'))
278 item.SetBitmap(self.images_analyses['europress'])
279 file_menu.AppendItem(item)
281 item = wx.MenuItem(file_menu, ID_importdmi, _(u"Import from DMI-TCAT (exp.)").decode('utf8'), _(u"Import from DMI-TCAT (exp.)").decode('utf8'))
282 item.SetBitmap(self.images_analyses['importdmi'])
283 file_menu.AppendItem(item)
285 item = wx.MenuItem(file_menu, ID_merge, _(u'Merge graphs').decode('utf8'), _(u'Merge graphs').decode('utf8'))
286 file_menu.AppendItem(item)
288 item = wx.MenuItem(file_menu, ID_merge_clusters, _(u'Corpus from merge clusters').decode('utf8'), _(u'Corpus from merge clusters').decode('utf8'))
289 file_menu.AppendItem(item)
291 menuFactiva = wx.Menu()
292 fact_from_xml = wx.MenuItem(menuFactiva, ID_Fact_xml, _(u"from xml").decode('utf8'))
293 fact_from_xml.SetBitmap(self.images_analyses['factiva_xml'])
294 fact_from_mail = wx.MenuItem(menuFactiva, ID_Fact_mail, _(u"from mail").decode('utf8'))
295 fact_from_mail.SetBitmap(self.images_analyses['factiva_mail'])
296 fact_from_txt = wx.MenuItem(menuFactiva, ID_Fact_copy, _(u"from copy/paste").decode('utf8'))
297 fact_from_txt.SetBitmap(self.images_analyses['factiva_copy'])
298 menuFactiva.AppendItem(fact_from_xml)
299 menuFactiva.AppendItem(fact_from_mail)
300 menuFactiva.AppendItem(fact_from_txt)
301 file_menu.AppendMenu(-1, _(u"Import from factiva").decode('utf8'), menuFactiva)
303 menuTools = wx.Menu()
304 splitvar = wx.MenuItem(menuTools, wx.ID_ANY, _(u"Split from variable").decode('utf8'))
305 extractmod = wx.MenuItem(menuTools, wx.ID_ANY, _(u"Extract mods").decode('utf8'))
306 extractthem = wx.MenuItem(menuTools, wx.ID_ANY, _(u"Extract thematics").decode('utf8'))
307 menuTools.AppendItem(splitvar)
308 menuTools.AppendItem(extractmod)
309 menuTools.AppendItem(extractthem)
310 self.ID_splitvar = splitvar.GetId()
311 self.ID_extractmod = extractmod.GetId()
312 self.ID_extractthem = extractthem.GetId()
313 file_menu.AppendMenu(-1, _(u"Tools").decode('utf8'), menuTools)
316 #item = wx.MenuItem(file_menu, ID_SaveTab, _(u"Save tab as...").decode('utf8'), _(u"Save tab as...").decode('utf8'))
317 #item.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FILE_SAVE_AS))
318 #file_menu.AppendItem(item)
320 file_menu.Append(wx.ID_EXIT, _(u"Exit").decode('utf8'))
322 edit_menu = wx.Menu()
323 pref = wx.MenuItem(edit_menu, wx.ID_PREFERENCES, _(u'Preferences').decode('utf8'))
324 pref.SetBitmap(self.images_analyses['preferences'])
325 edit_menu.AppendItem(pref)
326 #edit_menu.Append(wx.ID_PREFERENCES, _(u'Preferences').decode('utf8'))
328 view_menu = wx.Menu()
329 home = wx.MenuItem(view_menu, ID_ACCEUIL, _(u"Home page").decode('utf8'))
330 home.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_GO_HOME, size = (16,16)))
331 view_menu.AppendItem(home)
332 #view_menu.Append(ID_ACCEUIL, _(u"Home page").decode('utf8'))
333 results = wx.MenuItem(view_menu, ID_RESULT, _(u'Show results').decode('utf8'))
334 results.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_LIST_VIEW, size = (16,16)))
335 view_menu.AppendItem(results)
336 #view_menu.Append(ID_RESULT, _(u'Show results').decode('utf8'))
337 #view_menu.AppendSeparator()
338 matrix_menu = wx.Menu()
339 matanalyses = [[ID_Freq, _(u"Frequencies").decode('utf8'), 'freq'],
340 [ID_FreqMulti, _(u"Multiple Frequencies").decode('utf8'), 'freqmulti'],
341 [ID_Chi2, _(u"Chi2").decode('utf8'), 'chi2'],
342 [ID_Chi2mc, _(u"Chi2 McNemar").decode('utf8'), 'chi2mcnemar'],
343 {'name' : _(u"Clustering").decode('utf8'),
344 'content' : [[ID_CHDReinert, _(u"Reinert's Method").decode('utf8'), 'reinertmatrix']]},
345 [ID_SIMI, _(u"Similarities Analysis").decode('utf8'), 'simimatrix'],
346 [ID_proto, _(u"Prototypical Analysis").decode('utf8'), 'proto'],
347 [ID_Splitfromvar, _(u"Split from variable").decode('utf8'), 'subcorpusmeta'],
350 for analyse in matanalyses :
351 if not isinstance(analyse, dict) :
352 item = wx.MenuItem(matrix_menu, analyse[0], analyse[1])
353 item.SetBitmap(self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)))
354 matrix_menu.AppendItem(item)
357 for subana in analyse['content'] :
358 item = wx.MenuItem(nmenu, subana[0], subana[1])
359 item.SetBitmap(self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)))
360 nmenu.AppendItem(item)
361 matrix_menu.AppendMenu(-1, analyse['name'], nmenu)
362 #item = wx.MenuItem(matrix_menu, ID_Freq, _(u"Frequencies").decode('utf8'))
363 #item.SetBitmap(self.images_analyses['freq'])
364 #matrix_menu.AppendItem(item)
365 #matrix_menu.Append(ID_Freq, _(u"Frequencies").decode('utf8'))
366 #item = wx.MenuItem(matrix_menu, ID_Freq, _(u"Multiple Frequencies").decode('utf8'))
367 #item.SetBitmap(self.images_analyses['freqmulti'])
368 #matrix_menu.Append(ID_FreqMulti, _(u'Multiple frequencies').decode('utf8'))
369 #matrix_menu.AppendItem(item)
370 #matrix_menu.Append(ID_Chi2, _(u"Chi2").decode('utf8'))
371 #matrix_menu.Append(ID_Student, u"t de Student")
372 #menu_classif = wx.Menu()
373 #menu_classif.Append(ID_CHDReinert, _(u"Reinert's Method").decode('utf8'))
374 #menu_classif.Append(ID_CHDSIM, u"Par matrice des distances")
375 #matrix_menu.AppendMenu(-1, _(u"Clustering").decode('utf8'), menu_classif)
376 #matrix_menu.Append(ID_AFCM, u"AFCM")
377 #matrix_menu.Append(ID_SIMI, _(u"Similarities Analysis").decode('utf8'))
378 #matrix_menu.Append(ID_proto, _(u"Prototypical Analysis").decode('utf8'))
379 ID_RCODE = wx.NewId()
380 #matrix_menu.Append(ID_RCODE, u"Code R...")
381 #menu_splittab = wx.Menu()
382 #ID_SPLITVAR = wx.NewId()
383 #splitvar = wx.MenuItem(menu_splittab, ID_SPLITVAR, _(u"Split from variable").decode('utf8'))
384 #menu_splittab.AppendItem(splitvar)
385 #matrix_menu.AppendMenu(-1, _(u"Split matrix").decode('utf8'), menu_splittab)
386 self.matrix_menu = matrix_menu
388 text_menu = wx.Menu()
389 analyses_text = [[ID_TEXTSTAT, _(u"Statistics").decode('utf8'), 'stat'],
390 [ID_ASLEX, _(u"Specificities and CA").decode('utf8'), 'spec'],
391 [ID_labbe, _(u"Labbe Distance").decode('utf8'),'labbe'],
392 {'name' : _(u"Clustering").decode('utf8'),
393 'content' : [[ID_TEXTREINERT, _(u"Reinert's Method").decode('utf8'), 'alceste']]},
394 [ID_SimiTxt, _(u"Similarities Analysis").decode('utf8'), 'simitxt'],
395 [ID_WC, _(u"WordCloud").decode('utf8'), 'wordcloud'],
396 {'name' : _(u"Sub corpus").decode('utf8'),
397 'content' : [[ID_Subtxtfrommeta, _(u'Sub corpus from metadata').decode('utf8'), 'subcorpusmeta'],
398 [ID_Subtxtfromthem, _(u'Sub corpus from thematic').decode('utf8'), 'subcorpusthema']]},
399 [ID_exportmeta, _(u"Export metadata table").decode('utf8'), 'exportmetatable'],
402 for analyse in analyses_text :
403 if not isinstance(analyse, dict) :
404 item = wx.MenuItem(text_menu, analyse[0], analyse[1])
405 item.SetBitmap(self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)))
406 text_menu.AppendItem(item)
409 for subana in analyse['content'] :
410 item = wx.MenuItem(nmenu, subana[0], subana[1])
411 item.SetBitmap(self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)))
412 nmenu.AppendItem(item)
413 text_menu.AppendMenu(-1, analyse['name'], nmenu)
414 #text_menu.Append(ID_CHECKCORPUS, u"Vérifier le corpus")
415 # text_menu.Append(ID_TEXTSTAT, _(u"Statistics").decode('utf8'))
416 # text_menu.Append(ID_ASLEX, _(u"Specificities and CA").decode('utf8'))
417 # #text_menu.Append(ID_TEXTAFCM, u"AFC sur UCI / Vocabulaire")
418 # menu_classiftxt = wx.Menu()
419 # menu_classiftxt.Append(ID_TEXTREINERT, _(u"Reinert's Method").decode('utf8'))
420 # #menu_classiftxt.Append(ID_TEXTPAM, u"Par matrice des distances")
421 # text_menu.AppendMenu(-1, _(u"Clustering").decode('utf8'), menu_classiftxt)
422 # text_menu.Append(ID_SimiTxt, _(u"Similarities Analysis").decode('utf8'))
424 # text_menu.Append(ID_WC, _(u"WordCloud").decode('utf8'))
425 self.text_menu = text_menu
427 help_menu = wx.Menu()
428 about = wx.MenuItem(help_menu, wx.ID_ABOUT, _(u"About...").decode('utf8'))
429 about.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_INFORMATION, size = (16,16)))
430 help_menu.AppendItem(about)
431 #help_menu.Append(wx.ID_ABOUT, _(u"About...").decode('utf8'))
432 help = wx.MenuItem(help_menu, wx.ID_HELP, _(u"Online help...").decode('utf8'))
433 help.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_HELP, size = (16,16)))
434 help_menu.AppendItem(help)
435 #help_menu.Append(wx.ID_HELP, _(u"Online help...").decode('utf8'))
437 self.mb.Append(file_menu, _(u"File").decode('utf8'))
438 self.mb.Append(edit_menu, _(u"Edition").decode('utf8'))
439 self.mb.Append(view_menu, _(u"View").decode('utf8'))
440 self.mb.Append(matrix_menu, _(u"Matrix analysis").decode('utf8'))
441 self.mb.Append(text_menu, _(u"Text analysis").decode('utf8'))
442 self.mb.Append(help_menu, _(u"Help").decode('utf8'))
444 self.SetMenuBar(self.mb)
445 #--------------------------------------------------------------------
446 self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP)
447 self.statusbar.SetStatusWidths([-2, -3])
448 self.statusbar.SetStatusText(_(u"Ready").decode('utf8'), 0)
449 self.statusbar.SetStatusText(_(u"Welcome").decode('utf8'), 1)
451 # min size for the frame itself isn't completely done.
452 # see the end up FrameManager::Update() for the test
453 # code. For now, just hard code a frame minimum size
454 self.SetMinSize(wx.Size(400, 400))
456 # create some toolbars
457 tb1 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
458 wx.TB_FLAT | wx.TB_NODIVIDER)
459 tb1.SetToolBitmapSize(wx.Size(16, 16))
460 tb1.AddLabelTool(ID_OpenData, "OpenData", self.images_analyses['matroot'], shortHelp=_(u"Matrix").decode('utf8'), longHelp=_(u"Open a matrix").decode('utf8'))
462 tb1.AddLabelTool(ID_OpenText, "OpenText", self.images_analyses['textroot'], shortHelp=_(u"Text").decode('utf8'), longHelp=_(u"Open a text corpus").decode('utf8'))
464 tb1.AddLabelTool(ID_OnOpenAnalyse, "OpenAnalyse", self.images_analyses['iramuteq'], shortHelp= _(u"Open an analysis").decode('utf8'), longHelp=_(u"Open an analysis").decode('utf8'))
466 tb1.AddLabelTool(ID_ImportTXM, "ImportTXM", self.images_analyses['TXM'], shortHelp= _(u"Import from TXM").decode('utf8'), longHelp=_(u"Import from TXM").decode('utf8'))
468 tb1.AddLabelTool(ID_ImportEuro, "ImportEuro", self.images_analyses['europress'], shortHelp= _(u"Import from Europress").decode('utf8'), longHelp=_(u"Import from Europress").decode('utf8'))
470 tb1.AddLabelTool(ID_importdmi, "ImportDMI", self.images_analyses['importdmi'], shortHelp= _(u"Import from DMI-TCAT (exp.)").decode('utf8'), longHelp=_(u"Import from DMI-TCAT (exp.)").decode('utf8'))
472 tb1.AddLabelTool(ID_Fact_xml, "ImportFactxml", self.images_analyses['factiva_xml'], shortHelp= _(u"Factiva from xml").decode('utf8'), longHelp=_(u"Factiva from xml").decode('utf8'))
473 tb1.AddLabelTool(ID_Fact_mail, "ImportFactmail", self.images_analyses['factiva_mail'], shortHelp= _(u"Factiva from mail").decode('utf8'), longHelp=_(u"Factiva from mail").decode('utf8'))
474 tb1.AddLabelTool(ID_Fact_copy, "ImportFactcopy", self.images_analyses['factiva_copy'], shortHelp= _(u"Factiva from copy/paste").decode('utf8'), longHelp=_(u"Factiva from copy/paste").decode('utf8'))
476 tb1.AddLabelTool(wx.ID_PREFERENCES, "Preferences", self.images_analyses['preferences'], shortHelp= _(u"Preferences").decode('utf8'), longHelp=_(u"Preferences").decode('utf8'))
478 tb1.AddLabelTool(ID_ACCEUIL, "Home", wx.ArtProvider_GetBitmap(wx.ART_GO_HOME, size = (16,16)), shortHelp= _(u"Home page").decode('utf8'), longHelp=_(u"Home page").decode('utf8'))
479 tb1.AddLabelTool(ID_RESULT, "Results", wx.ArtProvider_GetBitmap(wx.ART_LIST_VIEW, size = (16,16)), shortHelp= _(u'Show results').decode('utf8'), longHelp=_(u'Show results').decode('utf8'))
482 tb_text = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
483 wx.TB_FLAT | wx.TB_NODIVIDER)
484 for analyse in analyses_text :
485 if not isinstance(analyse, dict) :
486 tb_text.AddLabelTool(analyse[0], analyse[1], self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)), shortHelp = analyse[1], longHelp = analyse[1])
488 for subana in analyse['content'] :
489 tb_text.AddLabelTool(subana[0], subana[1], self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)), shortHelp = subana[1], longHelp = subana[1])
492 tb_mat = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
493 wx.TB_FLAT | wx.TB_NODIVIDER)
494 for analyse in matanalyses :
495 if not isinstance(analyse, dict) :
496 tb_mat.AddLabelTool(analyse[0], analyse[1], self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)), shortHelp = analyse[1], longHelp = analyse[1])
498 for subana in analyse['content'] :
499 tb_mat.AddLabelTool(subana[0], subana[1], self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)), shortHelp = subana[1], longHelp = subana[1])
502 tb_help = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
503 wx.TB_FLAT | wx.TB_NODIVIDER)
504 tb_help.AddLabelTool(wx.ID_ABOUT, "About", wx.ArtProvider_GetBitmap(wx.ART_INFORMATION, size=(16,16)), shortHelp=_(u"About...").decode('utf8'), longHelp=_(u"About...").decode('utf8'))
505 tb_help.AddLabelTool(wx.ID_HELP, "Help", wx.ArtProvider_GetBitmap(wx.ART_HELP, size=(16,16)), shortHelp=_(u"Online help...").decode('utf8'), longHelp=_(u"Online help...").decode('utf8'))
507 #------------------------------------------------------------------------------------------------
509 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)
511 #self._mgr.AddPane(self.text_ctrl_txt, wx.aui.AuiPaneInfo().
512 # Name("Text").CenterPane())
513 self._mgr.AddPane(self.text_ctrl_txt, aui.AuiPaneInfo().
514 Name("Text").CenterPane())
515 #self._mgr.AddPane(IntroPanel(self), wx.aui.AuiPaneInfo().Name("Intro_Text").
517 self._mgr.AddPane(IntroPanel(self), aui.AuiPaneInfo().Name("Intro_Text").
519 #if not os.path.exists(os.path.join(UserConfigPath, 'history.db')) :
520 # with open(os.path.join(UserConfigPath, 'history.db'), 'w') as f :
522 self.history = History(os.path.join(UserConfigPath, 'history.db'))
523 #self.history.dostat()
524 self.tree = LeftTree(self)
525 self._mgr.AddPane(self.tree, aui.AuiPaneInfo().Name("lefttree").Caption(_(u"Historic").decode('utf8')).
526 Left().MinSize(wx.Size(200,500)).Layer(1).Position(1).CloseButton(False).MaximizeButton(True).
527 MinimizeButton(True))
529 #self.nb = wx.aui.AuiNotebook(self, -1, wx.DefaultPosition, wx.DefaultSize, wx.aui.AUI_NB_DEFAULT_STYLE | wx.aui.AUI_NB_TAB_EXTERNAL_MOVE | wx.aui.AUI_NB_TAB_MOVE | wx.aui.AUI_NB_TAB_FLOAT| wx.NO_BORDER)
530 self.nb = aui.AuiNotebook(self, -1, wx.DefaultPosition, wx.DefaultSize, aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_FLOAT| wx.NO_BORDER)
531 notebook_flags = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_FLOAT| wx.NO_BORDER
532 self.nb.SetAGWWindowStyleFlag(notebook_flags)
533 self.nb.SetArtProvider(aui.ChromeTabArt())
534 #self.nb.SetArtProvider(aui.VC8TabArt())
535 #self.nb.parent = self
536 #self._notebook_style = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | wx.NO_BORDER
537 #self._mgr.AddPane(self.nb, wx.aui.AuiPaneInfo().
538 # Name("Tab_content").
540 self._mgr.AddPane(self.nb, aui.AuiPaneInfo().
544 #self._mgr.AddPane(self.Sheet, wx.aui.AuiPaneInfo().Name("Data").CenterPane())
545 #self._mgr.AddPane(self.Sheet, aui.AuiPaneInfo().Name("Data").CenterPane())
546 self.nb.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnCloseTab)
547 self.nb.Bind(aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
548 # add the toolbars to the manager
550 #self._mgr.AddPane(tb1, wx.aui.AuiPaneInfo().
551 # Name("tb1").Caption("Fichiers").
552 # ToolbarPane().Top().
553 # LeftDockable(False).RightDockable(False))
554 self._mgr.AddPane(tb1, aui.AuiPaneInfo().
555 Name("tb1").Caption("Fichiers").
557 LeftDockable(True).RightDockable(False))
559 self._mgr.AddPane(tb_text, aui.AuiPaneInfo().
560 Name("tb_text").Caption("analyse_text").
562 LeftDockable(True).RightDockable(False))
564 self._mgr.AddPane(tb_mat, aui.AuiPaneInfo().
565 Name("tb_mat").Caption("analyse_matrix").
567 LeftDockable(True).RightDockable(False))
569 self._mgr.AddPane(tb_help, aui.AuiPaneInfo().
570 Name("tb_help").Caption("help").
572 LeftDockable(True).RightDockable(False))
574 self._mgr.GetPane('tb_text').Hide()
575 self._mgr.GetPane('tb_mat').Hide()
577 self.ShowAPane("Intro_Text")
578 self._mgr.GetPane("lefttree").Show()
579 self._mgr.GetPane("classif_tb").Hide()
580 # "commit" all changes made to FrameManager
583 # Show How To Use The Closing Panes Event
584 ##################################################################
585 self.Bind(wx.EVT_MENU, self.OnAcceuil, id=ID_ACCEUIL)
586 self.Bind(wx.EVT_MENU, self.ShowTab, id=ID_RESULT)
587 self.Bind(wx.EVT_MENU, self.OnOpenData, id=ID_OpenData)
588 self.Bind(wx.EVT_MENU, self.OnOpenText, id=ID_OpenText)
589 self.Bind(wx.EVT_MENU, self.OnOpenAnalyse, id=ID_OnOpenAnalyse)
590 self.Bind(wx.EVT_MENU, self.import_factiva_xml, fact_from_xml)
591 self.Bind(wx.EVT_MENU, self.import_factiva_mail, fact_from_mail)
592 self.Bind(wx.EVT_MENU, self.import_factiva_txt, fact_from_txt)
593 self.Bind(wx.EVT_MENU, self.ExtractTools, splitvar)
594 self.Bind(wx.EVT_MENU, self.ExtractTools, extractmod)
595 self.Bind(wx.EVT_MENU, self.ExtractTools, extractthem)
596 self.Bind(wx.EVT_MENU, self.OnFreq, id=ID_Freq)
597 self.Bind(wx.EVT_MENU, self.OnFreqMulti, id=ID_FreqMulti)
598 self.Bind(wx.EVT_MENU, self.OnChi2, id=ID_Chi2)
599 self.Bind(wx.EVT_MENU, self.OnChi2McNemar, id=ID_Chi2mc)
600 self.Bind(wx.EVT_MENU, self.OnStudent, id=ID_Student)
601 self.Bind(wx.EVT_MENU, self.OnCHDSIM, id=ID_CHDSIM)
602 self.Bind(wx.EVT_MENU, self.OnCHDReinert, id=ID_CHDReinert)
603 self.Bind(wx.EVT_MENU, self.OnAFCM, id=ID_AFCM)
604 self.Bind(wx.EVT_MENU, self.OnProto, id=ID_proto)
605 self.Bind(wx.EVT_MENU, self.OnSplitVar, id = ID_Splitfromvar)
606 #self.Bind(wx.EVT_MENU, self.OnRCode, id=ID_RCODE)
607 #self.Bind(wx.EVT_MENU, self.OnSplitVar, id=ID_SPLITVAR)
608 #self.Bind(wx.EVT_MENU, self.OnCheckcorpus, id = ID_CHECKCORPUS)
609 self.Bind(wx.EVT_MENU, self.OnTextStat, id=ID_TEXTSTAT)
610 self.Bind(wx.EVT_MENU, self.OnTextSpec, id=ID_ASLEX)
611 self.Bind(wx.EVT_MENU, self.OnTextLabbe, id=ID_labbe)
612 self.Bind(wx.EVT_MENU, self.OnTextAfcm, id=ID_TEXTAFCM)
613 self.Bind(wx.EVT_MENU, self.OnTextReinert, id=ID_TEXTREINERT)
614 self.Bind(wx.EVT_MENU, self.OnPamSimple, id=ID_TEXTPAM)
615 self.Bind(wx.EVT_MENU, self.OnSimiTxt, id=ID_SimiTxt)
616 self.Bind(wx.EVT_MENU, self.OnWordCloud, id=ID_WC)
617 self.Bind(wx.EVT_MENU, self.OnSubText, id = ID_Subtxtfrommeta)
618 self.Bind(wx.EVT_MENU, self.OnSubText, id = ID_Subtxtfromthem)
619 self.Bind(wx.EVT_MENU, self.OnSimiTab, id=ID_SIMI)
620 self.Bind(wx.EVT_MENU, self.OnExit, id=wx.ID_EXIT)
621 #self.Bind(wx.EVT_MENU, self.OnSaveTabAs, id=ID_SaveTab)
622 self.Bind(wx.EVT_MENU, self.OnAbout, id=wx.ID_ABOUT)
623 self.Bind(wx.EVT_MENU, self.OnHelp, id=wx.ID_HELP)
624 self.Bind(wx.EVT_MENU, self.OnPref, id=wx.ID_PREFERENCES)
625 self.Bind(wx.EVT_MENU, self.OnImportTXM, id=ID_ImportTXM)
626 self.Bind(wx.EVT_MENU, self.OnImportEuropress, id=ID_ImportEuro)
627 self.Bind(wx.EVT_MENU, self.OnImportDMI, id=ID_importdmi)
628 self.Bind(wx.EVT_MENU, self.OnExportMeta, id=ID_exportmeta)
629 self.Bind(wx.EVT_MENU, self.OnMergeGraph, id = ID_merge)
630 self.Bind(wx.EVT_MENU, self.OnMergeClusters, id = ID_merge_clusters)
631 self.Bind(wx.EVT_CLOSE, self.OnClose)
632 ##################################################################
633 flags = self._mgr.GetAGWFlags()
634 #flags &= ~wx.aui.AUI_MGR_TRANSPARENT_HINT
635 #flags &= ~wx.aui.AUI_MGR_VENETIAN_BLINDS_HINT
636 #flags &= ~wx.aui.AUI_MGR_RECTANGLE_HINT
637 flags &= ~(aui.AUI_MGR_RECTANGLE_HINT | aui.AUI_MGR_ALLOW_FLOATING)
638 self._mgr.SetAGWFlags(self._mgr.GetAGWFlags() ^ (aui.AUI_MGR_RECTANGLE_HINT | aui.AUI_MGR_ALLOW_FLOATING))
639 self._mgr.GetArtProvider().SetMetric(aui.AUI_DOCKART_GRADIENT_TYPE, aui.AUI_GRADIENT_HORIZONTAL)
640 self.GetDockArt().SetColor(aui.AUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR, "#00FFF9")
643 self._icon = wx.Icon(os.path.join(ImagePath, "iraicone.ico"), wx.BITMAP_TYPE_ICO)
644 self.SetIcon(self._icon)
645 ##########################
647 self.input_path = [False]
648 self.TEMPDIR = tempfile.mkdtemp('iramuteq')
649 self.FileTabList = []
655 self.g_header = False
662 self.SysEncoding = sys.getdefaultencoding()
663 self.syscoding = sys.getdefaultencoding()
664 #print 'SysEncoding',self.SysEncoding
665 if self.SysEncoding == 'mac-roman' : self.SysEncoding = 'MacRoman'
668 ##############################################################@
669 self.ShowMenu('view', True)
670 self.ShowMenu('matrix', False)
671 self.ShowMenu('text', False)
682 def finish_init(self) :
684 self.pref.read(self.ConfigPath['preferences'])
687 self.pref.read(self.ConfigPath['preferences'])
694 self.pref.read(self.ConfigPath['preferences'])
696 self.sound = self.pref.getboolean('iramuteq', 'sound')
697 self.check_update = self.pref.getboolean('iramuteq', 'checkupdate')
698 self.version = ConfigGlob.get('DEFAULT', 'version')
699 #configuration des chemins de R
700 self.PathPath = ConfigParser()
701 self.PathPath.read(ConfigPath['path'])
703 if not CheckRPath(self.PathPath) :
704 if sys.platform == 'win32':
705 BestRPath = FindRPAthWin32()
707 BestRPath = FindRPathNix()
709 self.PathPath.set('PATHS', 'rpath', BestRPath)
710 with open(ConfigPath['path'], 'w') as f :
711 self.PathPath.write(f)
715 self.RPath = self.PathPath.get('PATHS', 'rpath')
718 if not RLibsAreInstalled(self) :
721 msg = '\n'.join([_(u"Can't find R executable").decode('utf8'), _(u"If R is not installed, get it from http://www.r-project.org.").decode('utf8'),
722 _(u"If R is installed, report its path in Preferences.").decode('utf8'),
723 _(u"IRaMuTeQ does not work without R.").decode('utf8')])
724 dlg = wx.MessageDialog(self, msg, _(u"Problem").decode('utf8'), wx.OK | wx.ICON_WARNING)
726 if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
730 def setlangue(self) :
731 self.pref.read(self.ConfigPath['preferences'])
733 guilangue = self.pref.get('iramuteq', 'guilanguage')
735 guilangue = DefaultConf.get('iramuteq', 'guilanguage')
736 self.preslangue.get(guilangue, 'english').install()
738 def OnVerif(self, evt) :
739 pack = CheckRPackages(self)
741 dlg = wx.MessageDialog(self, _(u"Installation OK").decode('utf8'), _(u"Installation").decode('utf8'), wx.OK | wx.ICON_INFORMATION | wx.STAY_ON_TOP)
743 if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
746 def ShowMenu(self, menu, Show=True):
750 self._mgr.GetPane('tb_text').Show()
752 self._mgr.GetPane('tb_text').Hide()
753 elif menu == 'matrix' :
756 self._mgr.GetPane('tb_mat').Show()
758 self._mgr.GetPane('tb_mat').Hide()
759 elif menu == 'view' :
764 #menu_pos = self.mb.FindMenu(menu)
765 if not menu_pos is None :
766 self.mb.EnableTop(menu_pos, Show)
767 self.mb.UpdateMenus()
770 #--------------------------------------------------------------------
771 def OnClose(self, event):
773 with open(self.ConfigPath['path'], 'w') as f :
774 self.PathPath.write(f)
779 def OnOpenData(self, event):
780 inputname, self.input_path = OnOpen(self, "Data")
782 #filename = self.input_path[0]
783 self.tableau = Tableau(self,os.path.abspath(self.input_path[0]))
784 val = get_table_param(self, self.input_path[0])
786 busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self)
789 self.tableau.make_content()
790 OpenAnalyse(self, self.tableau.parametres)
791 self.tree.OnItemAppend(self.tableau.parametres)
796 #self.tableau.show_tab()
798 def OnOpenAnalyse(self, event):
799 self.AnalysePath = OnOpen(self, "Analyse")
800 if self.AnalysePath :
801 OpenAnalyse(self, self.AnalysePath[1][0], True)
802 self.ShowMenu('view')
804 def OnOpenText(self, event):
805 inputname, self.input_path = OnOpen(self, "Texte")
806 self.filename = self.input_path[0]
810 def OnSubText(self, evt, corpus = None, parametres = None):
812 corpus = self.tree.getcorpus()
813 if evt.GetId() == ID_Subtxtfrommeta :
814 parametres = {'frommeta' : True}
815 elif evt.GetId() == ID_Subtxtfromthem :
816 parametres = {'fromtheme' : True}
817 builder = SubBuilder(self, corpus, parametres)
818 if builder.res == wx.ID_OK :
819 busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self)
821 corpus = builder.doanalyse()
822 self.history.add(corpus.parametres)
823 OpenAnalyse(self, corpus.parametres)
824 self.tree.OnItemAppend(corpus.parametres)
828 builder = Builder(self, 5)
829 if builder.res == wx.ID_OK :
831 corpus = builder.doanalyse()
832 self.history.add(corpus.parametres)
833 self.tree.OnItemAppend(corpus.parametres)
834 OpenAnalyse(self, corpus.parametres)
836 builder.dlg.Destroy()
840 keepGoing = builder.dlg.Update(count, u"Lecture du fichier")
841 self.ShowMenu('view')
842 self.ShowMenu('text')
843 self.ShowMenu('matrix', False)
848 keepGoing = builder.dlg.Update(count, u"Chargement du dictionnaire")
849 builder.dlg.Destroy()
851 def OnExit(self, event):
854 def OnAbout(self, event):
855 info = wx.AboutDialogInfo()
856 info.Name = ConfigGlob.get('DEFAULT', 'name')
857 info.Version = ConfigGlob.get('DEFAULT', 'version')
858 info.Copyright = ConfigGlob.get('DEFAULT', 'copyright')
859 info.Translators = ConfigGlob.get('DEFAULT', 'translators').decode('utf8').split(';')
860 info.Description = u"""
861 Interface de R pour les Analyses Multidimensionnelles
862 de Textes et de Questionnaires
865 construit avec des logiciels libres.
871 info.WebSite = ("http://www.iramuteq.org", u"Site web IRaMuTeQ")
872 dev = ConfigGlob.get('DEFAULT', 'dev').decode('utf8').split(';')
873 info.Developers = dev
874 info.License = u"""Iramuteq est un logiciel libre ; vous pouvez le diffuser et/ou le modifier
875 suivant les termes de la Licence Publique Générale GNU telle que publiée
876 par la Free Software Foundation ; soit la version 2 de cette licence,
877 soit (à votre convenance) une version ultérieure.
879 Iramuteq est diffusé dans l'espoir qu'il sera utile,
880 mais SANS AUCUNE GARANTIE ; sans même une garantie implicite
881 de COMMERCIALISATION ou d'ADÉQUATION À UN USAGE PARTICULIER.
882 Voyez la Licence Publique Générale GNU pour plus de détails.
884 Vous devriez avoir reçu une copie de la Licence Publique Générale GNU
885 avec Iramuteq ; sinon, veuillez écrire à la Free Software Foundation,
886 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis."""
889 def GetDockArt(self):
890 return self._mgr.GetArtProvider()
895 def OnPageChanged(self, event) :
896 new = event.GetSelection()
897 nobject = event.GetEventObject()
898 parent = nobject.GetParent()
899 if isinstance(parent, IraFrame) :
900 npage = self.nb.GetPage(new)
901 if 'parametres' in dir(npage) :
902 self.tree.GiveFocus(uuid=npage.parametres['uuid'])
903 if npage.parametres.get('matrix', False) :
904 self.ShowMenu('text', False)
905 self.ShowMenu('matrix', True)
906 elif npage.parametres.get('corpus', False) :
907 self.ShowMenu('text')
908 self.ShowMenu('matrix', False)
910 def OnCloseTab(self, evt):
911 #log.info('Closing tab %s' % str(evt.GetEventObject()))
912 ctrl = evt.GetEventObject()
913 if isinstance(ctrl.GetParent(), aui.AuiNotebook) or isinstance(ctrl.GetParent(), wx.Panel):
917 page = self.nb.GetPage(self.nb.GetSelection())
918 if 'parametres' in dir(page) and isinstance(ctrl.GetParent(), IraFrame) :
919 self.history.rmtab(page.parametres)
920 self.tree.CloseItem(uuid = page.parametres['uuid'])
921 TabTitle = self.nb.GetPageText(self.nb.GetSelection())
923 if self.nb.GetPageCount() == 1 and not notebook :
926 def LastTabClose(self) :
927 if self.nb.GetPageCount() == 1 :
929 self.ShowAPane("Text")
931 self.ShowAPane("Data")
933 self.ShowAPane("Intro_Text")
935 def GetStartPosition(self):
939 pt = self.ClientToScreen(wx.Point(0, 0))
941 return wx.Point(pt.x + x, pt.y + x)
943 def ShowAPane(self, panel):
944 for pane in self._mgr.GetAllPanes() :
945 if not pane.IsToolbar() and pane.name != 'lefttree':
947 self._mgr.GetPane(panel).Show()
950 def OnAcceuil(self, event):
951 self.ShowAPane(u"Intro_Text")
954 def CreateHTMLCtrl(self):
955 ctrl = wx.html.HtmlWindow(self, -1, wx.DefaultPosition, wx.Size(400, 300))
956 if "gtk2" in wx.PlatformInfo:
957 ctrl.SetStandardFonts()
958 ctrl.SetPage(u"text")
961 def ShowTab(self, evt):
962 self.ShowAPane("Tab_content")
964 ################################################################
966 ################################################################
967 def analyse_matrix(self, analyse, analyse_type = '', matrix = None, parametres = None, dlgnb = 1):
969 matrix = self.tree.getmatrix()
970 if parametres is not None :
971 parametres['type'] = analyse_type
973 parametres = {'type' : analyse_type}
975 #print 'plus de bug@@@@@@@@@@@@@@@@@@@@@@'
976 analyse(self, matrix, parametres = parametres, dlg = dlgnb)
980 def OnFreq(self, event, matrix = None):
981 self.analyse_matrix(Frequences, analyse_type = 'freq', matrix = matrix, dlgnb = 3)
983 def OnFreqMulti(self, event, matrix = None):
984 self.analyse_matrix(FreqMultiple, analyse_type = 'freqmulti', matrix = matrix, dlgnb = 3)
986 def OnChi2(self, event, matrix = None):
987 self.analyse_matrix(ChiSquare, matrix = matrix, analyse_type = 'chi2', dlgnb = 3)
989 def OnChi2McNemar(self, event, matrix = None):
990 self.analyse_matrix(McNemar, matrix = matrix, analyse_type = 'chi2mcnemar', dlgnb = 3)
992 def OnSimiTab(self, event, matrix = None):
993 self.analyse_matrix(DoSimi, matrix = matrix, analyse_type = 'simimatrix', dlgnb = 5)
995 def OnCHDReinert(self, event, matrix = None):
997 # matrix = self.tree.getmatrix()
998 #AnalyseQuest(self, matrix, parametres = {'type' : 'reinertmatrix'}, dlg = 3)
999 self.analyse_matrix(AnalyseQuest, matrix = matrix, analyse_type = 'reinertmatrix', dlgnb = 5)
1001 def OnStudent(self, event):
1007 def OnRCode(self, event):
1013 def OnCHDSIM(self, event):
1015 # print 'ATTENTION!!!!'
1016 chdsim = ChdCluster(self)
1017 if chdsim.val == wx.ID_OK:
1022 # def OnCHDReinert(self, event):
1024 # # print('PLUS DE BUG SUR ALCESTE QUESTIONNAIRE')
1025 # self.quest = AnalyseQuest(self)
1026 # if self.quest.val == wx.ID_OK:
1030 def OnMergeGraph(self, evt):
1032 AnalyseMerge(self, {'type': 'merge', 'fileout' : '/tmp/test.txt'}, dlg = 5)
1034 def OnMergeClusters(self, evt) :
1035 builder = MergeClusters(self, {})
1036 if builder.res == wx.ID_OK :
1037 busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self)
1039 corpus = builder.doanalyse()
1040 self.history.add(corpus.parametres)
1041 OpenAnalyse(self, corpus.parametres)
1042 self.tree.OnItemAppend(corpus.parametres)
1045 def OnProto(self, evt, matrix = None) :
1046 self.analyse_matrix(Prototypical, matrix = matrix, analyse_type = 'proto', dlgnb = 3)
1047 #Prototypical(self, {'type' : 'proto'})
1049 def OnSplitVar(self, evt, matrix = None):
1051 matrix = self.tree.getmatrix()
1052 self.analyse_matrix(SplitMatrixFromVar, matrix = matrix, analyse_type = 'splitvar', parametres = {'pathout': matrix.pathout.dirout}, dlgnb = 3)
1053 #matrix = self.tree.getmatrix()
1056 def OnSimiTxt(self, evt, corpus = None) :
1057 # print 'PLUS DE BUG SUR SIMITXT'
1059 #self.Text = SimiTxt(self)
1061 corpus = self.tree.getcorpus()
1062 self.Text = SimiTxt(self, corpus, parametres = {'type': 'simitxt'}, dlg = 3)
1063 if self.Text.val == wx.ID_OK :
1068 def OnWordCloud(self, evt, corpus = None) :
1069 # print 'PLUS DE BUG SUR WORDCLOUD'
1072 corpus = self.tree.getcorpus()
1073 self.Text = WordCloud(self, corpus, parametres = {'type' : 'wordcloud'}, dlg = 3)
1074 if self.Text.val == wx.ID_OK :
1079 def OnClusterCloud(self, corpus, parametres = None) :
1080 self.Text = ClusterCloud(self, corpus, parametres = parametres, dlg = 3)
1082 def OnAFCM(self, event):
1088 def OnTextStat(self, event, corpus = None):
1089 #print 'PAS DE BUG SUR TEXT STAT'
1092 corpus = self.tree.getcorpus()
1093 self.Text = Stat(self, corpus, parametres = {'type': 'stat'}, dlg = 7)
1095 if self.Text.val == wx.ID_OK :
1100 def OnTextSpec(self, event, corpus = None):
1102 #self.Text = AsLexico(self)
1103 #print('ATTENTION : PLUS DE BUG SUR LEXICO')
1105 corpus = self.tree.getcorpus()
1106 self.Text = Lexico(self, corpus, parametres = {'type' : 'spec'}, dlg = 3)
1107 if self.Text.val == wx.ID_OK :
1112 def OnTextLabbe(self, event, corpus = None):
1115 corpus = self.tree.getcorpus()
1116 self.Text = DistLabbe(self, corpus, parametres = {'type' : 'labbe'}, dlg = 3)
1117 if self.Text.val == wx.ID_OK :
1123 def OnTextAfcm(self, event):
1130 def import_factiva_xml(self,event):
1132 ImportFactiva(self, 'xml')
1136 def import_factiva_mail(self, evt) :
1138 ImportFactiva(self, 'mail')
1142 def import_factiva_txt(self, evt) :
1144 ImportFactiva(self, 'txt')
1148 def OnImportTXM(self, evt) :
1150 ImportFactiva(self, 'txm')
1154 def OnImportEuropress(self, evt) :
1156 ImportFactiva(self, 'euro')
1160 def OnImportDMI(self, evt):
1163 def OnExportMeta(self, evt, corpus = None):
1165 corpus = self.tree.getcorpus()
1167 ExportMetaTable(self, corpus)
1171 def ExtractTools(self, evt) :
1173 if ID == self.ID_splitvar :
1174 Extract(self, 'splitvar')
1175 elif ID == self.ID_extractmod :
1176 Extract(self, 'mods')
1177 elif ID == self.ID_extractthem :
1178 Extract(self, 'them')
1180 def OnTextReinert(self, event, corpus = None):
1182 #print('ATTENTION : PLUS DE BUG SUR ALCESTE')
1183 #RunAnalyse(self, corpus, Alceste, OptAlceste)
1185 corpus = self.tree.getcorpus()
1186 self.Text = Reinert(self, corpus, parametres = {'type': 'alceste'}, dlg = 6)
1187 if self.Text.val == wx.ID_OK:
1192 def OnPamSimple(self, event, corpus = None):
1195 corpus = self.tree.getcorpus()
1196 self.Text = AnalysePam(self, corpus, parametres = {'type' : 'pamtxt'}, dlg = 6)
1197 if self.Text.val == wx.ID_OK:
1202 def SimiCluster(self, parametres = {}, fromprof = False, tableau = None) :
1203 self.analyse_matrix(DoSimi, parametres = parametres, analyse_type = 'simiclustermatrix', matrix = tableau, dlgnb = 5)
1205 # def OnSimi(self,evt):
1207 #print 'ATTENTION !!!! VERGES'
1208 #print 'PLUS DE BUG SUR SIMI'
1209 # self.res = DoSimi(self, param = None)
1210 #self.res = Verges(self)
1211 # if self.res.val == wx.ID_OK :
1215 #################################################################
1217 def OnHelp(self, event):
1218 webbrowser.open('http://www.iramuteq.org/documentation')
1220 def OnPref(self, event):
1221 dlg = PrefDialog(self)
1222 dlg.CenterOnParent()
1223 self.val = dlg.ShowModal()
1227 if self.check_update:
1230 print 'pas de verif'
1232 #CheckRPackages(self)
1234 def OnOpenFromCmdl(self):
1236 if options.filename :
1237 if os.path.exists(options.filename):
1238 self.filename = os.path.abspath(options.filename)
1242 if os.path.exists(os.path.realpath(args[0])):
1243 self.filename = os.path.abspath(os.path.realpath(args[0]))
1249 if os.path.splitext(self.filename)[1] in ['.csv', '.xls', '.ods']:
1250 self.tableau = Tableau(self, self.filename)
1251 val = get_table_param(self, self.filename)
1252 if val == wx.ID_OK :
1253 self.tableau.make_content()
1254 OpenAnalyse(self, self.tableau.parametres)
1255 self.tree.OnItemAppend(self.tableau.parametres)
1256 #get_table_param(self, self.filename)
1257 #self.tableau.make_content()
1258 #self.tableau.show_tab()
1259 #open_data(self, self.filename)
1260 elif os.path.splitext(self.filename)[1] == '.txt':
1262 elif os.path.splitext(self.filename)[1] == '.ira' :
1263 #self.corpus = Corpus(self)
1264 #self.Text = OpenAnalyse(self, self.filename)
1265 OpenAnalyse(self, self.filename)
1267 print 'This file does not exist'
1270 class IntroPanel(wx.Panel):
1271 def __init__(self, parent):
1272 wx.Panel.__init__(self, parent)
1273 #col = randint(0, 255)
1274 #col1 = randint(0,255)
1275 #col2 = randint(0,255)
1280 bckgrdcolor = wx.Colour(col, col1, col2)
1281 self.SetBackgroundColour(bckgrdcolor)
1282 txtcolour = wx.Colour(250, 250, 250)
1283 linkcolor = wx.Colour(255, 0, 0)
1284 sizer1 = wx.BoxSizer(wx.VERTICAL)
1285 sizer2 = wx.BoxSizer(wx.VERTICAL)
1286 sizer4 = wx.BoxSizer(wx.HORIZONTAL)
1287 grid_sizer_1 = wx.FlexGridSizer(1, 4, 0, 0)
1288 grid_sizer_3 = wx.FlexGridSizer(1, 4, 0, 0)
1289 grid_sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
1291 iralink = hl.HyperLinkCtrl(self, wx.ID_ANY, u"http://www.iramuteq.org", URL="http://www.iramuteq.org")
1292 iralink.SetColours(linkcolor, linkcolor, "RED")
1293 iralink.SetBackgroundColour(bckgrdcolor)
1294 iralink.EnableRollover(True)
1295 iralink.SetUnderlines(False, False, True)
1296 iralink.SetBold(True)
1297 iralink.UpdateLink()
1299 PanelPres = wx.Panel(self)
1300 bckgrdcolor = wx.Colour(randint(0, 255), randint(0, 255), randint(0, 255))
1301 PanelPres.SetBackgroundColour(bckgrdcolor)
1303 label_1 = wx.StaticText(self, -1, u"IRaMuTeQ", size=(-1, -1))
1304 label_1.SetFont(wx.Font(46, wx.TELETYPE, wx.NORMAL, wx.BOLD, 0, "Purisa"))
1305 label_1.SetForegroundColour(wx.RED)
1307 iraicone = wx.Image(os.path.join(ImagePath,'iraicone100x100.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1308 but_ira = wx.StaticBitmap(self, -1, bitmap = iraicone)
1311 label2 = wx.StaticText(PanelPres, -1 , u'\nVersion ' + ConfigGlob.get('DEFAULT', 'version') + '\n')
1312 label2.SetForegroundColour(txtcolour)
1313 label2.SetBackgroundColour(bckgrdcolor)
1314 self.hyper2 = hl.HyperLinkCtrl(PanelPres, wx.ID_ANY, u"REPERE", URL="http://repere.no-ip.org/")
1315 self.hyper2.SetColours(linkcolor, linkcolor, "RED")
1316 self.hyper2.SetBackgroundColour(bckgrdcolor)
1317 self.hyper2.EnableRollover(True)
1318 self.hyper2.SetUnderlines(False, False, True)
1319 self.hyper2.SetBold(True)
1320 self.hyper2.UpdateLink()
1322 label_lerass = wx.StaticText(PanelPres, -1, u'Laboratoire ')
1323 label_lerass.SetForegroundColour(txtcolour)
1324 label_lerass.SetBackgroundColour(bckgrdcolor)
1326 self.hyper_lerass = hl.HyperLinkCtrl(PanelPres, -1, u'LERASS', URL="http://www.lerass.com")
1327 self.hyper_lerass.SetColours(linkcolor, linkcolor, "RED")
1328 self.hyper_lerass.SetBackgroundColour(bckgrdcolor)
1329 self.hyper_lerass.EnableRollover(True)
1330 self.hyper_lerass.SetUnderlines(False, False, True)
1331 self.hyper_lerass.SetBold(True)
1332 self.hyper_lerass.UpdateLink()
1334 blank = wx.StaticText(PanelPres, -1, u'\n')
1335 blank1 = wx.StaticText(PanelPres, -1, u'\n')
1337 labellicence = wx.StaticText(PanelPres, -1, _(u"License GNU GPL").decode('utf8'))
1338 labellicence.SetForegroundColour(txtcolour)
1339 labellicence.SetBackgroundColour(bckgrdcolor)
1341 labelcopy = wx.StaticText(PanelPres, -1, ConfigGlob.get('DEFAULT', 'copyright'))
1342 labelcopy.SetForegroundColour(txtcolour)
1343 labelcopy.SetBackgroundColour(bckgrdcolor)
1345 python_img = wx.Image(os.path.join(ImagePath,'python-logo.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1346 r_img = wx.Image(os.path.join(ImagePath,'Rlogo.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1347 lexique_img = wx.Image(os.path.join(ImagePath,'LexTexte4.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1348 but_python = wx.BitmapButton(self, -1, python_img)
1349 but_lexique = wx.BitmapButton(self, -1, lexique_img)
1350 but_r = wx.BitmapButton(self, -1, r_img)
1351 self.Bind(wx.EVT_BUTTON, self.OnPython, but_python)
1352 self.Bind(wx.EVT_BUTTON, self.OnLexique, but_lexique)
1353 self.Bind(wx.EVT_BUTTON, self.OnR, but_r)
1355 grid_sizer_1.Add(self.hyper2, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1356 grid_sizer_3.Add(label_lerass, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1357 grid_sizer_3.Add(self.hyper_lerass, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1358 sizer4.Add(label_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5)
1360 sizer2.Add(label2, 0, wx.ALIGN_CENTER, 5)
1361 sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 5)
1362 sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 5)
1363 sizer2.Add(grid_sizer_3, 0, wx.ALIGN_CENTER, 5)
1364 sizer2.Add(wx.StaticText(PanelPres, -1, u' '), 0, wx.ALIGN_CENTER, 5)
1365 sizer2.Add(grid_sizer_1, 0, wx.ALIGN_CENTER, 5)
1366 sizer2.Add(labellicence, 0, wx.ALIGN_CENTER, 5)
1367 sizer2.Add(labelcopy, 0, wx.ALIGN_CENTER, 5)
1368 sizer1.Add(sizer4, 2, wx.ALIGN_CENTER_HORIZONTAL, 0)
1369 sizer1.Add(but_ira, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5)
1370 sizer1.Add(iralink, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_TOP, 5)
1371 sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 10)
1372 PanelPres.SetSizer(sizer2)
1373 grid_sizer_2.Add(but_python, 1, wx.ALIGN_BOTTOM)
1374 grid_sizer_2.Add(but_lexique, 1, wx.ALIGN_BOTTOM)
1375 grid_sizer_2.Add(but_r, 1, wx.ALIGN_BOTTOM)
1377 sizer1.Add(PanelPres, 0, wx.EXPAND |wx.ALL, 10)
1378 sizer1.Add(grid_sizer_2, 2, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 1)
1379 self.SetSizer(sizer1)
1382 def OnPython(self,evt):
1383 webbrowser.open('http://www.python.org')
1385 def OnLexique(self,evt):
1386 webbrowser.open('http://www.lexique.org')
1389 webbrowser.open('http://www.r-project.org')
1391 class MySplashScreen(wx.SplashScreen):
1393 bmp = wx.Image(os.path.join(ImagePath, 'splash.png')).ConvertToBitmap()
1394 wx.SplashScreen.__init__(self, bmp,
1395 wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,
1397 self.Bind(wx.EVT_CLOSE, self.OnClose)
1398 self.fc = wx.FutureCall(1, self.ShowMain)
1400 def OnClose(self, evt):
1404 if self.fc.IsRunning():
1409 displaySize = wx.DisplaySize()
1410 w = displaySize[0]/1.2
1411 h = displaySize[1]/1.2
1412 frame = IraFrame(None, -1, "IRaMuTeQ " + ConfigGlob.get('DEFAULT', 'version'), size=(w, h))
1416 frame.OnOpenFromCmdl()
1417 # if self.fc.IsRunning():
1419 #wx.CallAfter(frame.ShowTip)
1421 class MyApp(wx.App):
1424 Create and show the splash screen. It will then create and show
1425 the main frame when it is time to do so.
1427 wx.SystemOptions.SetOptionInt("mac.window-plain-transition", 1)
1428 self.SetAppName("Iramuteq")
1429 splash = MySplashScreen()
1437 if __name__ == '__main__':