remove agw
[iramuteq] / iramuteq.py
1 #!/bin/env python
2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2008-2012, Pierre Ratinaud
5 #Lisense: GNU GPL
6
7 from optparse import OptionParser
8
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()
13
14 #print args
15 #print options
16 import sys
17 reload(sys)
18 import locale
19 import tempfile
20 import codecs
21 import os
22 import shutil
23 from random import randint
24 from ConfigParser import *
25 import webbrowser
26 import gettext
27 import logging
28 #------------------------------------
29 import wx
30 #import wx.aui
31 import wx.lib.agw.aui as aui
32 #import agw.aui as aui
33 import wx.html
34 import wx.grid
35 import wx.lib.hyperlink as hl
36 #------------------------------------
37 from functions import BugReport, PlaySound, ReadLexique, History, DoConf, ReadDicoAsDico, progressbar
38 from checkversion import NewVersion
39 from guifunct import *
40 from tableau import Tableau
41 from dialog import PrefDialog, EncodeDialog, CorpusPref
42 from tabfrequence import Frequences
43 from tabchi2 import ChiSquare
44 #from tabstudent import MakeStudent
45 from tabchddist import ChdCluster
46 from tabafcm import DoAFCM
47 from tabchdalc import AnalyseQuest
48 from tabsimi import DoSimi
49 from tabrsimple import InputText
50 from tabverges import Verges
51 #from textafcuci import AfcUci
52 #from textchdalc import AnalyseAlceste
53 from analysetxt import Alceste
54 from textdist import PamTxt
55 from textstat import Stat
56 from textaslexico import Lexico
57 from textsimi import SimiTxt, SimiFromCluster
58 from textwordcloud import WordCloud
59 from profile_segment import ProfileSegment
60 from textcheckcorpus import checkcorpus
61 from openanalyse import OpenAnalyse
62 from corpus import BuildFromAlceste, Builder
63 from sheet import MySheet
64 from checkinstall import CreateIraDirectory, CheckRPath, FindRPAthWin32, FindRPathNix, CheckRPackages, IsNew, UpgradeConf, CopyConf, RLibsAreInstalled
65 from chemins import ConstructRscriptsPath, ConstructConfigPath, ConstructDicoPath, ConstructGlobalPath, PathOut
66 from parse_factiva_xml import ImportFactiva
67 from tools import Extract
68
69 from tree import LeftTree
70 ##########################################################
71 ID_OpenData = wx.NewId()
72 ID_Import = wx.NewId()
73 ID_OpenText = wx.NewId()
74 ID_OnOpenAnalyse = wx.NewId()
75 ID_Freq = wx.NewId()
76 ID_Chi2 = wx.NewId()
77 ID_Student = wx.NewId()
78 ID_CHDSIM = wx.NewId()
79 ID_CHDAlceste = wx.NewId()
80 ID_TEXTAFCM = wx.NewId()
81 ID_TEXTSTAT = wx.NewId()
82 ID_ASLEX = wx.NewId()
83 ID_TEXTALCESTE = wx.NewId()
84 ID_TEXTPAM = wx.NewId()
85 ID_CHECKCORPUS = wx.NewId()
86 ID_Tabcontent = wx.NewId()
87 ID_AFCM = wx.NewId()
88 ID_SIMI = wx.NewId()
89 ID_CloseTab = wx.NewId()
90 ID_SaveTab = wx.NewId()
91 ID_CreateText = wx.NewId()
92 ID_ACCEUIL = wx.NewId()
93 ID_RESULT = wx.NewId()
94 ID_VIEWDATA = wx.NewId()
95 ID_HTMLcontent = wx.NewId()
96 ID_SimiTxt = wx.NewId()
97 ##########################################################
98 #elements de configuration
99 ##########################################################
100 #encodage
101 if sys.platform == 'darwin' :
102     sys.setdefaultencoding('utf-8')
103     wx.SetDefaultPyEncoding('utf-8')
104 else :
105     sys.setdefaultencoding(locale.getpreferredencoding())
106 #chemin de l'application
107 AppliPath = os.path.abspath(os.path.dirname(os.path.realpath(sys.argv[0])))
108 #chemin des images
109 ImagePath = os.path.join(AppliPath, 'images')
110 #configuration generale
111 DictConfigPath = ConstructGlobalPath(AppliPath)
112 ConfigGlob = ConfigParser()
113 ConfigGlob.read(DictConfigPath['global'])
114 #repertoire de l'utilisateur
115 if os.getenv('HOME') != None:
116     user_home = os.getenv('HOME')
117 else:
118     user_home = os.getenv('HOMEPATH')
119 UserConfigPath = os.path.abspath(os.path.join(user_home, '.iramuteq'))
120 #Si pas de fichiers de config utilisateur, on cree le repertoire
121 CreateIraDirectory(UserConfigPath, AppliPath)
122 #fichiers log pour windows (py2exe)
123 log = logging.getLogger('iramuteq')
124 fh = logging.FileHandler(os.path.join(UserConfigPath,'stdout.log'))
125 ch = logging.StreamHandler()
126 formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
127 ch.setFormatter(formatter)
128 fh.setFormatter(formatter)
129 log.addHandler(ch)
130 log.addHandler(fh)
131 log.setLevel(logging.INFO)
132
133
134 class writer(object):
135     def write(self, data):
136         if data.strip() != '' :
137             log.info('BUG : %s' % data)
138 sys.stderr = writer()
139 ConfigPath = ConstructConfigPath(UserConfigPath)
140 #####################################################################
141
142 class IraFrame(wx.Frame):
143     def __init__(self, parent, id= -1, title="", pos=wx.DefaultPosition,
144                  size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE | 
145                                             wx.SUNKEN_BORDER | 
146                                             wx.CLIP_CHILDREN):
147         log.info('Starting...')
148         wx.Frame.__init__(self, parent, id, title, pos, size, style)
149         #configuration
150         self.AppliPath = AppliPath
151         self.images_path = os.path.join(AppliPath,'images')
152         self.UserConfigPath = UserConfigPath
153         self.RscriptsPath = ConstructRscriptsPath(AppliPath)
154         #self.DictPath = ConstructDicoPath(AppliPath)
155         self.DictPath = ConstructDicoPath(UserConfigPath)
156         self.ConfigGlob = ConfigGlob
157         self.ConfigPath = ConstructConfigPath(UserConfigPath)
158         self.pref = RawConfigParser()
159         #workaround for import problem
160         self.SimiFromCluster = SimiFromCluster
161         #langues
162         mylocale = wx.Locale(wx.LANGUAGE_FRENCH)
163         mylocale.AddCatalogLookupPathPrefix(os.path.join(AppliPath,'locale'))
164         mylocale.AddCatalog('iramuteq')
165         presLan_en = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=['en'])
166         presLan_fr = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=['fr_FR'])
167         presLan_fr.install()
168
169
170         # tell FrameManager to manage this frame        
171         #self._mgr = wx.aui.AuiManager()
172         self._mgr = aui.AuiManager()
173         self._mgr.SetManagedWindow(self)
174         self.x = 0
175         # create menu
176 #--------------------------------------------------------------------------------
177         self.mb = wx.MenuBar()
178
179         file_menu = wx.Menu()
180         item = wx.MenuItem(file_menu, ID_OpenData, _(u"Open a matrix"), _(u"Open a matrix"))
181         item.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN))
182         file_menu.AppendItem(item)
183         
184         item = wx.MenuItem(file_menu, ID_OpenText, _(u"Open a text corpora"), _(u"Open a text corpora"))
185         item.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN))
186         file_menu.AppendItem(item)
187         
188         item = wx.MenuItem(file_menu, ID_OnOpenAnalyse, _(u"Open an analysis"), _("Open an analysis"))
189         item.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN))
190         file_menu.AppendItem(item)
191
192         
193         menuFactiva = wx.Menu()
194         fact_from_xml = wx.MenuItem(menuFactiva, wx.ID_ANY, _(u"from xml"))
195         fact_from_mail = wx.MenuItem(menuFactiva, wx.ID_ANY, _(u"from mail"))
196         fact_from_txt = wx.MenuItem(menuFactiva, wx.ID_ANY, _(u"from copy/paste"))
197         menuFactiva.AppendItem(fact_from_xml)
198         menuFactiva.AppendItem(fact_from_mail)
199         menuFactiva.AppendItem(fact_from_txt)
200         file_menu.AppendMenu(-1, _(u"Import from factiva"), menuFactiva)
201
202         menuTools = wx.Menu()
203         splitvar = wx.MenuItem(menuTools, wx.ID_ANY, _(u"Split from variable"))
204         extractmod = wx.MenuItem(menuTools, wx.ID_ANY, _(u"Extract mods"))
205         menuTools.AppendItem(splitvar)
206         menuTools.AppendItem(extractmod)
207         self.ID_splitvar = splitvar.GetId()
208         self.ID_extractmod = extractmod.GetId()
209         file_menu.AppendMenu(-1, _(u"Tools"), menuTools)
210
211                
212         item = wx.MenuItem(file_menu, ID_SaveTab, _(u"Save tab as..."), _(u"Save tab as..."))
213         item.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FILE_SAVE_AS))
214         file_menu.AppendItem(item)
215         
216         file_menu.Append(wx.ID_EXIT, _(u"Exit"))
217         
218         edit_menu = wx.Menu()
219         edit_menu.Append(wx.ID_PREFERENCES, '', _(u'Preferences'))
220         
221         view_menu = wx.Menu()
222         view_menu.Append(ID_ACCEUIL, _(u"Home page"))
223         view_menu.Append(ID_VIEWDATA, _(u"Show data"))
224         view_menu.Append(ID_RESULT, _(u'Show results'))
225         #view_menu.AppendSeparator()
226
227         analyse_menu = wx.Menu()
228         analyse_menu.Append(ID_Freq, u"Fréquences")
229         analyse_menu.Append(ID_Chi2, u"Chi2")
230         #analyse_menu.Append(ID_Student, u"t de Student")
231         menu_classif = wx.Menu()
232         menu_classif.Append(ID_CHDAlceste, u"Méthode Alceste")
233         menu_classif.Append(ID_CHDSIM, u"Par matrice des distances")
234         analyse_menu.AppendMenu(-1, u"Classification", menu_classif)
235         analyse_menu.Append(ID_AFCM, u"AFCM")
236         analyse_menu.Append(ID_SIMI, u"Analyse de similitudes")
237         ID_RCODE = wx.NewId()
238         analyse_menu.Append(ID_RCODE, u"Code R...")
239
240         text_menu = wx.Menu()
241         text_menu.Append(ID_CHECKCORPUS, u"Vérifier le corpus")
242         text_menu.Append(ID_TEXTSTAT, u"Statistiques textuelles")
243         text_menu.Append(ID_ASLEX, u"Spécificités et AFC")
244         #text_menu.Append(ID_TEXTAFCM, u"AFC sur UCI / Vocabulaire")
245         menu_classiftxt = wx.Menu()
246         menu_classiftxt.Append(ID_TEXTALCESTE, u"Méthode Alceste")
247         menu_classiftxt.Append(ID_TEXTPAM, u"Par matrice des distances")
248         text_menu.AppendMenu(-1, u"Classification", menu_classiftxt)
249         text_menu.Append(ID_SimiTxt, u'Analyse de similitude') 
250         ID_WC = wx.NewId()
251         text_menu.Append(ID_WC, u'Nuage de mots')
252         
253         help_menu = wx.Menu()
254         help_menu.Append(wx.ID_ABOUT, u'À propos...')
255         help_menu.Append(wx.ID_HELP, u'Aide en ligne')
256         
257         self.mb.Append(file_menu, _(u"File"))
258         self.mb.Append(edit_menu, _(u"Edition"))
259         self.mb.Append(view_menu, _(u"View"))
260         self.mb.Append(analyse_menu, _("Spreadsheet analysis"))
261         self.mb.Append(text_menu, _(u"Text analysis"))
262         self.mb.Append(help_menu, _(u"Help"))
263         
264         self.SetMenuBar(self.mb)
265 #--------------------------------------------------------------------
266         self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP)
267         self.statusbar.SetStatusWidths([-2, -3])
268         self.statusbar.SetStatusText(u"Prêt", 0)
269         self.statusbar.SetStatusText(u"Bienvenue", 1)
270
271         # min size for the frame itself isn't completely done.
272         # see the end up FrameManager::Update() for the test
273         # code. For now, just hard code a frame minimum size
274         self.SetMinSize(wx.Size(400, 400))
275
276         # create some toolbars
277         tb1 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
278                          wx.TB_FLAT | wx.TB_NODIVIDER)
279         tb1.SetToolBitmapSize(wx.Size(16, 16))
280         tb1.AddLabelTool(ID_OpenData, "OpenData", wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, wx.Size(16, 16)), shortHelp="Questionnaire", longHelp="Ouvrir un questionnaire")
281         tb1.AddSeparator()
282         tb1.AddLabelTool(ID_OpenText, "OpenText", wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, wx.Size(16, 16)), shortHelp="Texte", longHelp="Ouvrir un corpus texte")
283
284         tb1.Realize()
285         
286 #------------------------------------------------------------------------------------------------
287
288         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)
289                       
290         #self._mgr.AddPane(self.text_ctrl_txt, wx.aui.AuiPaneInfo().
291         #                  Name("Text").CenterPane())                      
292         self._mgr.AddPane(self.text_ctrl_txt, aui.AuiPaneInfo().
293                           Name("Text").CenterPane())
294         #self._mgr.AddPane(IntroPanel(self), wx.aui.AuiPaneInfo().Name("Intro_Text").
295         #                  CenterPane())
296         self._mgr.AddPane(IntroPanel(self), aui.AuiPaneInfo().Name("Intro_Text").
297                           CenterPane())
298         #if not os.path.exists(os.path.join(UserConfigPath, 'history.db')) :
299         #    with open(os.path.join(UserConfigPath, 'history.db'), 'w') as f :
300         #        f.write('')
301         self.history = History(os.path.join(UserConfigPath, 'history.db'))
302         self.tree = LeftTree(self)
303         self._mgr.AddPane(self.tree, aui.AuiPaneInfo().Name("lefttree").Caption("Navigateur").
304                           Left().MinSize(wx.Size(200,500)).Layer(1).Position(1).CloseButton(False).MaximizeButton(True).
305                           MinimizeButton(True))
306         
307         #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)
308         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)
309         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
310         self.nb.SetAGWWindowStyleFlag(notebook_flags)
311         self.nb.SetArtProvider(aui.ChromeTabArt())
312         #self.nb.SetArtProvider(aui.VC8TabArt())
313         #self.nb.parent = self
314         #self._notebook_style = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | wx.NO_BORDER
315         #self._mgr.AddPane(self.nb, wx.aui.AuiPaneInfo().
316         #                      Name("Tab_content").
317         #                      CenterPane())
318         self._mgr.AddPane(self.nb, aui.AuiPaneInfo().
319                               Name("Tab_content").
320                               CenterPane())        
321         self.Sheet = MySheet(self)
322         #self._mgr.AddPane(self.Sheet, wx.aui.AuiPaneInfo().Name("Data").CenterPane())
323         self._mgr.AddPane(self.Sheet, aui.AuiPaneInfo().Name("Data").CenterPane())
324         self.nb.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnCloseTab)
325         self.nb.Bind(aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
326         # add the toolbars to the manager
327                         
328         #self._mgr.AddPane(tb1, wx.aui.AuiPaneInfo().
329         #                  Name("tb1").Caption("Fichiers").
330         #                  ToolbarPane().Top().
331         #                  LeftDockable(False).RightDockable(False))
332         self._mgr.AddPane(tb1, aui.AuiPaneInfo().
333                           Name("tb1").Caption("Fichiers").
334                           ToolbarPane().Top().
335                           LeftDockable(True).RightDockable(False))        
336         
337         self.ShowAPane("Intro_Text")
338         self._mgr.GetPane("lefttree").Show()
339         self._mgr.GetPane("classif_tb").Hide()
340         # "commit" all changes made to FrameManager   
341         self._mgr.Update()
342
343         # Show How To Use The Closing Panes Event
344 ##################################################################        
345         self.Bind(wx.EVT_MENU, self.OnAcceuil, id=ID_ACCEUIL)
346         self.Bind(wx.EVT_MENU, self.OnViewData, id=ID_VIEWDATA)
347         self.Bind(wx.EVT_MENU, self.ShowTab, id=ID_RESULT)
348         self.Bind(wx.EVT_MENU, self.OnOpenData, id=ID_OpenData)
349         self.Bind(wx.EVT_MENU, self.OnOpenText, id=ID_OpenText)
350         self.Bind(wx.EVT_MENU, self.OnOpenAnalyse, id=ID_OnOpenAnalyse)
351         self.Bind(wx.EVT_MENU, self.import_factiva_xml, fact_from_xml)
352         self.Bind(wx.EVT_MENU, self.import_factiva_mail, fact_from_mail)
353         self.Bind(wx.EVT_MENU, self.import_factiva_txt, fact_from_txt)
354         self.Bind(wx.EVT_MENU, self.ExtractTools, splitvar)
355         self.Bind(wx.EVT_MENU, self.ExtractTools, extractmod)
356         self.Bind(wx.EVT_MENU, self.OnFreq, id=ID_Freq)
357         self.Bind(wx.EVT_MENU, self.OnChi2, id=ID_Chi2)
358         self.Bind(wx.EVT_MENU, self.OnStudent, id=ID_Student)
359         self.Bind(wx.EVT_MENU, self.OnCHDSIM, id=ID_CHDSIM)
360         self.Bind(wx.EVT_MENU, self.OnCHDAlceste, id=ID_CHDAlceste)
361         self.Bind(wx.EVT_MENU, self.OnAFCM, id=ID_AFCM)
362         self.Bind(wx.EVT_MENU, self.OnRCode, id=ID_RCODE)
363         self.Bind(wx.EVT_MENU, self.OnCheckcorpus, id = ID_CHECKCORPUS)
364         self.Bind(wx.EVT_MENU, self.OnTextStat, id=ID_TEXTSTAT)
365         self.Bind(wx.EVT_MENU, self.OnTextSpec, id=ID_ASLEX)
366         self.Bind(wx.EVT_MENU, self.OnTextAfcm, id=ID_TEXTAFCM)
367         self.Bind(wx.EVT_MENU, self.OnTextAlceste, id=ID_TEXTALCESTE)
368         self.Bind(wx.EVT_MENU, self.OnPamSimple, id=ID_TEXTPAM)
369         self.Bind(wx.EVT_MENU, self.OnSimiTxt, id=ID_SimiTxt)
370         self.Bind(wx.EVT_MENU, self.OnWordCloud, id=ID_WC)
371         self.Bind(wx.EVT_MENU, self.OnSimi, id=ID_SIMI)
372         self.Bind(wx.EVT_MENU, self.OnExit, id=wx.ID_EXIT)
373         self.Bind(wx.EVT_MENU, self.OnSaveTabAs, id=ID_SaveTab)
374         self.Bind(wx.EVT_MENU, self.OnAbout, id=wx.ID_ABOUT)
375         self.Bind(wx.EVT_MENU, self.OnHelp, id=wx.ID_HELP)
376         self.Bind(wx.EVT_MENU, self.OnPref, id=wx.ID_PREFERENCES)
377         self.Bind(wx.EVT_CLOSE, self.OnClose)
378 ##################################################################
379         flags = self._mgr.GetAGWFlags()
380         #flags &= ~wx.aui.AUI_MGR_TRANSPARENT_HINT
381         #flags &= ~wx.aui.AUI_MGR_VENETIAN_BLINDS_HINT
382         #flags &= ~wx.aui.AUI_MGR_RECTANGLE_HINT
383         flags &= ~(aui.AUI_MGR_RECTANGLE_HINT | aui.AUI_MGR_ALLOW_FLOATING)
384         self._mgr.SetAGWFlags(self._mgr.GetAGWFlags() ^ (aui.AUI_MGR_RECTANGLE_HINT | aui.AUI_MGR_ALLOW_FLOATING))
385         self._mgr.GetArtProvider().SetMetric(aui.AUI_DOCKART_GRADIENT_TYPE, aui.AUI_GRADIENT_HORIZONTAL)
386         self.GetDockArt().SetColor(aui.AUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR, "#00FFF9")
387         self.DoUpdate()
388
389         self._icon = wx.Icon(os.path.join(ImagePath, "iraicone.ico"), wx.BITMAP_TYPE_ICO)
390         self.SetIcon(self._icon)
391 ##########################
392         self.ctrl = ""
393         self.input_path = [False]
394         self.TEMPDIR = tempfile.mkdtemp('iramuteq')
395         self.FileTabList = []
396         self.listbar=[]
397         self.DictTab = {}
398         self.FreqNum = 0
399         self.colsep = ''
400         self.txtsep = ''
401         self.g_header = False
402         self.g_id = False
403         self.table = ''
404         self.fileforR = ''
405         self.filename = ''
406         self.nastrings = ''
407         self.encode = ''
408         self.SysEncoding = sys.getdefaultencoding()
409         self.syscoding = sys.getdefaultencoding()
410         #print 'SysEncoding',self.SysEncoding
411         if self.SysEncoding == 'mac-roman' : self.SysEncoding = 'MacRoman'
412         self.type = ''
413
414         try :
415             self.pref.read(self.ConfigPath['preferences'])
416             if IsNew(self) :
417                 UpgradeConf(self)
418                 New = True
419             else :
420                 CopyConf(self)
421                 New = False
422         except :
423             UpgradeConf(self)
424             self.pref.read(self.ConfigPath['preferences'])
425             New = True
426         #configuration des chemins de R
427         self.PathPath = ConfigParser()
428         self.PathPath.read(ConfigPath['path'])
429         BestRPath = False
430         if not CheckRPath(self.PathPath) :
431             if sys.platform == 'win32':
432                 BestRPath = FindRPAthWin32()
433             else:
434                 BestRPath = FindRPathNix()
435             if BestRPath:
436                 self.PathPath.set('PATHS', 'rpath', BestRPath)
437                 with open(ConfigPath['path'], 'w') as f :
438                     self.PathPath.write(f)
439         else:
440             BestRPath = True 
441         if BestRPath :
442             self.RPath = self.PathPath.get('PATHS', 'rpath')
443             if New :
444                 CheckRPackages(self)
445             if not RLibsAreInstalled(self) :
446                 CheckRPackages(self)
447         else :
448             msg = u"""
449 Le chemin de l'executable de R n'a pas été trouvé.
450 Si R n'est pas installé, vous devez l'installer (http://www.r-project.org/).
451 Si R n'est pas installé dans le répertoire par défaut
452 (souvent C:\Program Files\R\R-2.x.x\R.exe sous windows ou /usr/bin/R sous linux ou Mac Os X)
453 vous devez signaler le chemin de l'éxecutable de R dans les préférences.""" 
454             dlg = wx.MessageDialog(self, msg, u"Problème de configuration", wx.OK | wx.NO_DEFAULT | wx.ICON_WARNING)
455             dlg.CenterOnParent()
456             if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
457                  evt.Veto()
458             dlg.Destroy()
459         self.DataPop = False
460         self.DataTxt = False
461         self.Text = ''
462         self.sound = self.pref.getboolean('iramuteq', 'sound')
463         self.check_update = self.pref.getboolean('iramuteq', 'checkupdate')
464         self.version = ConfigGlob.get('DEFAULT', 'version')
465         self.lexique = None
466         self.corpus = None
467 ##############################################################@
468         self.DisEnSaveTabAs(False)
469         self.ShowMenu(_("View"), False)
470         self.ShowMenu(_("Spreadsheet analysis"), False)
471         self.ShowMenu(_("Text analysis"), False)
472    
473         self._mgr.Update()
474
475     def OnVerif(self, evt) :
476         pack = CheckRPackages(self)
477         if pack :
478             dlg = wx.MessageDialog(self, u"Installation OK", u"Installation", wx.OK | wx.NO_DEFAULT | wx.ICON_INFORMATION)
479             dlg.CenterOnParent()
480             if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
481                  evt.Veto()
482
483     #FIXME  marche pas sous mac ?
484     def DisEnSaveTabAs(self, DISEN):
485     #Disable SaveTabAs
486         file_menu = self.mb.GetMenu(0)
487         items = file_menu.GetMenuItems()
488         for item in items :
489             if item.GetId() == ID_SaveTab :
490                 item.Enable(DISEN)
491     
492     def ShowMenu(self, menu, Show=True):
493         menu_pos = self.mb.FindMenu(menu)
494         self.mb.EnableTop(menu_pos, Show)
495         self.mb.UpdateMenus()
496
497
498 #--------------------------------------------------------------------
499     def OnClose(self, event):
500         print 'onclose'
501         with open(self.ConfigPath['path'], 'w') as f :
502             self.PathPath.write(f)
503         if self.DictTab != {} :
504             savestates = [self.DictTab[item][0] for item in self.DictTab]
505             if False in savestates :
506                 notsave = [item for item in self.DictTab if self.DictTab[item][0] == False] 
507                 msg = u"""
508  Certains résultats ne sont pas enregistrés.
509  Voulez-vous fermer quand même ?"""
510                 dlg = wx.MessageDialog(self, msg, "Sauvegarde",
511                        wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
512                 dlg.CenterOnParent()
513                 if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
514                     event.Veto()
515                     dlg.Destroy()
516                 else:
517                     dlg.Destroy()
518                     for item in notsave :
519                         for tmpfile in self.DictTab[item][1:] :
520                             os.remove(tmpfile)
521                             print 'remove : ' + tmpfile
522                     self._mgr.UnInit()
523                     del self._mgr
524                     self.Destroy()
525             else :
526                 self._mgr.UnInit()
527                 del self._mgr
528                 self.Destroy()
529         else :
530             self._mgr.UnInit()
531             del self._mgr
532             self.Destroy()
533             #if sys.platform == 'win32' :
534             #    os.system("taskkill /im iramuteq.exe /f")
535             #    print 'meurtre de process'
536
537     def OnOpenData(self, event):
538         inputname, self.input_path = OnOpen(self, "Data")
539         if inputname:
540             self.filename = self.input_path[0]
541             self.tableau = Tableau(self,os.path.abspath(self.input_path[0]))
542             get_table_param(self, self.input_path[0])
543             self.tableau.make_content()
544             self.tableau.show_tab()
545
546     def OnOpenAnalyse(self, event):
547         self.AnalysePath = OnOpen(self, "Analyse")
548         OpenAnalyse(self, self.AnalysePath[1][0], True)
549         self.ShowMenu(_("View"))
550
551     def OnOpenText(self, event):
552         inputname, self.input_path = OnOpen(self, "Texte")
553         self.filename = self.input_path[0]
554         if inputname:
555              self.OpenText()
556    
557     def OnViewData(self, event):
558         print self.type
559         print self.DataTxt
560         if self.type == "Data":
561             if not self.DataPop :
562                 self.Sheet.Populate(self.content)
563                 self.DataPop = True
564                 self.DataTxt = False
565             self.ShowAPane(u"Data")
566         elif self.type == "Texte" or self.type == 'Analyse' :
567             if not self.DataTxt :
568                 self.text_ctrl_txt.Clear()
569                 self.text_ctrl_txt.write(self.content)
570                 self.text_ctrl_txt.ShowPosition(0)
571                 self.DataTxt = True
572                 self.DataPop = False
573             self.ShowAPane(u"Text")
574         self._mgr.Update()
575         
576     def OpenText(self):
577         #dial = EncodeDialog(self)
578         dlg = wx.ProgressDialog("Ouverture...",
579                                    "Veuillez patienter...",
580                                    maximum=2,
581                                    parent=self,
582                                    style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME | wx.PD_CAN_ABORT
583                                    )
584         
585         builder =  Builder(self, dlg)
586         if builder.res == wx.ID_OK :
587             try :
588                 corpus = builder.doanalyse()
589                 self.history.add(corpus.parametres)
590                 self.tree.OnItemAppend(corpus.parametres)
591                 OpenAnalyse(self, corpus.parametres)
592             except :
593                 BugReport(self)
594         #self.content = DoConf().totext(corpus.parametres)
595 #        parametres = DoConf(os.path.join(UserConfigPath,'corpus.cfg')).getoptions('corpus')
596 #        parametres['originalpath'] = self.filename
597 #        
598 #        parametres['pathout'] = PathOut(self.filename, 'corpus').dirout
599 #        dial = CorpusPref(self, parametres)
600 #        dial.CenterOnParent()
601 #        dial.txtpath.SetLabel(self.filename)
602 #        res = dial.ShowModal()
603 #        parametres = dial.doparametres()
604 #        print parametres
605 #        ReadLexique(self, lang = parametres['lang'])
606 #        self.expressions = ReadDicoAsDico(self.DictPath.get(parametres['lang'], 'french_exp'))
607 #        corpus = BuildFromAlceste(self.filename, parametres, self.lexique, self.expressions).corpus
608         #self.corpus_encodage =  dial.encodages[dial.list_encodages.GetSelection()][0]
609         #self.corpus_lang = dial.langues[dial.choice_dict.GetSelection()]
610             else :
611                 count = 1
612                 keepGoing = dlg.Update(count, u"Lecture du fichier")
613     #            msg = u"Ce fichier ne semble pas être encodé en %s" % self.corpus_encodage
614     #            dial = wx.MessageDialog(self, msg, u"Problème d'encodage", wx.OK | wx.NO_DEFAULT | wx.ICON_WARNING)
615     #            dial.CenterOnParent()
616     #            res = dial.ShowModal()
617     #            dial.Destroy()
618     #            self.OpenText()
619                 self.ShowMenu(_("View"))
620                 self.ShowMenu(_("Text analysis"))
621                 self.ShowMenu(_(u"Spreadsheet analysis"), False)
622                 self.type = "Texte"
623                 self.DataTxt = False
624                 self.Text = ''
625                 count += 1
626                 keepGoing = dlg.Update(count, u"Chargement du dictionnaire")
627                 dlg.Destroy()
628         #self.OnViewData(wx.EVT_BUTTON)
629         
630     def OnExit(self, event):
631         self.Close()
632
633     def OnAbout(self, event):
634         info = wx.AboutDialogInfo()
635         info.Name = ConfigGlob.get('DEFAULT', 'name')
636         info.Version = ConfigGlob.get('DEFAULT', 'version')
637         info.Copyright = ConfigGlob.get('DEFAULT', 'copyright')
638         info.Description = u"""
639 Interface de R pour les Analyses Multidimensionnelles 
640 de Textes et de Questionnaires
641
642 Un logiciel libre
643 construit avec des logiciels libres.
644
645 Laboratoire LERASS
646
647 REPERE
648 """
649         info.WebSite = ("http://www.iramuteq.org", u"Site web IRaMuTeQ")
650         dev = ConfigGlob.get('DEFAULT', 'dev').split(';')
651         info.Developers = dev
652         info.License = u"""Iramuteq est un logiciel libre ; vous pouvez le diffuser et/ou le modifier 
653 suivant les termes de la Licence Publique Générale GNU telle que publiée 
654 par la Free Software Foundation ; soit la version 2 de cette licence, 
655 soit (à votre convenance) une version ultérieure.
656
657 Iramuteq est diffusé dans l'espoir qu'il sera utile, 
658 mais SANS AUCUNE GARANTIE ; sans même une garantie implicite 
659 de COMMERCIALISATION ou d'ADÉQUATION À UN USAGE PARTICULIER. 
660 Voyez la Licence Publique Générale GNU pour plus de détails.
661
662 Vous devriez avoir reçu une copie de la Licence Publique Générale GNU
663 avec Iramuteq ; sinon, veuillez écrire à la Free Software Foundation,
664 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis."""
665         wx.AboutBox(info)
666
667     def GetDockArt(self):
668         return self._mgr.GetArtProvider()
669
670     def DoUpdate(self):
671         self._mgr.Update()
672
673     def OnPageChanged(self, event) :
674         new = event.GetSelection()
675         nobject = event.GetEventObject()
676         parent = nobject.GetParent()
677         if isinstance(parent, IraFrame) :
678             npage = self.nb.GetPage(new)
679             self.tree.GiveFocus(uuid=npage.parametres['uuid'])
680
681     def OnCloseTab(self, evt):
682         #log.info('Closing tab %s' % str(evt.GetEventObject()))
683         ctrl = evt.GetEventObject()
684         if isinstance(ctrl.GetParent(), aui.AuiNotebook) or isinstance(ctrl.GetParent(), wx.Panel):
685             notebook = True
686         else :
687             notebook = False
688         page = self.nb.GetPage(self.nb.GetSelection())
689         if 'parametres' in dir(page) and isinstance(ctrl.GetParent(), IraFrame) :
690             self.history.rmtab(page.parametres)
691             self.tree.CloseItem(uuid = page.parametres['uuid'])
692         TabTitle = self.nb.GetPageText(self.nb.GetSelection())
693         if self.DictTab != {} :
694             if TabTitle in self.DictTab :
695                 ListFile=self.DictTab[TabTitle]
696                 if False in ListFile:
697                     msg = u"""
698 Certains résultats ne sont pas enregistrer.
699 Voulez-vous fermer quand même ?"""
700                     dlg = wx.MessageDialog(self, msg, "Sauvegarde",wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
701
702                     dlg.CenterOnParent()
703                     if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
704                         remove = False
705                         evt.Veto()
706                         dlg.Destroy()
707                     else :
708                         for f in ListFile[1:] :
709                             print 'remove', f
710                             os.remove(f)
711                             remove = True
712                         dlg.Destroy()
713                 elif True in ListFile :
714                     remove = True
715                 if remove:
716                    del self.DictTab[TabTitle]
717             else : 
718                 self.LastTabClose()
719         else :
720             remove = True
721         if self.nb.GetPageCount() == 1 and remove and not notebook :
722             self.LastTabClose()
723     
724     def LastTabClose(self) :
725         if self.nb.GetPageCount() == 1 :
726             self.DisEnSaveTabAs(False)
727             if self.DataTxt :
728                 self.ShowAPane("Text")
729             elif self.DataPop :
730                 self.ShowAPane("Data")
731             else :
732                 self.ShowAPane("Intro_Text")
733
734     def OnSaveTabAs(self, event):
735         SelectTab = self.nb.GetSelection()
736         TabTitle = self.nb.GetPageText(SelectTab)
737         FileToSave = self.DictTab[TabTitle]
738         NewListFile = []
739         dlg = wx.FileDialog(
740             self, message="Enregistrer sous...", defaultDir=os.getcwd(),
741             defaultFile="resultat.html", wildcard="Tous les fichiers|*", style=wx.SAVE | wx.OVERWRITE_PROMPT
742             )
743         dlg.SetFilterIndex(2)
744         dlg.CenterOnParent()
745         
746         if dlg.ShowModal() == wx.ID_OK:
747             Path = dlg.GetPath()
748             Dirname = os.path.dirname(Path)
749             Filename = dlg.GetFilename()
750         else :
751             Path = False
752         dlg.Destroy()
753         if Path:
754             shutil.copyfile(FileToSave[-1], Path)
755             os.remove(FileToSave[len(FileToSave) - 1])
756             NewListFile.append(True)
757             NewListFile.append(Path)
758             for f in FileToSave[1:-1] :
759                 Fileout = os.path.join(Dirname, os.path.basename(f))
760                 shutil.copyfile(f, Fileout)
761                 NewListFile.append(Fileout)
762                 os.remove(f)
763             TabText = Filename
764             self.DictTab[TabText] = NewListFile
765             del self.DictTab[TabTitle]
766             self.nb.SetPageText(SelectTab, TabText)
767
768     def GetStartPosition(self):
769
770         self.x = self.x + 20
771         x = self.x
772         pt = self.ClientToScreen(wx.Point(0, 0))
773         
774         return wx.Point(pt.x + x, pt.y + x)
775     
776     def ShowAPane(self, panel):
777         for pane in self._mgr.GetAllPanes() :
778             if not pane.IsToolbar() and pane.name != 'lefttree': 
779                 pane.Hide()
780         self._mgr.GetPane(panel).Show()
781         self._mgr.Update()
782         
783     def OnAcceuil(self, event):
784         self.ShowAPane(u"Intro_Text")
785         event.Skip()
786     
787     def CreateHTMLCtrl(self):
788         ctrl = wx.html.HtmlWindow(self, -1, wx.DefaultPosition, wx.Size(400, 300))
789         if "gtk2" in wx.PlatformInfo:
790             ctrl.SetStandardFonts()
791         ctrl.SetPage(u"text")        
792         return ctrl
793
794     def ShowTab(self, evt):
795         self.ShowAPane("Tab_content")
796
797 ################################################################
798 #debut des analyses
799 ################################################################
800
801     def OnFreq(self, event):
802         try:
803             Frequences(self) 
804         except:
805             BugReport(self)
806             
807     def OnChi2(self, event):
808         try:
809         #    print('PAS DE DEBUG SUR CHI2')
810             chi = ChiSquare(self)
811         except:
812             BugReport(self)
813     
814     def OnStudent(self, event):
815         try:
816             MakeStudent(self) 
817         except:
818             BugReport(self)
819
820     def OnRCode(self, event):
821         try:
822             InputText(self)
823         except:
824             BugReport(self)
825
826     def OnCHDSIM(self, event):
827         try:
828         #    print 'ATTENTION!!!!'
829             chdsim = ChdCluster(self)
830             if chdsim.val == wx.ID_OK:
831                 PlaySound(self)
832         except:
833             BugReport(self)
834  
835     def OnCHDAlceste(self, event):
836         try:
837          #   print('PLUS DE BUG SUR ALCESTE QUESTIONNAIRE')
838             self.quest = AnalyseQuest(self)
839             if self.quest.val == wx.ID_OK:
840                 PlaySound(self)
841         except:
842             BugReport(self)
843
844     def OnSimiTxt(self, evt, corpus = None) :
845         #    print 'PLUS DE BUG SUR SIMITXT'
846         try :
847             #self.Text = SimiTxt(self)
848             if corpus is None :
849                 corpus = self.tree.getcorpus()            
850             self.Text = SimiTxt(self, corpus, parametres = {'type': 'simitxt'}, dlg = progressbar(self, 3))
851             if self.Text.val == wx.ID_OK :
852                 PlaySound(self)
853         except :
854             BugReport(self)
855     
856     def OnWordCloud(self, evt, corpus = None) :
857         #    print 'PLUS DE BUG SUR WORDCLOUD'
858         try :
859             if corpus is None :
860                 corpus = self.tree.getcorpus()            
861             self.Text = WordCloud(self, corpus, parametres = {'type' : 'wordcloud'}, dlg = progressbar(self, 3))
862             if self.Text.val == wx.ID_OK :
863                 PlaySound(self)
864         except :
865             BugReport(self)
866
867
868     def OnAFCM(self, event):
869         try:
870             DoAFCM(self)
871         except:
872             BugReport(self)
873
874     def OnCheckcorpus(self, evt):
875         try :
876             checkcorpus(self)
877         except :
878             BugReport(self)
879
880     def OnTextStat(self, event, corpus = None):
881             print 'PAS DE BUG SUR TEXT STAT'
882         #try:
883             if corpus is None :
884                 corpus = self.tree.getcorpus()
885             self.Text = Stat(self, corpus, parametres = {'type': 'stat'}, dlg = progressbar(self, 7))
886             
887             if self.Text.val == wx.ID_OK :
888                 PlaySound(self)
889         #except:
890         #    BugReport(self)
891         
892     def OnTextSpec(self, event, corpus = None):  
893         #try:
894             #self.Text = AsLexico(self)
895             print('ATTENTION : PLUS DE BUG SUR LEXICO')
896             if corpus is None :
897                 corpus = self.tree.getcorpus()
898             self.Text = Lexico(self, corpus, parametres = {'type' : 'spec'}, dlg = progressbar(self, 3))
899             if self.Text.val == wx.ID_OK :
900                 PlaySound(self)
901         #except:
902         #    BugReport(self)
903     
904     def OnTextAfcm(self, event):
905         try:
906             AfcUci(self)
907             PlaySound(self)
908         except:
909             BugReport(self)
910
911     def import_factiva_xml(self,event):
912         try :
913             ImportFactiva(self, 'xml')
914         except :
915             BugReport(self)
916
917     def import_factiva_mail(self, evt) :
918         try :
919             ImportFactiva(self, 'mail')
920         except :
921             BugReport(self)
922
923     def import_factiva_txt(self, evt) :
924         try :
925             ImportFactiva(self, 'txt')
926         except :
927             BugReport(self)
928
929     def ExtractTools(self, evt) :
930         ID = evt.GetId()
931         if ID == self.ID_splitvar :
932             Extract(self, 'splitvar')
933         else :
934             Extract(self, 'mods')
935
936     def OnTextAlceste(self, event, corpus = None):
937         try:
938             #print('ATTENTION : PLUS DE BUG SUR ALCESTE')
939             #RunAnalyse(self, corpus, Alceste, OptAlceste)
940             if corpus is None :
941                 corpus = self.tree.getcorpus()            
942             self.Text = Alceste(self, corpus, parametres = {'type': 'alceste'}, dlg = progressbar(self,6))
943             if self.Text.val == wx.ID_OK:
944                 PlaySound(self)
945         except:
946             BugReport(self)
947
948     def OnPamSimple(self, event):
949         try:
950             self.Text = PamTxt(self)
951             if self.Text.val == wx.ID_OK:
952                 PlaySound(self)
953         except:
954             BugReport(self)
955     
956     def OnSimi(self,evt):
957         try :
958             #print 'ATTENTION !!!! VERGES'
959             self.res = DoSimi(self, param = None)
960             #self.res = Verges(self)
961             if self.res.val == wx.ID_OK :
962                  PlaySound(self)
963         except :
964             BugReport(self)
965 #################################################################
966
967     def OnHelp(self, event):
968         webbrowser.open('http://www.iramuteq.org/documentation')
969     
970     def OnPref(self, event):
971         dlg = PrefDialog(self)
972         dlg.CenterOnParent()
973         self.val = dlg.ShowModal()
974
975     def Upgrade(self) :
976         if self.check_update:
977             NewVersion(self)
978         else:
979             print 'pas de verif'    
980         #IsNew(self)
981         #CheckRPackages(self)
982
983     def OnOpenFromCmdl(self):
984         truepath = True
985         if options.filename :
986             if os.path.exists(options.filename):
987                 self.filename = os.path.abspath(options.filename)
988             else:
989                 truepath = False
990         elif args :
991             if os.path.exists(os.path.realpath(args[0])):
992                 self.filename = os.path.abspath(os.path.realpath(args[0]))
993             else:
994                 truepath = False
995         else:
996             pass
997         if truepath :
998             if os.path.splitext(self.filename)[1] in ['.csv', '.xls', '.ods']:
999                 self.tableau = Tableau(self, self.filename)
1000                 get_table_param(self, self.filename)
1001                 self.tableau.make_content()
1002                 self.tableau.show_tab()
1003                 #open_data(self, self.filename)
1004             elif os.path.splitext(self.filename)[1] == '.txt':
1005                 self.OpenText()
1006             elif os.path.splitext(self.filename)[1] == '.ira' :
1007                 #self.corpus = Corpus(self)
1008                 #self.Text = OpenAnalyse(self, self.filename)
1009                 OpenAnalyse(self, self.filename)
1010         if not truepath:
1011             print 'ce fichier n\'existe pas'
1012             
1013         
1014
1015 class IntroPanel(wx.Panel):
1016     def __init__(self, parent):
1017         wx.Panel.__init__(self, parent)
1018         #col = randint(0, 255)
1019         #col1 = randint(0,255)
1020         #col2 = randint(0,255)
1021         col = 0
1022         bckgrdcolor = wx.Colour(col, col, col)
1023         self.SetBackgroundColour(bckgrdcolor)
1024         txtcolour = wx.Colour(250, 250, 250)
1025         linkcolor = wx.Colour(255, 0, 0)
1026         sizer1 = wx.BoxSizer(wx.VERTICAL)
1027         sizer2 = wx.BoxSizer(wx.VERTICAL)
1028         sizer3 = wx.BoxSizer(wx.HORIZONTAL)
1029         sizer4 = wx.BoxSizer(wx.VERTICAL)
1030         sizer5 = wx.BoxSizer(wx.HORIZONTAL)
1031         grid_sizer_1 = wx.FlexGridSizer(1, 4, 0, 0)
1032         grid_sizer_3 = wx.FlexGridSizer(1, 4, 0, 0)
1033         grid_sizer_2 = wx.FlexGridSizer(1, 3, 0, 0)
1034         PanelPres = wx.Panel(self)
1035         PanelPres.SetBackgroundColour(bckgrdcolor)
1036         label_1 = wx.StaticText(self, -1, u"IRaMuTeQ", size=(-1, -1))
1037         label_1.SetFont(wx.Font(46, wx.TELETYPE, wx.NORMAL, wx.BOLD, 0, "Purisa"))
1038         label_1.SetForegroundColour(wx.RED)
1039         label2 = wx.StaticText(PanelPres, -1 , u'\nVersion ' + ConfigGlob.get('DEFAULT', 'version') + '\n')
1040         label2.SetForegroundColour(txtcolour)
1041         label2.SetBackgroundColour(bckgrdcolor)
1042         #label3 = wx.StaticText(PanelPres, -1 , u'Equipe ')
1043         #label3.SetForegroundColour(txtcolour)
1044         #label3.SetBackgroundColour(bckgrdcolor)
1045         self.hyper2 = hl.HyperLinkCtrl(PanelPres, wx.ID_ANY, u"REPERE", URL="http://repere.no-ip.org/")
1046         self.hyper2.SetColours(linkcolor, linkcolor, "RED")
1047         self.hyper2.SetBackgroundColour(bckgrdcolor)
1048         self.hyper2.EnableRollover(True)
1049         self.hyper2.SetUnderlines(False, False, True)
1050         self.hyper2.SetBold(True)
1051         self.hyper2.UpdateLink()
1052         label_lerass = wx.StaticText(PanelPres, -1, u'Laboratoire ')
1053         label_lerass.SetForegroundColour(txtcolour)
1054         label_lerass.SetBackgroundColour(bckgrdcolor)
1055         self.hyper_lerass = hl.HyperLinkCtrl(PanelPres, -1, u'LERASS', URL="http://www.lerass.com")
1056         self.hyper_lerass.SetColours(linkcolor, linkcolor, "RED")
1057         self.hyper_lerass.SetBackgroundColour(bckgrdcolor)
1058         self.hyper_lerass.EnableRollover(True)
1059         self.hyper_lerass.SetUnderlines(False, False, True)
1060         self.hyper_lerass.SetBold(True)
1061         self.hyper_lerass.UpdateLink()
1062         blank = wx.StaticText(PanelPres, -1, u'\n')
1063         blank1 = wx.StaticText(PanelPres, -1, u'\n')
1064         labellicence = wx.StaticText(PanelPres, -1, u'Licence GNU GPL')
1065         labellicence.SetForegroundColour(txtcolour)
1066         labellicence.SetBackgroundColour(bckgrdcolor)
1067         labelcopy = wx.StaticText(PanelPres, -1, ConfigGlob.get('DEFAULT', 'copyright'))
1068         labelcopy.SetForegroundColour(txtcolour)
1069         labelcopy.SetBackgroundColour(bckgrdcolor)
1070         python_img = wx.Image(os.path.join(ImagePath,'python-logo.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1071         r_img = wx.Image(os.path.join(ImagePath,'Rlogo.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1072         lexique_img = wx.Image(os.path.join(ImagePath,'LexTexte4.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1073         but_python = wx.BitmapButton(self, -1, python_img)
1074         but_lexique = wx.BitmapButton(self, -1, lexique_img)
1075         but_r = wx.BitmapButton(self, -1, r_img)
1076         self.Bind(wx.EVT_BUTTON, self.OnPython, but_python)
1077         self.Bind(wx.EVT_BUTTON, self.OnLexique, but_lexique)
1078         self.Bind(wx.EVT_BUTTON, self.OnR, but_r)
1079         
1080         
1081         #grid_sizer_1.Add(label3, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1082         grid_sizer_1.Add(self.hyper2, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1083         grid_sizer_3.Add(label_lerass, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1084         grid_sizer_3.Add(self.hyper_lerass, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1085         sizer4.Add(label_1, 0, wx.ALIGN_CENTER, 5)
1086         sizer2.Add(label2, 0, wx.ALIGN_CENTER, 5)
1087         #sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 5)
1088         sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 5)
1089         sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 5)
1090         sizer2.Add(grid_sizer_3, 0, wx.ALIGN_CENTER, 5)
1091         sizer2.Add(wx.StaticText(PanelPres, -1, u' '), 0, wx.ALIGN_CENTER, 5)
1092         #sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 5)
1093         #sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 5)
1094         sizer2.Add(grid_sizer_1, 0, wx.ALIGN_CENTER, 5)
1095         sizer2.Add(labellicence, 0, wx.ALIGN_CENTER, 5)
1096         sizer2.Add(labelcopy, 0, wx.ALIGN_CENTER, 5)
1097         sizer1.Add(sizer4, 1, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1098         PanelPres.SetSizer(sizer2)
1099         sizer5.Add(blank, 1, wx.EXPAND | wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 2)
1100         sizer5.Add(PanelPres, 1, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1101         sizer5.Add(blank1, 1, wx.ALIGN_CENTER_HORIZONTAL,2)
1102         grid_sizer_2.Add(but_python, 1, wx.ALIGN_CENTER_HORIZONTAL| wx.ALIGN_CENTER_VERTICAL)
1103         grid_sizer_2.Add(but_lexique, 1,wx.ALIGN_CENTER_HORIZONTAL| wx.ALIGN_CENTER_VERTICAL)
1104         grid_sizer_2.Add(but_r, 1, wx.ALIGN_CENTER_HORIZONTAL| wx.ALIGN_CENTER_VERTICAL)
1105         
1106         sizer1.Add(sizer5, 3, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 1)
1107         sizer1.Add(grid_sizer_2, 1, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
1108         self.SetSizer(sizer1)
1109         sizer1.Fit(self)
1110     
1111     def OnPython(self,evt):
1112         webbrowser.open('http://www.python.org')
1113     
1114     def OnLexique(self,evt):
1115         webbrowser.open('http://www.lexique.org')
1116         
1117     def OnR(self,evt):
1118         webbrowser.open('http://www.r-project.org')
1119
1120 class MySplashScreen(wx.SplashScreen):
1121     def __init__(self):
1122         bmp = wx.Image(os.path.join(ImagePath, 'splash.png')).ConvertToBitmap()
1123         wx.SplashScreen.__init__(self, bmp,
1124                                  wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,
1125                                  2000, None, -1)
1126         self.Bind(wx.EVT_CLOSE, self.OnClose)
1127         self.fc = wx.FutureCall(1, self.ShowMain)
1128
1129     def OnClose(self, evt):
1130         evt.Skip()
1131         self.Hide()
1132         
1133         if self.fc.IsRunning():
1134             self.fc.Stop()
1135             self.ShowMain()
1136
1137     def ShowMain(self):
1138         frame = IraFrame(None, -1, "IRaMuTeQ " + ConfigGlob.get('DEFAULT', 'version'), size=(1100, 800))
1139         frame.Show()
1140         frame.Upgrade()
1141         frame.OnOpenFromCmdl()
1142 #        if self.fc.IsRunning():
1143 #            self.Raise()
1144         #wx.CallAfter(frame.ShowTip)
1145         
1146 class MyApp(wx.App):
1147     def OnInit(self):
1148         """
1149         Create and show the splash screen.  It will then create and show
1150         the main frame when it is time to do so.
1151         """
1152         wx.SystemOptions.SetOptionInt("mac.window-plain-transition", 1)
1153         self.SetAppName("Iramuteq")       
1154         splash = MySplashScreen()
1155         splash.Show()
1156         return True
1157
1158 def main():
1159     app = MyApp(False)
1160     app.MainLoop()
1161
1162 if __name__ == '__main__':
1163     __name__ = 'Main'
1164     main()