test
[iramuteq] / iramuteq.py
1 #!/bin/env python
2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2008-2016, Pierre Ratinaud
5 #License: GNU GPL
6 #test
7
8 from optparse import OptionParser
9
10 parser = OptionParser()
11 parser.add_option("-f", "--file", dest="filename",
12                   help="open FILE", metavar="FILE", default=False)
13 (options, args) = parser.parse_args()
14
15 import sys
16 reload(sys)
17 import locale
18 import tempfile
19 import codecs
20 import os
21 from random import randint
22 from ConfigParser import ConfigParser, RawConfigParser
23 import webbrowser
24 import gettext
25 import logging
26 #------------------------------------
27 import wx
28 import wx.lib.agw.aui as aui
29 import wx.html
30 import wx.grid
31 import wx.lib.hyperlink as hl
32 #------------------------------------
33 from functions import BugReport, PlaySound, History, progressbar
34 from checkversion import NewVersion
35 from guifunct import *
36 from tableau import Tableau
37 from dialog import PrefDialog
38 from tabfrequence import Frequences, FreqMultiple
39 from tabchi2 import ChiSquare
40 from tabchi2mcnemar import McNemar
41 #from tabstudent import MakeStudent
42 from tabchddist import ChdCluster
43 from tabafcm import DoAFCM
44 from tabchdalc import AnalyseQuest
45 from tabsimi import DoSimi
46 from tabrsimple import InputText
47 from tabverges import Prototypical
48 from tabsplitvar import SplitMatrixFromVar
49 #frog textdist import AnalysePam
50 from textstat import Stat
51 from textaslexico import Lexico
52 from textlabbe import DistLabbe
53 from textsimi import SimiTxt, SimiFromCluster
54 from textwordcloud import WordCloud, ClusterCloud
55 from textreinert import Reinert
56 #from textcheckcorpus import checkcorpus
57 from openanalyse import OpenAnalyse
58 from corpus import Builder, SubBuilder, MergeClusters
59 from checkinstall import CreateIraDirectory, CheckRPath, FindRPAthWin32, FindRPathNix, CheckRPackages, IsNew, UpgradeConf, CopyConf, RLibsAreInstalled
60 from chemins import RscriptsPath, ConstructConfigPath, ConstructDicoPath, ConstructGlobalPath, PathOut
61 from parse_factiva_xml import ImportFactiva
62 from parse_dmi import ImportDMI
63 from tools import Extract
64 from analyse_merge import AnalyseMerge
65
66 from tree import LeftTree
67 ##########################################################
68 ID_OpenData = wx.NewId()
69 ID_Import = wx.NewId()
70 ID_OpenText = wx.NewId()
71 ID_OnOpenAnalyse = wx.NewId()
72 ID_Freq = wx.NewId()
73 ID_Chi2 = wx.NewId()
74 ID_Chi2mc = wx.NewId()
75 ID_Student = wx.NewId()
76 ID_CHDSIM = wx.NewId()
77 ID_CHDReinert = wx.NewId()
78 ID_TEXTAFCM = wx.NewId()
79 ID_TEXTSTAT = wx.NewId()
80 ID_ASLEX = wx.NewId()
81 ID_TEXTREINERT = wx.NewId()
82 ID_TEXTPAM = wx.NewId()
83 ID_CHECKCORPUS = wx.NewId()
84 ID_Tabcontent = wx.NewId()
85 ID_AFCM = wx.NewId()
86 ID_SIMI = wx.NewId()
87 ID_CloseTab = wx.NewId()
88 ID_SaveTab = wx.NewId()
89 ID_CreateText = wx.NewId()
90 ID_ACCEUIL = wx.NewId()
91 ID_RESULT = wx.NewId()
92 ID_HTMLcontent = wx.NewId()
93 ID_SimiTxt = wx.NewId()
94 ID_proto = wx.NewId()
95 ID_ImportTXM = wx.NewId()
96 ID_FreqMulti = wx.NewId()
97 ID_Splitfromvar = wx.NewId()
98 ID_Subtxtfrommeta = wx.NewId()
99 ID_Subtxtfromthem = wx.NewId()
100 ID_WC = wx.NewId()
101 ID_ImportEuro = wx.NewId()
102 ID_Fact_xml = wx.NewId()
103 ID_Fact_mail = wx.NewId()
104 ID_Fact_copy = wx.NewId()
105 ID_exportmeta = wx.NewId()
106 ID_importdmi = wx.NewId()
107 ID_merge = wx.NewId()
108 ID_merge_clusters = wx.NewId()
109 ID_labbe = wx.NewId()
110 ##########################################################
111 #elements de configuration
112 ##########################################################
113 #encodage
114 if sys.platform == 'darwin' :
115     sys.setdefaultencoding('UTF-8')
116     wx.SetDefaultPyEncoding('UTF-8')
117 else :
118     sys.setdefaultencoding(locale.getpreferredencoding())
119
120 #chemin de l'application
121 AppliPath = os.path.abspath(os.path.dirname(os.path.realpath(sys.argv[0])))
122 #chemin des images
123 ImagePath = os.path.join(AppliPath, 'images')
124 #configuration generale
125 DictConfigPath = ConstructGlobalPath(AppliPath)
126 ConfigGlob = ConfigParser()
127 ConfigGlob.read(DictConfigPath['global'])
128 DefaultConf = ConfigParser()
129 DefaultConf.read(DictConfigPath['preferences'])
130 #repertoire de l'utilisateur
131 user_home = os.getenv('HOME')
132 if user_home is None :
133     user_home = os.path.expanduser('~')
134
135 UserConfigPath = os.path.abspath(os.path.join(user_home, '.iramuteq-%s' % ConfigGlob.get('DEFAULT', 'version_nb')))
136 #Si pas de fichiers de config utilisateur, on cree le repertoire
137 CreateIraDirectory(UserConfigPath, AppliPath)
138 #fichiers log pour windows (py2exe)
139 log = logging.getLogger('iramuteq')
140 fh = logging.FileHandler(os.path.join(UserConfigPath,'stdout.log'))
141 formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
142 fh.setFormatter(formatter)
143 log.addHandler(fh)
144 if sys.platform != 'win32' and sys.platform != 'darwin':
145     ch = logging.StreamHandler()
146     ch.setFormatter(formatter)
147     log.addHandler(ch)
148 log.setLevel(logging.INFO)
149
150 class writer(object):
151     def write(self, data):
152         if data.strip() != '' :
153             log.info('ERROR : %s' % data)
154
155 class printer(object) :
156     def write(self, data) :
157         if data.strip() != '' :
158             log.info('Print : %s' % data)
159
160 sys.stderr = writer()
161 sys.stdout = printer()
162
163 ConfigPath = ConstructConfigPath(UserConfigPath)
164
165 langues = {'french' : wx.LANGUAGE_FRENCH,
166            'english' : wx.LANGUAGE_ENGLISH,
167            'portuguese' : wx.LANGUAGE_PORTUGUESE,
168            'italian' : wx.LANGUAGE_ITALIAN,
169            'spanish' : wx.LANGUAGE_SPANISH
170            }
171
172 code_langues = {'french' : 'fr_FR',
173                 'english' : 'en',
174                 'portuguese' : 'pt_PT',
175                 'italian' : 'it_IT',
176                 'spanish' : 'es_ES'
177                }
178
179 images_analyses = {
180         'textroot' : 'textroot.png',
181         'alceste' : 'reinert.png',
182         'reinert' : 'reinert.png',
183         'corpus' : 'textcorpus.png',
184         'wordcloud' :'wordcloud.png',
185         'stat' :'stats.png',
186         'simitxt' : 'simitxt.png',
187         'clustersimitxt' :'clustersimitxt.png',
188         'clustercloud' : 'clustercloud.png',
189         'spec' : 'spec.png',
190         'matroot' : 'matroot.png',
191         'matrix' : 'matrix.png',
192         'freq' : 'frequences.png',
193         'freqmulti' : 'frequences.png',
194         'chi2' : 'chi2.png',
195         'chi2mcnemar' : 'chi2.png',
196         'reinertmatrix' : 'reinertmatrix.png',
197         'simimatrix' : 'simimatrix.png',
198         'simiclustermatrix' : 'simimatrix.png',
199         'proto' : 'proto.png',
200         'TXM' : 'TXM.png',
201         'europress' : 'europress.png',
202         'factiva_xml' : 'factiva_xml.png',
203         'factiva_copy' : 'factiva_copy.png',
204         'factiva_mail': 'factiva_mail.png',
205         'iramuteq' : 'iraicone.png',
206         'subcorpusmeta' : 'subcorpusmeta.png',
207         'subcorpusthema' : 'subcorpusthema.png',
208         'preferences' : 'preferences.png',
209         'exportmetatable' : 'exportmetatable.png',
210         'importdmi' : 'twitter.png',
211         'labbe' : 'spec.png'
212          }
213 #####################################################################
214
215 class IraFrame(wx.Frame):
216     def __init__(self, parent, id= -1, title="", pos=wx.DefaultPosition,
217                  size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE |
218                                             wx.SUNKEN_BORDER |
219                                             wx.CLIP_CHILDREN):
220         log.info('Starting... ' )
221         log.info('version : %s' % ConfigGlob.get('DEFAULT', 'version'))
222         wx.Frame.__init__(self, parent, id, title, pos, size, style)
223         #configuration
224         self.AppliPath = AppliPath
225         self.images_path = os.path.join(AppliPath,'images')
226         self.UserConfigPath = UserConfigPath
227         #self.RscriptsPath = ConstructRscriptsPath(AppliPath)
228         self.RscriptsPath = PathOut(dirout=os.path.join(AppliPath, 'Rscripts'))
229         self.RscriptsPath.basefiles(RscriptsPath)
230         #self.DictPath = ConstructDicoPath(AppliPath)
231         self.DictPath = ConstructDicoPath(UserConfigPath)
232         self.ConfigGlob = ConfigGlob
233         self.ConfigPath = ConstructConfigPath(UserConfigPath)
234         self.pref = RawConfigParser()
235         #workaround for import problem
236         self.SimiFromCluster = SimiFromCluster
237         #langues
238         gettext.install('iramuteq',  os.path.join(AppliPath,'locale'), unicode=True)
239         #langues = ['fr_FR', 'en', 'pt_PT']
240         #for l in langues :
241         #    pass
242         self.preslangue = {}
243         for langue in code_langues :
244             self.preslangue[langue] = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=[code_langues[langue]])
245         self.setlangue()
246         #self.presLan_fr = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=['fr_FR'])
247         #self.presLan_en = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=['en'])
248         # tell FrameManager to manage this frame
249         #self._mgr = wx.aui.AuiManager()
250         self._mgr = aui.AuiManager()
251         self._mgr.SetManagedWindow(self)
252         self.x = 0
253         # create menu
254 #--------------------------------------------------------------------------------
255         self.images_analyses = images_analyses
256         for img in images_analyses :
257             self.images_analyses[img] = wx.Image(os.path.join(self.images_path, self.images_analyses[img]), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()
258         self.mb = wx.MenuBar()
259
260         file_menu = wx.Menu()
261         item = wx.MenuItem(file_menu, ID_OpenData, _(u"Open a matrix").decode('utf8'), _(u"Open a matrix").decode('utf8'))
262         #item.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN))
263         item.SetBitmap(self.images_analyses['matroot'])
264         file_menu.AppendItem(item)
265
266         item = wx.MenuItem(file_menu, ID_OpenText, _(u"Open a text corpus").decode('utf8'), _(u"Open a text corpus").decode('utf8'))
267         item.SetBitmap(self.images_analyses['textroot'])
268         file_menu.AppendItem(item)
269
270         item = wx.MenuItem(file_menu, ID_OnOpenAnalyse, _(u"Open an analysis").decode('utf8'), _(u"Open an analysis").decode('utf8'))
271         item.SetBitmap(self.images_analyses['iramuteq'])
272         file_menu.AppendItem(item)
273
274         item = wx.MenuItem(file_menu, ID_ImportTXM, _(u"Import from TXM").decode('utf8'), _(u"Import from TXM").decode('utf8'))
275         item.SetBitmap(self.images_analyses['TXM'])
276         file_menu.AppendItem(item)
277
278         item = wx.MenuItem(file_menu, ID_ImportEuro, _(u"Import from Europress").decode('utf8'), _(u"Import from Europress").decode('utf8'))
279         item.SetBitmap(self.images_analyses['europress'])
280         file_menu.AppendItem(item)
281
282         item = wx.MenuItem(file_menu, ID_importdmi, _(u"Import from DMI-TCAT (exp.)").decode('utf8'), _(u"Import from DMI-TCAT (exp.)").decode('utf8'))
283         item.SetBitmap(self.images_analyses['importdmi'])
284         file_menu.AppendItem(item)
285
286         item = wx.MenuItem(file_menu, ID_merge, _(u'Merge graphs').decode('utf8'), _(u'Merge graphs').decode('utf8'))
287         file_menu.AppendItem(item)
288
289         item = wx.MenuItem(file_menu, ID_merge_clusters, _(u'Corpus from merge clusters').decode('utf8'), _(u'Corpus from merge clusters').decode('utf8'))
290         file_menu.AppendItem(item)
291
292         menuFactiva = wx.Menu()
293         fact_from_xml = wx.MenuItem(menuFactiva, ID_Fact_xml, _(u"from xml").decode('utf8'))
294         fact_from_xml.SetBitmap(self.images_analyses['factiva_xml'])
295         fact_from_mail = wx.MenuItem(menuFactiva, ID_Fact_mail, _(u"from mail").decode('utf8'))
296         fact_from_mail.SetBitmap(self.images_analyses['factiva_mail'])
297         fact_from_txt = wx.MenuItem(menuFactiva, ID_Fact_copy, _(u"from copy/paste").decode('utf8'))
298         fact_from_txt.SetBitmap(self.images_analyses['factiva_copy'])
299         menuFactiva.AppendItem(fact_from_xml)
300         menuFactiva.AppendItem(fact_from_mail)
301         menuFactiva.AppendItem(fact_from_txt)
302         file_menu.AppendMenu(-1, _(u"Import from factiva").decode('utf8'), menuFactiva)
303
304         menuTools = wx.Menu()
305         splitvar = wx.MenuItem(menuTools, wx.ID_ANY, _(u"Split from variable").decode('utf8'))
306         extractmod = wx.MenuItem(menuTools, wx.ID_ANY, _(u"Extract mods").decode('utf8'))
307         extractthem = wx.MenuItem(menuTools, wx.ID_ANY, _(u"Extract thematics").decode('utf8'))
308         menuTools.AppendItem(splitvar)
309         menuTools.AppendItem(extractmod)
310         menuTools.AppendItem(extractthem)
311         self.ID_splitvar = splitvar.GetId()
312         self.ID_extractmod = extractmod.GetId()
313         self.ID_extractthem = extractthem.GetId()
314         file_menu.AppendMenu(-1, _(u"Tools").decode('utf8'), menuTools)
315
316
317         #item = wx.MenuItem(file_menu, ID_SaveTab, _(u"Save tab as...").decode('utf8'), _(u"Save tab as...").decode('utf8'))
318         #item.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FILE_SAVE_AS))
319         #file_menu.AppendItem(item)
320
321         file_menu.Append(wx.ID_EXIT, _(u"Exit").decode('utf8'))
322
323         edit_menu = wx.Menu()
324         pref = wx.MenuItem(edit_menu, wx.ID_PREFERENCES, _(u'Preferences').decode('utf8'))
325         pref.SetBitmap(self.images_analyses['preferences'])
326         edit_menu.AppendItem(pref)
327         #edit_menu.Append(wx.ID_PREFERENCES, _(u'Preferences').decode('utf8'))
328
329         view_menu = wx.Menu()
330         home = wx.MenuItem(view_menu, ID_ACCEUIL, _(u"Home page").decode('utf8'))
331         home.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_GO_HOME, size = (16,16)))
332         view_menu.AppendItem(home)
333         #view_menu.Append(ID_ACCEUIL, _(u"Home page").decode('utf8'))
334         results = wx.MenuItem(view_menu, ID_RESULT, _(u'Show results').decode('utf8'))
335         results.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_LIST_VIEW, size = (16,16)))
336         view_menu.AppendItem(results)
337         #view_menu.Append(ID_RESULT, _(u'Show results').decode('utf8'))
338         #view_menu.AppendSeparator()
339         matrix_menu = wx.Menu()
340         matanalyses = [[ID_Freq, _(u"Frequencies").decode('utf8'), 'freq'],
341                        [ID_FreqMulti, _(u"Multiple  Frequencies").decode('utf8'), 'freqmulti'],
342                        [ID_Chi2, _(u"Chi2").decode('utf8'), 'chi2'],
343                        [ID_Chi2mc, _(u"Chi2 McNemar").decode('utf8'), 'chi2mcnemar'],
344                        {'name' : _(u"Clustering").decode('utf8'),
345                         'content' : [[ID_CHDReinert, _(u"Reinert's Method").decode('utf8'), 'reinertmatrix']]},
346                        [ID_SIMI, _(u"Similarities Analysis").decode('utf8'), 'simimatrix'],
347                        [ID_proto, _(u"Prototypical Analysis").decode('utf8'), 'proto'],
348                        [ID_Splitfromvar, _(u"Split from variable").decode('utf8'), 'subcorpusmeta'],
349                         ]
350
351         for analyse in matanalyses :
352             if not isinstance(analyse, dict) :
353                 item = wx.MenuItem(matrix_menu, analyse[0], analyse[1])
354                 item.SetBitmap(self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)))
355                 matrix_menu.AppendItem(item)
356             else :
357                 nmenu = wx.Menu()
358                 for subana in analyse['content'] :
359                     item = wx.MenuItem(nmenu, subana[0], subana[1])
360                     item.SetBitmap(self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)))
361                     nmenu.AppendItem(item)
362                 matrix_menu.AppendMenu(-1, analyse['name'], nmenu)
363         #item = wx.MenuItem(matrix_menu, ID_Freq, _(u"Frequencies").decode('utf8'))
364         #item.SetBitmap(self.images_analyses['freq'])
365         #matrix_menu.AppendItem(item)
366         #matrix_menu.Append(ID_Freq, _(u"Frequencies").decode('utf8'))
367         #item = wx.MenuItem(matrix_menu, ID_Freq, _(u"Multiple  Frequencies").decode('utf8'))
368         #item.SetBitmap(self.images_analyses['freqmulti'])
369         #matrix_menu.Append(ID_FreqMulti, _(u'Multiple frequencies').decode('utf8'))
370         #matrix_menu.AppendItem(item)
371         #matrix_menu.Append(ID_Chi2, _(u"Chi2").decode('utf8'))
372         #matrix_menu.Append(ID_Student, u"t de Student")
373         #menu_classif = wx.Menu()
374         #menu_classif.Append(ID_CHDReinert, _(u"Reinert's Method").decode('utf8'))
375         #menu_classif.Append(ID_CHDSIM, u"Par matrice des distances")
376         #matrix_menu.AppendMenu(-1, _(u"Clustering").decode('utf8'), menu_classif)
377         #matrix_menu.Append(ID_AFCM, u"AFCM")
378         #matrix_menu.Append(ID_SIMI, _(u"Similarities Analysis").decode('utf8'))
379         #matrix_menu.Append(ID_proto, _(u"Prototypical Analysis").decode('utf8'))
380         ID_RCODE = wx.NewId()
381         #matrix_menu.Append(ID_RCODE, u"Code R...")
382         #menu_splittab = wx.Menu()
383         #ID_SPLITVAR = wx.NewId()
384         #splitvar = wx.MenuItem(menu_splittab, ID_SPLITVAR, _(u"Split from variable").decode('utf8'))
385         #menu_splittab.AppendItem(splitvar)
386         #matrix_menu.AppendMenu(-1, _(u"Split matrix").decode('utf8'), menu_splittab)
387         self.matrix_menu = matrix_menu
388
389         text_menu = wx.Menu()
390         analyses_text = [[ID_TEXTSTAT, _(u"Statistics").decode('utf8'), 'stat'],
391                          [ID_ASLEX, _(u"Specificities and CA").decode('utf8'), 'spec'],
392                          [ID_labbe, _(u"Labbe Distance").decode('utf8'),'labbe'],
393                          {'name' : _(u"Clustering").decode('utf8'),
394                           'content' : [[ID_TEXTREINERT, _(u"Reinert's Method").decode('utf8'), 'alceste']]},
395                          [ID_SimiTxt, _(u"Similarities Analysis").decode('utf8'), 'simitxt'],
396                          [ID_WC, _(u"WordCloud").decode('utf8'), 'wordcloud'],
397                          {'name' : _(u"Sub corpus").decode('utf8'),
398                           'content' : [[ID_Subtxtfrommeta, _(u'Sub corpus from metadata').decode('utf8'), 'subcorpusmeta'],
399                                        [ID_Subtxtfromthem, _(u'Sub corpus from thematic').decode('utf8'), 'subcorpusthema']]},
400                          [ID_exportmeta, _(u"Export metadata table").decode('utf8'), 'exportmetatable'],
401                          ]
402
403         for analyse in analyses_text :
404             if not isinstance(analyse, dict) :
405                 item = wx.MenuItem(text_menu, analyse[0], analyse[1])
406                 item.SetBitmap(self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)))
407                 text_menu.AppendItem(item)
408             else :
409                 nmenu = wx.Menu()
410                 for subana in analyse['content'] :
411                     item = wx.MenuItem(nmenu, subana[0], subana[1])
412                     item.SetBitmap(self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)))
413                     nmenu.AppendItem(item)
414                 text_menu.AppendMenu(-1, analyse['name'], nmenu)
415         #text_menu.Append(ID_CHECKCORPUS, u"Vérifier le corpus")
416 #         text_menu.Append(ID_TEXTSTAT, _(u"Statistics").decode('utf8'))
417 #         text_menu.Append(ID_ASLEX, _(u"Specificities and CA").decode('utf8'))
418 #         #text_menu.Append(ID_TEXTAFCM, u"AFC sur UCI / Vocabulaire")
419 #         menu_classiftxt = wx.Menu()
420 #         menu_classiftxt.Append(ID_TEXTREINERT, _(u"Reinert's Method").decode('utf8'))
421 #         #menu_classiftxt.Append(ID_TEXTPAM, u"Par matrice des distances")
422 #         text_menu.AppendMenu(-1, _(u"Clustering").decode('utf8'), menu_classiftxt)
423 #         text_menu.Append(ID_SimiTxt, _(u"Similarities Analysis").decode('utf8'))
424 #
425 #         text_menu.Append(ID_WC, _(u"WordCloud").decode('utf8'))
426         self.text_menu = text_menu
427
428         help_menu = wx.Menu()
429         about = wx.MenuItem(help_menu, wx.ID_ABOUT, _(u"About...").decode('utf8'))
430         about.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_INFORMATION, size = (16,16)))
431         help_menu.AppendItem(about)
432         #help_menu.Append(wx.ID_ABOUT, _(u"About...").decode('utf8'))
433         help = wx.MenuItem(help_menu, wx.ID_HELP, _(u"Online help...").decode('utf8'))
434         help.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_HELP, size = (16,16)))
435         help_menu.AppendItem(help)
436         #help_menu.Append(wx.ID_HELP, _(u"Online help...").decode('utf8'))
437
438         self.mb.Append(file_menu, _(u"File").decode('utf8'))
439         self.mb.Append(edit_menu, _(u"Edition").decode('utf8'))
440         self.mb.Append(view_menu, _(u"View").decode('utf8'))
441         self.mb.Append(matrix_menu, _(u"Matrix analysis").decode('utf8'))
442         self.mb.Append(text_menu, _(u"Text analysis").decode('utf8'))
443         self.mb.Append(help_menu, _(u"Help").decode('utf8'))
444
445         self.SetMenuBar(self.mb)
446 #--------------------------------------------------------------------
447         self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP)
448         self.statusbar.SetStatusWidths([-2, -3])
449         self.statusbar.SetStatusText(_(u"Ready").decode('utf8'), 0)
450         self.statusbar.SetStatusText(_(u"Welcome").decode('utf8'), 1)
451
452         # min size for the frame itself isn't completely done.
453         # see the end up FrameManager::Update() for the test
454         # code. For now, just hard code a frame minimum size
455         self.SetMinSize(wx.Size(400, 400))
456
457         # create some toolbars
458         tb1 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
459                          wx.TB_FLAT | wx.TB_NODIVIDER)
460         tb1.SetToolBitmapSize(wx.Size(16, 16))
461         tb1.AddLabelTool(ID_OpenData, "OpenData", self.images_analyses['matroot'], shortHelp=_(u"Matrix").decode('utf8'), longHelp=_(u"Open a matrix").decode('utf8'))
462         tb1.AddSeparator()
463         tb1.AddLabelTool(ID_OpenText, "OpenText", self.images_analyses['textroot'], shortHelp=_(u"Text").decode('utf8'), longHelp=_(u"Open a text corpus").decode('utf8'))
464         tb1.AddSeparator()
465         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.AddSeparator()
467         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.AddSeparator()
469         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.AddSeparator()
471         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.AddSeparator()
473         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'))
474         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'))
475         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.AddSeparator()
477         tb1.AddLabelTool(wx.ID_PREFERENCES, "Preferences", self.images_analyses['preferences'], shortHelp= _(u"Preferences").decode('utf8'), longHelp=_(u"Preferences").decode('utf8'))
478         tb1.AddSeparator()
479         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'))
480         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'))
481         tb1.Realize()
482
483         tb_text = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
484                          wx.TB_FLAT | wx.TB_NODIVIDER)
485         for analyse in analyses_text :
486             if not isinstance(analyse, dict) :
487                 tb_text.AddLabelTool(analyse[0], analyse[1], self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)), shortHelp = analyse[1], longHelp = analyse[1])
488             else :
489                 for subana in analyse['content'] :
490                     tb_text.AddLabelTool(subana[0], subana[1], self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)), shortHelp = subana[1], longHelp = subana[1])
491         tb_text.Realize()
492
493         tb_mat = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
494                          wx.TB_FLAT | wx.TB_NODIVIDER)
495         for analyse in matanalyses :
496             if not isinstance(analyse, dict) :
497                 tb_mat.AddLabelTool(analyse[0], analyse[1], self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)), shortHelp = analyse[1], longHelp = analyse[1])
498             else :
499                 for subana in analyse['content'] :
500                     tb_mat.AddLabelTool(subana[0], subana[1], self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)), shortHelp = subana[1], longHelp = subana[1])
501         tb_mat.Realize()
502
503         tb_help = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
504                          wx.TB_FLAT | wx.TB_NODIVIDER)
505         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'))
506         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         tb_help.Realize()
508 #------------------------------------------------------------------------------------------------
509
510         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
512         #self._mgr.AddPane(self.text_ctrl_txt, wx.aui.AuiPaneInfo().
513         #                  Name("Text").CenterPane())
514         self._mgr.AddPane(self.text_ctrl_txt, aui.AuiPaneInfo().
515                           Name("Text").CenterPane())
516         #self._mgr.AddPane(IntroPanel(self), wx.aui.AuiPaneInfo().Name("Intro_Text").
517         #                  CenterPane())
518         self._mgr.AddPane(IntroPanel(self), aui.AuiPaneInfo().Name("Intro_Text").
519                           CenterPane())
520         #if not os.path.exists(os.path.join(UserConfigPath, 'history.db')) :
521         #    with open(os.path.join(UserConfigPath, 'history.db'), 'w') as f :
522         #        f.write('')
523         self.history = History(os.path.join(UserConfigPath, 'history.db'))
524         #self.history.dostat()
525         self.tree = LeftTree(self)
526         self._mgr.AddPane(self.tree, aui.AuiPaneInfo().Name("lefttree").Caption(_(u"Historic").decode('utf8')).
527                           Left().MinSize(wx.Size(200,500)).Layer(1).Position(1).CloseButton(False).MaximizeButton(True).
528                           MinimizeButton(True))
529
530         #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)
531         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)
532         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
533         self.nb.SetAGWWindowStyleFlag(notebook_flags)
534         self.nb.SetArtProvider(aui.ChromeTabArt())
535         #self.nb.SetArtProvider(aui.VC8TabArt())
536         #self.nb.parent = self
537         #self._notebook_style = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | wx.NO_BORDER
538         #self._mgr.AddPane(self.nb, wx.aui.AuiPaneInfo().
539         #                      Name("Tab_content").
540         #                      CenterPane())
541         self._mgr.AddPane(self.nb, aui.AuiPaneInfo().
542                               Name("Tab_content").
543                               CenterPane())
544
545         #self._mgr.AddPane(self.Sheet, wx.aui.AuiPaneInfo().Name("Data").CenterPane())
546         #self._mgr.AddPane(self.Sheet, aui.AuiPaneInfo().Name("Data").CenterPane())
547         self.nb.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnCloseTab)
548         self.nb.Bind(aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
549         # add the toolbars to the manager
550
551         #self._mgr.AddPane(tb1, wx.aui.AuiPaneInfo().
552         #                  Name("tb1").Caption("Fichiers").
553         #                  ToolbarPane().Top().
554         #                  LeftDockable(False).RightDockable(False))
555         self._mgr.AddPane(tb1, aui.AuiPaneInfo().
556                           Name("tb1").Caption("Fichiers").
557                           ToolbarPane().Top().
558                           LeftDockable(True).RightDockable(False))
559
560         self._mgr.AddPane(tb_text, aui.AuiPaneInfo().
561                           Name("tb_text").Caption("analyse_text").
562                           ToolbarPane().Top().
563                           LeftDockable(True).RightDockable(False))
564
565         self._mgr.AddPane(tb_mat, aui.AuiPaneInfo().
566                           Name("tb_mat").Caption("analyse_matrix").
567                           ToolbarPane().Top().
568                           LeftDockable(True).RightDockable(False))
569
570         self._mgr.AddPane(tb_help, aui.AuiPaneInfo().
571                           Name("tb_help").Caption("help").
572                           ToolbarPane().Top().
573                           LeftDockable(True).RightDockable(False))
574
575         self._mgr.GetPane('tb_text').Hide()
576         self._mgr.GetPane('tb_mat').Hide()
577
578         self.ShowAPane("Intro_Text")
579         self._mgr.GetPane("lefttree").Show()
580         self._mgr.GetPane("classif_tb").Hide()
581         # "commit" all changes made to FrameManager
582         self._mgr.Update()
583
584         # Show How To Use The Closing Panes Event
585 ##################################################################
586         self.Bind(wx.EVT_MENU, self.OnAcceuil, id=ID_ACCEUIL)
587         self.Bind(wx.EVT_MENU, self.ShowTab, id=ID_RESULT)
588         self.Bind(wx.EVT_MENU, self.OnOpenData, id=ID_OpenData)
589         self.Bind(wx.EVT_MENU, self.OnOpenText, id=ID_OpenText)
590         self.Bind(wx.EVT_MENU, self.OnOpenAnalyse, id=ID_OnOpenAnalyse)
591         self.Bind(wx.EVT_MENU, self.import_factiva_xml, fact_from_xml)
592         self.Bind(wx.EVT_MENU, self.import_factiva_mail, fact_from_mail)
593         self.Bind(wx.EVT_MENU, self.import_factiva_txt, fact_from_txt)
594         self.Bind(wx.EVT_MENU, self.ExtractTools, splitvar)
595         self.Bind(wx.EVT_MENU, self.ExtractTools, extractmod)
596         self.Bind(wx.EVT_MENU, self.ExtractTools, extractthem)
597         self.Bind(wx.EVT_MENU, self.OnFreq, id=ID_Freq)
598         self.Bind(wx.EVT_MENU, self.OnFreqMulti, id=ID_FreqMulti)
599         self.Bind(wx.EVT_MENU, self.OnChi2, id=ID_Chi2)
600         self.Bind(wx.EVT_MENU, self.OnChi2McNemar, id=ID_Chi2mc)
601         self.Bind(wx.EVT_MENU, self.OnStudent, id=ID_Student)
602         self.Bind(wx.EVT_MENU, self.OnCHDSIM, id=ID_CHDSIM)
603         self.Bind(wx.EVT_MENU, self.OnCHDReinert, id=ID_CHDReinert)
604         self.Bind(wx.EVT_MENU, self.OnAFCM, id=ID_AFCM)
605         self.Bind(wx.EVT_MENU, self.OnProto, id=ID_proto)
606         self.Bind(wx.EVT_MENU, self.OnSplitVar, id = ID_Splitfromvar)
607         #self.Bind(wx.EVT_MENU, self.OnRCode, id=ID_RCODE)
608         #self.Bind(wx.EVT_MENU, self.OnSplitVar, id=ID_SPLITVAR)
609         #self.Bind(wx.EVT_MENU, self.OnCheckcorpus, id = ID_CHECKCORPUS)
610         self.Bind(wx.EVT_MENU, self.OnTextStat, id=ID_TEXTSTAT)
611         self.Bind(wx.EVT_MENU, self.OnTextSpec, id=ID_ASLEX)
612         self.Bind(wx.EVT_MENU, self.OnTextLabbe, id=ID_labbe)
613         self.Bind(wx.EVT_MENU, self.OnTextAfcm, id=ID_TEXTAFCM)
614         self.Bind(wx.EVT_MENU, self.OnTextReinert, id=ID_TEXTREINERT)
615         self.Bind(wx.EVT_MENU, self.OnPamSimple, id=ID_TEXTPAM)
616         self.Bind(wx.EVT_MENU, self.OnSimiTxt, id=ID_SimiTxt)
617         self.Bind(wx.EVT_MENU, self.OnWordCloud, id=ID_WC)
618         self.Bind(wx.EVT_MENU, self.OnSubText, id = ID_Subtxtfrommeta)
619         self.Bind(wx.EVT_MENU, self.OnSubText, id = ID_Subtxtfromthem)
620         self.Bind(wx.EVT_MENU, self.OnSimiTab, id=ID_SIMI)
621         self.Bind(wx.EVT_MENU, self.OnExit, id=wx.ID_EXIT)
622         #self.Bind(wx.EVT_MENU, self.OnSaveTabAs, id=ID_SaveTab)
623         self.Bind(wx.EVT_MENU, self.OnAbout, id=wx.ID_ABOUT)
624         self.Bind(wx.EVT_MENU, self.OnHelp, id=wx.ID_HELP)
625         self.Bind(wx.EVT_MENU, self.OnPref, id=wx.ID_PREFERENCES)
626         self.Bind(wx.EVT_MENU, self.OnImportTXM, id=ID_ImportTXM)
627         self.Bind(wx.EVT_MENU, self.OnImportEuropress, id=ID_ImportEuro)
628         self.Bind(wx.EVT_MENU, self.OnImportDMI, id=ID_importdmi)
629         self.Bind(wx.EVT_MENU, self.OnExportMeta, id=ID_exportmeta)
630         self.Bind(wx.EVT_MENU, self.OnMergeGraph, id = ID_merge)
631         self.Bind(wx.EVT_MENU, self.OnMergeClusters, id = ID_merge_clusters)
632         self.Bind(wx.EVT_CLOSE, self.OnClose)
633 ##################################################################
634         flags = self._mgr.GetAGWFlags()
635         #flags &= ~wx.aui.AUI_MGR_TRANSPARENT_HINT
636         #flags &= ~wx.aui.AUI_MGR_VENETIAN_BLINDS_HINT
637         #flags &= ~wx.aui.AUI_MGR_RECTANGLE_HINT
638         flags &= ~(aui.AUI_MGR_RECTANGLE_HINT | aui.AUI_MGR_ALLOW_FLOATING)
639         self._mgr.SetAGWFlags(self._mgr.GetAGWFlags() ^ (aui.AUI_MGR_RECTANGLE_HINT | aui.AUI_MGR_ALLOW_FLOATING))
640         self._mgr.GetArtProvider().SetMetric(aui.AUI_DOCKART_GRADIENT_TYPE, aui.AUI_GRADIENT_HORIZONTAL)
641         self.GetDockArt().SetColor(aui.AUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR, "#00FFF9")
642         self.DoUpdate()
643
644         self._icon = wx.Icon(os.path.join(ImagePath, "iraicone.ico"), wx.BITMAP_TYPE_ICO)
645         self.SetIcon(self._icon)
646 ##########################
647         self.ctrl = ""
648         self.input_path = [False]
649         self.TEMPDIR = tempfile.mkdtemp('iramuteq')
650         self.FileTabList = []
651         self.listbar=[]
652         self.DictTab = {}
653         self.FreqNum = 0
654         self.colsep = ''
655         self.txtsep = ''
656         self.g_header = False
657         self.g_id = False
658         self.table = ''
659         self.fileforR = ''
660         self.filename = ''
661         self.nastrings = ''
662         self.encode = ''
663         self.SysEncoding = sys.getdefaultencoding()
664         self.syscoding = sys.getdefaultencoding()
665         #print 'SysEncoding',self.SysEncoding
666         if self.SysEncoding == 'mac-roman' : self.SysEncoding = 'MacRoman'
667         self.type = ''
668
669 ##############################################################@
670         self.ShowMenu('view', True)
671         self.ShowMenu('matrix', False)
672         self.ShowMenu('text', False)
673
674         self._mgr.Update()
675
676         self.DataPop = False
677         self.DataTxt = False
678         self.Text = ''
679
680         self.lexique = None
681         self.corpus = None
682
683     def finish_init(self) :
684         try :
685             self.pref.read(self.ConfigPath['preferences'])
686             if IsNew(self) :
687                 UpgradeConf(self)
688                 self.pref.read(self.ConfigPath['preferences'])
689                 New = True
690             else :
691                 CopyConf(self)
692                 New = False
693         except :
694             UpgradeConf(self)
695             self.pref.read(self.ConfigPath['preferences'])
696             New = True
697         self.sound = self.pref.getboolean('iramuteq', 'sound')
698         self.check_update = self.pref.getboolean('iramuteq', 'checkupdate')
699         self.version = ConfigGlob.get('DEFAULT', 'version')
700         #configuration des chemins de R
701         self.PathPath = ConfigParser()
702         self.PathPath.read(ConfigPath['path'])
703         BestRPath = False
704         if not CheckRPath(self.PathPath) :
705             if sys.platform == 'win32':
706                 BestRPath = FindRPAthWin32()
707             else:
708                 BestRPath = FindRPathNix()
709             if BestRPath:
710                 self.PathPath.set('PATHS', 'rpath', BestRPath)
711                 with open(ConfigPath['path'], 'w') as f :
712                     self.PathPath.write(f)
713         else:
714             BestRPath = True
715         if BestRPath :
716             self.RPath = self.PathPath.get('PATHS', 'rpath')
717             if New :
718                 CheckRPackages(self)
719             if not RLibsAreInstalled(self) :
720                 CheckRPackages(self)
721         else :
722             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'),
723                              _(u"If R is installed, report its path in Preferences.").decode('utf8'),
724                              _(u"IRaMuTeQ does not work without R.").decode('utf8')])
725             dlg = wx.MessageDialog(self, msg, _(u"Problem").decode('utf8'), wx.OK | wx.ICON_WARNING)
726             dlg.CenterOnParent()
727             if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
728                 pass
729             dlg.Destroy()
730
731     def setlangue(self) :
732         self.pref.read(self.ConfigPath['preferences'])
733         try :
734             guilangue = self.pref.get('iramuteq', 'guilanguage')
735         except :
736             guilangue = DefaultConf.get('iramuteq', 'guilanguage')
737         self.preslangue.get(guilangue, 'english').install()
738
739     def OnVerif(self, evt) :
740         pack = CheckRPackages(self)
741         if pack :
742             dlg = wx.MessageDialog(self, _(u"Installation OK").decode('utf8'), _(u"Installation").decode('utf8'), wx.OK | wx.ICON_INFORMATION | wx.STAY_ON_TOP)
743             dlg.CenterOnParent()
744             if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
745                 evt.Veto()
746
747     def ShowMenu(self, menu, Show=True):
748         if menu == 'text' :
749             menu_pos = 4
750             if Show :
751                 self._mgr.GetPane('tb_text').Show()
752             else :
753                 self._mgr.GetPane('tb_text').Hide()
754         elif menu == 'matrix' :
755             menu_pos = 3
756             if Show :
757                 self._mgr.GetPane('tb_mat').Show()
758             else :
759                 self._mgr.GetPane('tb_mat').Hide()
760         elif menu == 'view' :
761             menu_pos = 2
762         else :
763             menu_pos = None
764
765         #menu_pos = self.mb.FindMenu(menu)
766         if not menu_pos is None :
767             self.mb.EnableTop(menu_pos, Show)
768             self.mb.UpdateMenus()
769         self._mgr.Update()
770
771 #--------------------------------------------------------------------
772     def OnClose(self, event):
773         print 'onclose'
774         with open(self.ConfigPath['path'], 'w') as f :
775             self.PathPath.write(f)
776         self._mgr.UnInit()
777         del self._mgr
778         self.Destroy()
779
780     def OnOpenData(self, event):
781         inputname, self.input_path = OnOpen(self, "Data")
782         if inputname:
783             #filename = self.input_path[0]
784             self.tableau = Tableau(self,os.path.abspath(self.input_path[0]))
785             val = get_table_param(self, self.input_path[0])
786             if val == wx.ID_OK :
787                 busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self)
788                 wx.SafeYield()
789                 try :
790                     self.tableau.make_content()
791                     OpenAnalyse(self, self.tableau.parametres)
792                     self.tree.OnItemAppend(self.tableau.parametres)
793                     del busy
794                 except :
795                     del busy
796                     BugReport(self)
797                 #self.tableau.show_tab()
798
799     def OnOpenAnalyse(self, event):
800         self.AnalysePath = OnOpen(self, "Analyse")
801         if self.AnalysePath :
802             OpenAnalyse(self, self.AnalysePath[1][0], True)
803             self.ShowMenu('view')
804
805     def OnOpenText(self, event):
806         inputname, self.input_path = OnOpen(self, "Texte")
807         self.filename = self.input_path[0]
808         if inputname:
809             self.OpenText()
810
811     def OnSubText(self, evt, corpus = None, parametres = None):
812         if corpus is None :
813             corpus = self.tree.getcorpus()
814         if evt.GetId() == ID_Subtxtfrommeta :
815             parametres = {'frommeta' : True}
816         elif evt.GetId() == ID_Subtxtfromthem :
817             parametres = {'fromtheme' : True}
818         builder = SubBuilder(self, corpus, parametres)
819         if builder.res == wx.ID_OK :
820             busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self)
821             wx.SafeYield()
822             corpus = builder.doanalyse()
823             self.history.add(corpus.parametres)
824             OpenAnalyse(self, corpus.parametres)
825             self.tree.OnItemAppend(corpus.parametres)
826             del busy
827
828     def OpenText(self):
829         builder =  Builder(self, 5)
830         if builder.res == wx.ID_OK :
831             try :
832                 corpus = builder.doanalyse()
833                 self.history.add(corpus.parametres)
834                 self.tree.OnItemAppend(corpus.parametres)
835                 OpenAnalyse(self, corpus.parametres)
836             except :
837                 builder.dlg.Destroy()
838                 BugReport(self)
839             else :
840                 count = 1
841                 keepGoing = builder.dlg.Update(count, u"Lecture du fichier")
842                 self.ShowMenu('view')
843                 self.ShowMenu('text')
844                 self.ShowMenu('matrix', False)
845                 self.type = "Texte"
846                 self.DataTxt = False
847                 self.Text = ''
848                 count += 1
849                 keepGoing = builder.dlg.Update(count, u"Chargement du dictionnaire")
850                 builder.dlg.Destroy()
851
852     def OnExit(self, event):
853         self.Close()
854
855     def OnAbout(self, event):
856         info = wx.AboutDialogInfo()
857         info.Name = ConfigGlob.get('DEFAULT', 'name')
858         info.Version = ConfigGlob.get('DEFAULT', 'version')
859         info.Copyright = ConfigGlob.get('DEFAULT', 'copyright')
860         info.Translators = ConfigGlob.get('DEFAULT', 'translators').decode('utf8').split(';')
861         info.Description = u"""
862 Interface de R pour les Analyses Multidimensionnelles
863 de Textes et de Questionnaires
864
865 Un logiciel libre
866 construit avec des logiciels libres.
867
868 Laboratoire LERASS
869
870 REPERE
871 """
872         info.WebSite = ("http://www.iramuteq.org", u"Site web IRaMuTeQ")
873         dev = ConfigGlob.get('DEFAULT', 'dev').decode('utf8').split(';')
874         info.Developers = dev
875         info.License = u"""Iramuteq est un logiciel libre ; vous pouvez le diffuser et/ou le modifier
876 suivant les termes de la Licence Publique Générale GNU telle que publiée 
877 par la Free Software Foundation ; soit la version 2 de cette licence, 
878 soit (à votre convenance) une version ultérieure.
879
880 Iramuteq est diffusé dans l'espoir qu'il sera utile, 
881 mais SANS AUCUNE GARANTIE ; sans même une garantie implicite 
882 de COMMERCIALISATION ou d'ADÉQUATION Ã€ UN USAGE PARTICULIER. 
883 Voyez la Licence Publique Générale GNU pour plus de détails.
884
885 Vous devriez avoir reçu une copie de la Licence Publique Générale GNU
886 avec Iramuteq ; sinon, veuillez Ã©crire Ã  la Free Software Foundation,
887 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, Ã‰tats-Unis."""
888         wx.AboutBox(info)
889
890     def GetDockArt(self):
891         return self._mgr.GetArtProvider()
892
893     def DoUpdate(self):
894         self._mgr.Update()
895
896     def OnPageChanged(self, event) :
897         new = event.GetSelection()
898         nobject = event.GetEventObject()
899         parent = nobject.GetParent()
900         if isinstance(parent, IraFrame) :
901             npage = self.nb.GetPage(new)
902             if 'parametres' in dir(npage) :
903                 self.tree.GiveFocus(uuid=npage.parametres['uuid'])
904                 if npage.parametres.get('matrix', False) :
905                     self.ShowMenu('text', False)
906                     self.ShowMenu('matrix', True)
907                 elif npage.parametres.get('corpus', False) :
908                     self.ShowMenu('text')
909                     self.ShowMenu('matrix', False)
910
911     def OnCloseTab(self, evt):
912         #log.info('Closing tab %s' % str(evt.GetEventObject()))
913         ctrl = evt.GetEventObject()
914         if isinstance(ctrl.GetParent(), aui.AuiNotebook) or isinstance(ctrl.GetParent(), wx.Panel):
915             notebook = True
916         else :
917             notebook = False
918         page = self.nb.GetPage(self.nb.GetSelection())
919         if 'parametres' in dir(page) and isinstance(ctrl.GetParent(), IraFrame) :
920             self.history.rmtab(page.parametres)
921             self.tree.CloseItem(uuid = page.parametres['uuid'])
922         TabTitle = self.nb.GetPageText(self.nb.GetSelection())
923
924         if self.nb.GetPageCount() == 1 and not notebook :
925             self.LastTabClose()
926
927     def LastTabClose(self) :
928         if self.nb.GetPageCount() == 1 :
929             if self.DataTxt :
930                 self.ShowAPane("Text")
931             elif self.DataPop :
932                 self.ShowAPane("Data")
933             else :
934                 self.ShowAPane("Intro_Text")
935
936     def GetStartPosition(self):
937
938         self.x = self.x + 20
939         x = self.x
940         pt = self.ClientToScreen(wx.Point(0, 0))
941
942         return wx.Point(pt.x + x, pt.y + x)
943
944     def ShowAPane(self, panel):
945         for pane in self._mgr.GetAllPanes() :
946             if not pane.IsToolbar() and pane.name != 'lefttree':
947                 pane.Hide()
948         self._mgr.GetPane(panel).Show()
949         self._mgr.Update()
950
951     def OnAcceuil(self, event):
952         self.ShowAPane(u"Intro_Text")
953         event.Skip()
954
955     def CreateHTMLCtrl(self):
956         ctrl = wx.html.HtmlWindow(self, -1, wx.DefaultPosition, wx.Size(400, 300))
957         if "gtk2" in wx.PlatformInfo:
958             ctrl.SetStandardFonts()
959         ctrl.SetPage(u"text")
960         return ctrl
961
962     def ShowTab(self, evt):
963         self.ShowAPane("Tab_content")
964
965 ################################################################
966 #debut des analyses
967 ################################################################
968     def analyse_matrix(self, analyse, analyse_type = '', matrix = None, parametres = None, dlgnb = 1):
969         if matrix is None :
970             matrix = self.tree.getmatrix()
971         if parametres is not None :
972             parametres['type'] = analyse_type
973         else :
974             parametres = {'type' : analyse_type}
975         try :
976         #print 'plus de bug@@@@@@@@@@@@@@@@@@@@@@'
977             analyse(self, matrix, parametres = parametres, dlg = dlgnb)
978         except:
979             BugReport(self)
980
981     def OnFreq(self, event, matrix = None):
982         self.analyse_matrix(Frequences, analyse_type = 'freq', matrix = matrix, dlgnb = 3)
983
984     def OnFreqMulti(self, event, matrix = None):
985         self.analyse_matrix(FreqMultiple, analyse_type = 'freqmulti', matrix = matrix, dlgnb = 3)
986
987     def OnChi2(self, event, matrix = None):
988         self.analyse_matrix(ChiSquare, matrix = matrix, analyse_type = 'chi2', dlgnb = 3)
989
990     def OnChi2McNemar(self, event, matrix = None):
991         self.analyse_matrix(McNemar, matrix = matrix, analyse_type = 'chi2mcnemar', dlgnb = 3)
992
993     def OnSimiTab(self, event, matrix = None):
994         self.analyse_matrix(DoSimi, matrix = matrix, analyse_type = 'simimatrix', dlgnb = 5)
995
996     def OnCHDReinert(self, event, matrix = None):
997         #if matrix is None :
998         #    matrix = self.tree.getmatrix()
999         #AnalyseQuest(self, matrix, parametres = {'type' : 'reinertmatrix'}, dlg = 3)
1000         self.analyse_matrix(AnalyseQuest, matrix = matrix, analyse_type = 'reinertmatrix', dlgnb = 5)
1001
1002     def OnStudent(self, event):
1003         try:
1004             MakeStudent(self)
1005         except:
1006             BugReport(self)
1007
1008     def OnRCode(self, event):
1009         try:
1010             InputText(self)
1011         except:
1012             BugReport(self)
1013
1014     def OnCHDSIM(self, event):
1015         try:
1016         #    print 'ATTENTION!!!!'
1017             chdsim = ChdCluster(self)
1018             if chdsim.val == wx.ID_OK:
1019                 PlaySound(self)
1020         except:
1021             BugReport(self)
1022
1023 #     def OnCHDReinert(self, event):
1024 #         try:
1025 #          #   print('PLUS DE BUG SUR ALCESTE QUESTIONNAIRE')
1026 #             self.quest = AnalyseQuest(self)
1027 #             if self.quest.val == wx.ID_OK:
1028 #                 PlaySound(self)
1029 #         except:
1030 #             BugReport(self)
1031     def OnMergeGraph(self, evt):
1032         #FIXME
1033         AnalyseMerge(self, {'type': 'merge', 'fileout' : '/tmp/test.txt'}, dlg = 5)
1034
1035     def OnMergeClusters(self, evt) :
1036         builder = MergeClusters(self, {})
1037         if builder.res == wx.ID_OK :
1038             busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self)
1039             wx.SafeYield()
1040             corpus = builder.doanalyse()
1041             self.history.add(corpus.parametres)
1042             OpenAnalyse(self, corpus.parametres)
1043             self.tree.OnItemAppend(corpus.parametres)
1044             del busy
1045
1046     def OnProto(self, evt, matrix = None) :
1047         self.analyse_matrix(Prototypical, matrix = matrix, analyse_type = 'proto', dlgnb = 3) 
1048         #Prototypical(self, {'type' : 'proto'})
1049
1050     def OnSplitVar(self, evt, matrix = None):
1051         if matrix is None :
1052             matrix = self.tree.getmatrix()
1053         self.analyse_matrix(SplitMatrixFromVar, matrix = matrix, analyse_type = 'splitvar', parametres = {'pathout': matrix.pathout.dirout}, dlgnb = 3)
1054         #matrix = self.tree.getmatrix()
1055
1056
1057     def OnSimiTxt(self, evt, corpus = None) :
1058         #    print 'PLUS DE BUG SUR SIMITXT'
1059         try :
1060             #self.Text = SimiTxt(self)
1061             if corpus is None :
1062                 corpus = self.tree.getcorpus()
1063             self.Text = SimiTxt(self, corpus, parametres = {'type': 'simitxt'}, dlg = 3)
1064             if self.Text.val == wx.ID_OK :
1065                 PlaySound(self)
1066         except :
1067             BugReport(self)
1068
1069     def OnWordCloud(self, evt, corpus = None) :
1070         #    print 'PLUS DE BUG SUR WORDCLOUD'
1071         try :
1072             if corpus is None :
1073                 corpus = self.tree.getcorpus()
1074             self.Text = WordCloud(self, corpus, parametres = {'type' : 'wordcloud'}, dlg = 3)
1075             if self.Text.val == wx.ID_OK :
1076                 PlaySound(self)
1077         except :
1078             BugReport(self)
1079
1080     def OnClusterCloud(self, corpus, parametres = None) :
1081         self.Text = ClusterCloud(self, corpus, parametres = parametres, dlg = 3)
1082
1083     def OnAFCM(self, event):
1084         try:
1085             DoAFCM(self)
1086         except:
1087             BugReport(self)
1088
1089     def OnTextStat(self, event, corpus = None):
1090             #print 'PAS DE BUG SUR TEXT STAT'
1091         try:
1092             if corpus is None :
1093                 corpus = self.tree.getcorpus()
1094             self.Text = Stat(self, corpus, parametres = {'type': 'stat'}, dlg = 7)
1095
1096             if self.Text.val == wx.ID_OK :
1097                 PlaySound(self)
1098         except:
1099             BugReport(self)
1100
1101     def OnTextSpec(self, event, corpus = None):
1102         try:
1103             #self.Text = AsLexico(self)
1104             #print('ATTENTION : PLUS DE BUG SUR LEXICO')
1105             if corpus is None :
1106                 corpus = self.tree.getcorpus()
1107             self.Text = Lexico(self, corpus, parametres = {'type' : 'spec'}, dlg = 3)
1108             if self.Text.val == wx.ID_OK :
1109                 PlaySound(self)
1110         except:
1111             BugReport(self)
1112
1113     def OnTextLabbe(self, event, corpus = None):
1114         try:
1115             if corpus is None :
1116                 corpus = self.tree.getcorpus()
1117             self.Text = DistLabbe(self, corpus, parametres = {'type' : 'labbe'}, dlg = 3)
1118             if self.Text.val == wx.ID_OK :
1119                 PlaySound(self)
1120         except:
1121             BugReport(self)
1122
1123
1124     def OnTextAfcm(self, event):
1125         try:
1126             AfcUci(self)
1127             PlaySound(self)
1128         except:
1129             BugReport(self)
1130
1131     def import_factiva_xml(self,event):
1132         try :
1133             ImportFactiva(self, 'xml')
1134         except :
1135             BugReport(self)
1136
1137     def import_factiva_mail(self, evt) :
1138         try :
1139             ImportFactiva(self, 'mail')
1140         except :
1141             BugReport(self)
1142
1143     def import_factiva_txt(self, evt) :
1144         try :
1145             ImportFactiva(self, 'txt')
1146         except :
1147             BugReport(self)
1148
1149     def OnImportTXM(self, evt) :
1150         try :
1151             ImportFactiva(self, 'txm')
1152         except :
1153             BugReport(self)
1154
1155     def OnImportEuropress(self, evt) :
1156         try :
1157             ImportFactiva(self, 'euro')
1158         except :
1159             BugReport(self)
1160
1161     def OnImportDMI(self, evt):
1162         ImportDMI(self, {})
1163
1164     def OnExportMeta(self, evt, corpus = None):
1165         if corpus is None :
1166             corpus = self.tree.getcorpus()
1167         try :
1168             ExportMetaTable(self, corpus)
1169         except :
1170             BugReport(self)
1171
1172     def ExtractTools(self, evt) :
1173         ID = evt.GetId()
1174         if ID == self.ID_splitvar :
1175             Extract(self, 'splitvar')
1176         elif ID == self.ID_extractmod :
1177             Extract(self, 'mods')
1178         elif ID == self.ID_extractthem :
1179             Extract(self, 'them')
1180
1181     def OnTextReinert(self, event, corpus = None):
1182         try:
1183             #print('ATTENTION : PLUS DE BUG SUR ALCESTE')
1184             #RunAnalyse(self, corpus, Alceste, OptAlceste)
1185             if corpus is None :
1186                 corpus = self.tree.getcorpus()
1187             self.Text = Reinert(self, corpus, parametres = {'type': 'alceste'}, dlg = 6)
1188             if self.Text.val == wx.ID_OK:
1189                 PlaySound(self)
1190         except:
1191             BugReport(self)
1192
1193     def OnPamSimple(self, event, corpus = None):
1194         try:
1195             if corpus is None :
1196                 corpus = self.tree.getcorpus()
1197             self.Text = AnalysePam(self, corpus, parametres = {'type' : 'pamtxt'}, dlg = 6)
1198             if self.Text.val == wx.ID_OK:
1199                 PlaySound(self)
1200         except:
1201             BugReport(self)
1202
1203     def SimiCluster(self, parametres = {}, fromprof = False, tableau = None) :
1204         self.analyse_matrix(DoSimi, parametres = parametres, analyse_type = 'simiclustermatrix', matrix = tableau, dlgnb = 5)
1205
1206 #    def OnSimi(self,evt):
1207 #        try :
1208             #print 'ATTENTION !!!! VERGES'
1209             #print 'PLUS DE BUG SUR SIMI'
1210 #            self.res = DoSimi(self, param = None)
1211             #self.res = Verges(self)
1212 #            if self.res.val == wx.ID_OK :
1213 #                PlaySound(self)
1214 #        except :
1215 #            BugReport(self)
1216 #################################################################
1217
1218     def OnHelp(self, event):
1219         webbrowser.open('http://www.iramuteq.org/documentation')
1220
1221     def OnPref(self, event):
1222         dlg = PrefDialog(self)
1223         dlg.CenterOnParent()
1224         self.val = dlg.ShowModal()
1225         dlg.Destroy()
1226
1227     def Upgrade(self) :
1228         if self.check_update:
1229             NewVersion(self)
1230         else:
1231             print 'pas de verif'
1232         #IsNew(self)
1233         #CheckRPackages(self)
1234
1235     def OnOpenFromCmdl(self):
1236         truepath = True
1237         if options.filename :
1238             if os.path.exists(options.filename):
1239                 self.filename = os.path.abspath(options.filename)
1240             else:
1241                 truepath = False
1242         elif args :
1243             if os.path.exists(os.path.realpath(args[0])):
1244                 self.filename = os.path.abspath(os.path.realpath(args[0]))
1245             else:
1246                 truepath = False
1247         else:
1248             return
1249         if truepath :
1250             if os.path.splitext(self.filename)[1] in ['.csv', '.xls', '.ods']:
1251                 self.tableau = Tableau(self, self.filename)
1252                 val = get_table_param(self, self.filename)
1253                 if val == wx.ID_OK :
1254                     self.tableau.make_content()
1255                     OpenAnalyse(self, self.tableau.parametres)
1256                     self.tree.OnItemAppend(self.tableau.parametres)
1257                 #get_table_param(self, self.filename)
1258                 #self.tableau.make_content()
1259                 #self.tableau.show_tab()
1260                 #open_data(self, self.filename)
1261             elif os.path.splitext(self.filename)[1] == '.txt':
1262                 self.OpenText()
1263             elif os.path.splitext(self.filename)[1] == '.ira' :
1264                 #self.corpus = Corpus(self)
1265                 #self.Text = OpenAnalyse(self, self.filename)
1266                 OpenAnalyse(self, self.filename)
1267         if not truepath:
1268             print 'This file does not exist'
1269
1270
1271 class IntroPanel(wx.Panel):
1272     def __init__(self, parent):
1273         wx.Panel.__init__(self, parent)
1274         #col = randint(0, 255)
1275         #col1 = randint(0,255)
1276         #col2 = randint(0,255)
1277         #col = 57
1278         col = 161
1279         col1 = 198
1280         col2 = 224
1281         bckgrdcolor = wx.Colour(col, col1, col2)
1282         self.SetBackgroundColour(bckgrdcolor)
1283         txtcolour = wx.Colour(250, 250, 250)
1284         linkcolor = wx.Colour(255, 0, 0)
1285         sizer1 = wx.BoxSizer(wx.VERTICAL)
1286         sizer2 = wx.BoxSizer(wx.VERTICAL)
1287         sizer4 = wx.BoxSizer(wx.HORIZONTAL)
1288         grid_sizer_1 = wx.FlexGridSizer(1, 4, 0, 0)
1289         grid_sizer_3 = wx.FlexGridSizer(1, 4, 0, 0)
1290         grid_sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
1291
1292         iralink = hl.HyperLinkCtrl(self, wx.ID_ANY, u"http://www.iramuteq.org", URL="http://www.iramuteq.org")
1293         iralink.SetColours(linkcolor, linkcolor, "RED")
1294         iralink.SetBackgroundColour(bckgrdcolor)
1295         iralink.EnableRollover(True)
1296         iralink.SetUnderlines(False, False, True)
1297         iralink.SetBold(True)
1298         iralink.UpdateLink()
1299
1300         PanelPres = wx.Panel(self)
1301         bckgrdcolor = wx.Colour(randint(0, 255), randint(0, 255), randint(0, 255))
1302         PanelPres.SetBackgroundColour(bckgrdcolor)
1303
1304         label_1 = wx.StaticText(self, -1, u"IRaMuTeQ", size=(-1, -1))
1305         label_1.SetFont(wx.Font(46, wx.TELETYPE, wx.NORMAL, wx.BOLD, 0, "Purisa"))
1306         label_1.SetForegroundColour(wx.RED)
1307
1308         iraicone = wx.Image(os.path.join(ImagePath,'iraicone100x100.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1309         but_ira = wx.StaticBitmap(self, -1, bitmap = iraicone)
1310
1311
1312         label2 = wx.StaticText(PanelPres, -1 , u'\nVersion ' + ConfigGlob.get('DEFAULT', 'version') + '\n')
1313         label2.SetForegroundColour(txtcolour)
1314         label2.SetBackgroundColour(bckgrdcolor)
1315         self.hyper2 = hl.HyperLinkCtrl(PanelPres, wx.ID_ANY, u"REPERE", URL="http://repere.no-ip.org/")
1316         self.hyper2.SetColours(linkcolor, linkcolor, "RED")
1317         self.hyper2.SetBackgroundColour(bckgrdcolor)
1318         self.hyper2.EnableRollover(True)
1319         self.hyper2.SetUnderlines(False, False, True)
1320         self.hyper2.SetBold(True)
1321         self.hyper2.UpdateLink()
1322
1323         label_lerass = wx.StaticText(PanelPres, -1, u'Laboratoire ')
1324         label_lerass.SetForegroundColour(txtcolour)
1325         label_lerass.SetBackgroundColour(bckgrdcolor)
1326
1327         self.hyper_lerass = hl.HyperLinkCtrl(PanelPres, -1, u'LERASS', URL="http://www.lerass.com")
1328         self.hyper_lerass.SetColours(linkcolor, linkcolor, "RED")
1329         self.hyper_lerass.SetBackgroundColour(bckgrdcolor)
1330         self.hyper_lerass.EnableRollover(True)
1331         self.hyper_lerass.SetUnderlines(False, False, True)
1332         self.hyper_lerass.SetBold(True)
1333         self.hyper_lerass.UpdateLink()
1334
1335         blank = wx.StaticText(PanelPres, -1, u'\n')
1336         blank1 = wx.StaticText(PanelPres, -1, u'\n')
1337
1338         labellicence = wx.StaticText(PanelPres, -1, _(u"License GNU GPL").decode('utf8'))
1339         labellicence.SetForegroundColour(txtcolour)
1340         labellicence.SetBackgroundColour(bckgrdcolor)
1341
1342         labelcopy = wx.StaticText(PanelPres, -1, ConfigGlob.get('DEFAULT', 'copyright'))
1343         labelcopy.SetForegroundColour(txtcolour)
1344         labelcopy.SetBackgroundColour(bckgrdcolor)
1345
1346         python_img = wx.Image(os.path.join(ImagePath,'python-logo.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1347         r_img = wx.Image(os.path.join(ImagePath,'Rlogo.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1348         lexique_img = wx.Image(os.path.join(ImagePath,'LexTexte4.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1349         but_python = wx.BitmapButton(self, -1, python_img)
1350         but_lexique = wx.BitmapButton(self, -1, lexique_img)
1351         but_r = wx.BitmapButton(self, -1, r_img)
1352         self.Bind(wx.EVT_BUTTON, self.OnPython, but_python)
1353         self.Bind(wx.EVT_BUTTON, self.OnLexique, but_lexique)
1354         self.Bind(wx.EVT_BUTTON, self.OnR, but_r)
1355
1356         grid_sizer_1.Add(self.hyper2, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1357         grid_sizer_3.Add(label_lerass, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1358         grid_sizer_3.Add(self.hyper_lerass, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1359         sizer4.Add(label_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5)
1360
1361         sizer2.Add(label2, 0, wx.ALIGN_CENTER, 5)
1362         sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 5)
1363         sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 5)
1364         sizer2.Add(grid_sizer_3, 0, wx.ALIGN_CENTER, 5)
1365         sizer2.Add(wx.StaticText(PanelPres, -1, u' '), 0, wx.ALIGN_CENTER, 5)
1366         sizer2.Add(grid_sizer_1, 0, wx.ALIGN_CENTER, 5)
1367         sizer2.Add(labellicence, 0, wx.ALIGN_CENTER, 5)
1368         sizer2.Add(labelcopy, 0, wx.ALIGN_CENTER, 5)
1369         sizer1.Add(sizer4, 2, wx.ALIGN_CENTER_HORIZONTAL, 0)
1370         sizer1.Add(but_ira, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5)
1371         sizer1.Add(iralink, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_TOP, 5)
1372         sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 10)
1373         PanelPres.SetSizer(sizer2)
1374         grid_sizer_2.Add(but_python, 1, wx.ALIGN_BOTTOM)
1375         grid_sizer_2.Add(but_lexique, 1, wx.ALIGN_BOTTOM)
1376         grid_sizer_2.Add(but_r, 1,  wx.ALIGN_BOTTOM)
1377
1378         sizer1.Add(PanelPres, 0, wx.EXPAND |wx.ALL, 10)
1379         sizer1.Add(grid_sizer_2, 2, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 1)
1380         self.SetSizer(sizer1)
1381         sizer1.Fit(self)
1382
1383     def OnPython(self,evt):
1384         webbrowser.open('http://www.python.org')
1385
1386     def OnLexique(self,evt):
1387         webbrowser.open('http://www.lexique.org')
1388
1389     def OnR(self,evt):
1390         webbrowser.open('http://www.r-project.org')
1391
1392 class MySplashScreen(wx.SplashScreen):
1393     def __init__(self):
1394         bmp = wx.Image(os.path.join(ImagePath, 'splash.png')).ConvertToBitmap()
1395         wx.SplashScreen.__init__(self, bmp,
1396                                  wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,
1397                                  1000, None, -1)
1398         self.Bind(wx.EVT_CLOSE, self.OnClose)
1399         self.fc = wx.FutureCall(1, self.ShowMain)
1400
1401     def OnClose(self, evt):
1402         evt.Skip()
1403         self.Hide()
1404
1405         if self.fc.IsRunning():
1406             self.fc.Stop()
1407             self.ShowMain()
1408
1409     def ShowMain(self):
1410         displaySize = wx.DisplaySize()
1411         w = displaySize[0]/1.2
1412         h = displaySize[1]/1.2
1413         frame = IraFrame(None, -1, "IRaMuTeQ " + ConfigGlob.get('DEFAULT', 'version'), size=(w, h))
1414         frame.Show()
1415         frame.finish_init()
1416         frame.Upgrade()
1417         frame.OnOpenFromCmdl()
1418 #        if self.fc.IsRunning():
1419 #            self.Raise()
1420         #wx.CallAfter(frame.ShowTip)
1421
1422 class MyApp(wx.App):
1423     def OnInit(self):
1424         """
1425         Create and show the splash screen.  It will then create and show
1426         the main frame when it is time to do so.
1427         """
1428         wx.SystemOptions.SetOptionInt("mac.window-plain-transition", 1)
1429         self.SetAppName("Iramuteq")
1430         splash = MySplashScreen()
1431         splash.Show()
1432         return True
1433
1434 def main():
1435     app = MyApp(False)
1436     app.MainLoop()
1437
1438 if __name__ == '__main__':
1439     __name__ = 'Main'
1440     main()