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