2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2008-2016, Pierre Ratinaud
7 from optparse import OptionParser
9 parser = OptionParser()
10 parser.add_option("-f", "--file", dest="filename",
11 help="open FILE", metavar="FILE", default=False)
12 (options, args) = parser.parse_args()
20 from random import randint
21 from ConfigParser import ConfigParser, RawConfigParser
25 #------------------------------------
27 import wx.lib.agw.aui as aui
30 import wx.lib.hyperlink as hl
31 #------------------------------------
32 from functions import BugReport, PlaySound, History, progressbar
33 from checkversion import NewVersion
34 from guifunct import *
35 from tableau import Tableau
36 from dialog import PrefDialog
37 from tabfrequence import Frequences, FreqMultiple
38 from tabchi2 import ChiSquare
39 from tabchi2mcnemar import McNemar
40 #from tabstudent import MakeStudent
41 from tabchddist import ChdCluster
42 from tabafcm import DoAFCM
43 from tabchdalc import AnalyseQuest
44 from tabsimi import DoSimi
45 from tabrsimple import InputText
46 from tabverges import Prototypical
47 from tabsplitvar import SplitMatrixFromVar
48 #from textdist import AnalysePam
49 from textstat import Stat
50 from textaslexico import Lexico
51 from textlabbe import DistLabbe
52 from textsimi import SimiTxt, SimiFromCluster
53 from textwordcloud import WordCloud, ClusterCloud
54 from textreinert import Reinert
55 #from textcheckcorpus import checkcorpus
56 from openanalyse import OpenAnalyse
57 from corpus import Builder, SubBuilder
58 from checkinstall import CreateIraDirectory, CheckRPath, FindRPAthWin32, FindRPathNix, CheckRPackages, IsNew, UpgradeConf, CopyConf, RLibsAreInstalled
59 from chemins import RscriptsPath, ConstructConfigPath, ConstructDicoPath, ConstructGlobalPath, PathOut
60 from parse_factiva_xml import ImportFactiva
61 from parse_dmi import ImportDMI
62 from tools import Extract
63 from analyse_merge import AnalyseMerge
65 from tree import LeftTree
66 ##########################################################
67 ID_OpenData = wx.NewId()
68 ID_Import = wx.NewId()
69 ID_OpenText = wx.NewId()
70 ID_OnOpenAnalyse = wx.NewId()
73 ID_Chi2mc = wx.NewId()
74 ID_Student = wx.NewId()
75 ID_CHDSIM = wx.NewId()
76 ID_CHDReinert = wx.NewId()
77 ID_TEXTAFCM = wx.NewId()
78 ID_TEXTSTAT = wx.NewId()
80 ID_TEXTREINERT = wx.NewId()
81 ID_TEXTPAM = wx.NewId()
82 ID_CHECKCORPUS = wx.NewId()
83 ID_Tabcontent = wx.NewId()
86 ID_CloseTab = wx.NewId()
87 ID_SaveTab = wx.NewId()
88 ID_CreateText = wx.NewId()
89 ID_ACCEUIL = wx.NewId()
90 ID_RESULT = wx.NewId()
91 ID_HTMLcontent = wx.NewId()
92 ID_SimiTxt = wx.NewId()
94 ID_ImportTXM = wx.NewId()
95 ID_FreqMulti = wx.NewId()
96 ID_Splitfromvar = wx.NewId()
97 ID_Subtxtfrommeta = wx.NewId()
98 ID_Subtxtfromthem = wx.NewId()
100 ID_ImportEuro = wx.NewId()
101 ID_Fact_xml = wx.NewId()
102 ID_Fact_mail = wx.NewId()
103 ID_Fact_copy = wx.NewId()
104 ID_exportmeta = wx.NewId()
105 ID_importdmi = wx.NewId()
106 ID_merge = wx.NewId()
107 ID_labbe = wx.NewId()
108 ##########################################################
109 #elements de configuration
110 ##########################################################
112 if sys.platform == 'darwin' :
113 sys.setdefaultencoding('UTF-8')
114 wx.SetDefaultPyEncoding('UTF-8')
116 sys.setdefaultencoding(locale.getpreferredencoding())
118 #chemin de l'application
119 AppliPath = os.path.abspath(os.path.dirname(os.path.realpath(sys.argv[0])))
121 ImagePath = os.path.join(AppliPath, 'images')
122 #configuration generale
123 DictConfigPath = ConstructGlobalPath(AppliPath)
124 ConfigGlob = ConfigParser()
125 ConfigGlob.read(DictConfigPath['global'])
126 DefaultConf = ConfigParser()
127 DefaultConf.read(DictConfigPath['preferences'])
128 #repertoire de l'utilisateur
129 user_home = os.getenv('HOME')
130 if user_home is None :
131 user_home = os.path.expanduser('~')
133 UserConfigPath = os.path.abspath(os.path.join(user_home, '.iramuteq'))
134 #Si pas de fichiers de config utilisateur, on cree le repertoire
135 CreateIraDirectory(UserConfigPath, AppliPath)
136 #fichiers log pour windows (py2exe)
137 log = logging.getLogger('iramuteq')
138 fh = logging.FileHandler(os.path.join(UserConfigPath,'stdout.log'))
139 formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
140 fh.setFormatter(formatter)
142 if sys.platform != 'win32' and sys.platform != 'darwin':
143 ch = logging.StreamHandler()
144 ch.setFormatter(formatter)
146 log.setLevel(logging.INFO)
148 class writer(object):
149 def write(self, data):
150 if data.strip() != '' :
151 log.info('ERROR : %s' % data)
153 class printer(object) :
154 def write(self, data) :
155 if data.strip() != '' :
156 log.info('Print : %s' % data)
158 sys.stderr = writer()
159 sys.stdout = printer()
161 ConfigPath = ConstructConfigPath(UserConfigPath)
163 langues = {'french' : wx.LANGUAGE_FRENCH,
164 'english' : wx.LANGUAGE_ENGLISH,
165 'portuguese' : wx.LANGUAGE_PORTUGUESE,
166 'italian' : wx.LANGUAGE_ITALIAN,
167 'spanish' : wx.LANGUAGE_SPANISH
170 code_langues = {'french' : 'fr_FR',
172 'portuguese' : 'pt_PT',
178 'textroot' : 'textroot.png',
179 'alceste' : 'reinert.png',
180 'corpus' : 'textcorpus.png',
181 'wordcloud' :'wordcloud.png',
183 'simitxt' : 'simitxt.png',
184 'clustersimitxt' :'clustersimitxt.png',
185 'clustercloud' : 'clustercloud.png',
187 'matroot' : 'matroot.png',
188 'matrix' : 'matrix.png',
189 'freq' : 'frequences.png',
190 'freqmulti' : 'frequences.png',
192 'chi2mcnemar' : 'chi2.png',
193 'reinertmatrix' : 'reinertmatrix.png',
194 'simimatrix' : 'simimatrix.png',
195 'simiclustermatrix' : 'simimatrix.png',
196 'proto' : 'proto.png',
198 'europress' : 'europress.png',
199 'factiva_xml' : 'factiva_xml.png',
200 'factiva_copy' : 'factiva_copy.png',
201 'factiva_mail': 'factiva_mail.png',
202 'iramuteq' : 'iraicone.png',
203 'subcorpusmeta' : 'subcorpusmeta.png',
204 'subcorpusthema' : 'subcorpusthema.png',
205 'preferences' : 'preferences.png',
206 'exportmetatable' : 'exportmetatable.png',
207 'importdmi' : 'twitter.png',
210 #####################################################################
212 class IraFrame(wx.Frame):
213 def __init__(self, parent, id= -1, title="", pos=wx.DefaultPosition,
214 size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE |
217 log.info('Starting... ' )
218 log.info('version : %s' % ConfigGlob.get('DEFAULT', 'version'))
219 wx.Frame.__init__(self, parent, id, title, pos, size, style)
221 self.AppliPath = AppliPath
222 self.images_path = os.path.join(AppliPath,'images')
223 self.UserConfigPath = UserConfigPath
224 #self.RscriptsPath = ConstructRscriptsPath(AppliPath)
225 self.RscriptsPath = PathOut(dirout=os.path.join(AppliPath, 'Rscripts'))
226 self.RscriptsPath.basefiles(RscriptsPath)
227 #self.DictPath = ConstructDicoPath(AppliPath)
228 self.DictPath = ConstructDicoPath(UserConfigPath)
229 self.ConfigGlob = ConfigGlob
230 self.ConfigPath = ConstructConfigPath(UserConfigPath)
231 self.pref = RawConfigParser()
232 #workaround for import problem
233 self.SimiFromCluster = SimiFromCluster
235 gettext.install('iramuteq', os.path.join(AppliPath,'locale'), unicode=True)
236 #langues = ['fr_FR', 'en', 'pt_PT']
240 for langue in code_langues :
241 self.preslangue[langue] = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=[code_langues[langue]])
243 #self.presLan_fr = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=['fr_FR'])
244 #self.presLan_en = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=['en'])
245 # tell FrameManager to manage this frame
246 #self._mgr = wx.aui.AuiManager()
247 self._mgr = aui.AuiManager()
248 self._mgr.SetManagedWindow(self)
251 #--------------------------------------------------------------------------------
252 self.images_analyses = images_analyses
253 for img in images_analyses :
254 self.images_analyses[img] = wx.Image(os.path.join(self.images_path, self.images_analyses[img]), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()
255 self.mb = wx.MenuBar()
257 file_menu = wx.Menu()
258 item = wx.MenuItem(file_menu, ID_OpenData, _(u"Open a matrix").decode('utf8'), _(u"Open a matrix").decode('utf8'))
259 #item.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN))
260 item.SetBitmap(self.images_analyses['matroot'])
261 file_menu.AppendItem(item)
263 item = wx.MenuItem(file_menu, ID_OpenText, _(u"Open a text corpus").decode('utf8'), _(u"Open a text corpus").decode('utf8'))
264 item.SetBitmap(self.images_analyses['textroot'])
265 file_menu.AppendItem(item)
267 item = wx.MenuItem(file_menu, ID_OnOpenAnalyse, _(u"Open an analysis").decode('utf8'), _(u"Open an analysis").decode('utf8'))
268 item.SetBitmap(self.images_analyses['iramuteq'])
269 file_menu.AppendItem(item)
271 item = wx.MenuItem(file_menu, ID_ImportTXM, _(u"Import from TXM").decode('utf8'), _(u"Import from TXM").decode('utf8'))
272 item.SetBitmap(self.images_analyses['TXM'])
273 file_menu.AppendItem(item)
275 item = wx.MenuItem(file_menu, ID_ImportEuro, _(u"Import from Europress").decode('utf8'), _(u"Import from Europress").decode('utf8'))
276 item.SetBitmap(self.images_analyses['europress'])
277 file_menu.AppendItem(item)
279 item = wx.MenuItem(file_menu, ID_importdmi, _(u"Import from DMI-TCAT (exp.)").decode('utf8'), _(u"Import from DMI-TCAT (exp.)").decode('utf8'))
280 item.SetBitmap(self.images_analyses['importdmi'])
281 file_menu.AppendItem(item)
283 item = wx.MenuItem(file_menu, ID_merge, _(u'Merge graphs').decode('utf8'), _(u'Merge graphs').decode('utf8'))
284 file_menu.AppendItem(item)
286 menuFactiva = wx.Menu()
287 fact_from_xml = wx.MenuItem(menuFactiva, ID_Fact_xml, _(u"from xml").decode('utf8'))
288 fact_from_xml.SetBitmap(self.images_analyses['factiva_xml'])
289 fact_from_mail = wx.MenuItem(menuFactiva, ID_Fact_mail, _(u"from mail").decode('utf8'))
290 fact_from_mail.SetBitmap(self.images_analyses['factiva_mail'])
291 fact_from_txt = wx.MenuItem(menuFactiva, ID_Fact_copy, _(u"from copy/paste").decode('utf8'))
292 fact_from_txt.SetBitmap(self.images_analyses['factiva_copy'])
293 menuFactiva.AppendItem(fact_from_xml)
294 menuFactiva.AppendItem(fact_from_mail)
295 menuFactiva.AppendItem(fact_from_txt)
296 file_menu.AppendMenu(-1, _(u"Import from factiva").decode('utf8'), menuFactiva)
298 menuTools = wx.Menu()
299 splitvar = wx.MenuItem(menuTools, wx.ID_ANY, _(u"Split from variable").decode('utf8'))
300 extractmod = wx.MenuItem(menuTools, wx.ID_ANY, _(u"Extract mods").decode('utf8'))
301 extractthem = wx.MenuItem(menuTools, wx.ID_ANY, _(u"Extract thematics").decode('utf8'))
302 menuTools.AppendItem(splitvar)
303 menuTools.AppendItem(extractmod)
304 menuTools.AppendItem(extractthem)
305 self.ID_splitvar = splitvar.GetId()
306 self.ID_extractmod = extractmod.GetId()
307 self.ID_extractthem = extractthem.GetId()
308 file_menu.AppendMenu(-1, _(u"Tools").decode('utf8'), menuTools)
311 #item = wx.MenuItem(file_menu, ID_SaveTab, _(u"Save tab as...").decode('utf8'), _(u"Save tab as...").decode('utf8'))
312 #item.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FILE_SAVE_AS))
313 #file_menu.AppendItem(item)
315 file_menu.Append(wx.ID_EXIT, _(u"Exit").decode('utf8'))
317 edit_menu = wx.Menu()
318 pref = wx.MenuItem(edit_menu, wx.ID_PREFERENCES, _(u'Preferences').decode('utf8'))
319 pref.SetBitmap(self.images_analyses['preferences'])
320 edit_menu.AppendItem(pref)
321 #edit_menu.Append(wx.ID_PREFERENCES, _(u'Preferences').decode('utf8'))
323 view_menu = wx.Menu()
324 home = wx.MenuItem(view_menu, ID_ACCEUIL, _(u"Home page").decode('utf8'))
325 home.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_GO_HOME, size = (16,16)))
326 view_menu.AppendItem(home)
327 #view_menu.Append(ID_ACCEUIL, _(u"Home page").decode('utf8'))
328 results = wx.MenuItem(view_menu, ID_RESULT, _(u'Show results').decode('utf8'))
329 results.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_LIST_VIEW, size = (16,16)))
330 view_menu.AppendItem(results)
331 #view_menu.Append(ID_RESULT, _(u'Show results').decode('utf8'))
332 #view_menu.AppendSeparator()
333 matrix_menu = wx.Menu()
334 matanalyses = [[ID_Freq, _(u"Frequencies").decode('utf8'), 'freq'],
335 [ID_FreqMulti, _(u"Multiple Frequencies").decode('utf8'), 'freqmulti'],
336 [ID_Chi2, _(u"Chi2").decode('utf8'), 'chi2'],
337 [ID_Chi2mc, _(u"Chi2 McNemar").decode('utf8'), 'chi2mcnemar'],
338 {'name' : _(u"Clustering").decode('utf8'),
339 'content' : [[ID_CHDReinert, _(u"Reinert's Method").decode('utf8'), 'reinertmatrix']]},
340 [ID_SIMI, _(u"Similarities Analysis").decode('utf8'), 'simimatrix'],
341 [ID_proto, _(u"Prototypical Analysis").decode('utf8'), 'proto'],
342 [ID_Splitfromvar, _(u"Split from variable").decode('utf8'), 'subcorpusmeta'],
345 for analyse in matanalyses :
346 if not isinstance(analyse, dict) :
347 item = wx.MenuItem(matrix_menu, analyse[0], analyse[1])
348 item.SetBitmap(self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)))
349 matrix_menu.AppendItem(item)
352 for subana in analyse['content'] :
353 item = wx.MenuItem(nmenu, subana[0], subana[1])
354 item.SetBitmap(self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)))
355 nmenu.AppendItem(item)
356 matrix_menu.AppendMenu(-1, analyse['name'], nmenu)
357 #item = wx.MenuItem(matrix_menu, ID_Freq, _(u"Frequencies").decode('utf8'))
358 #item.SetBitmap(self.images_analyses['freq'])
359 #matrix_menu.AppendItem(item)
360 #matrix_menu.Append(ID_Freq, _(u"Frequencies").decode('utf8'))
361 #item = wx.MenuItem(matrix_menu, ID_Freq, _(u"Multiple Frequencies").decode('utf8'))
362 #item.SetBitmap(self.images_analyses['freqmulti'])
363 #matrix_menu.Append(ID_FreqMulti, _(u'Multiple frequencies').decode('utf8'))
364 #matrix_menu.AppendItem(item)
365 #matrix_menu.Append(ID_Chi2, _(u"Chi2").decode('utf8'))
366 #matrix_menu.Append(ID_Student, u"t de Student")
367 #menu_classif = wx.Menu()
368 #menu_classif.Append(ID_CHDReinert, _(u"Reinert's Method").decode('utf8'))
369 #menu_classif.Append(ID_CHDSIM, u"Par matrice des distances")
370 #matrix_menu.AppendMenu(-1, _(u"Clustering").decode('utf8'), menu_classif)
371 #matrix_menu.Append(ID_AFCM, u"AFCM")
372 #matrix_menu.Append(ID_SIMI, _(u"Similarities Analysis").decode('utf8'))
373 #matrix_menu.Append(ID_proto, _(u"Prototypical Analysis").decode('utf8'))
374 ID_RCODE = wx.NewId()
375 #matrix_menu.Append(ID_RCODE, u"Code R...")
376 #menu_splittab = wx.Menu()
377 #ID_SPLITVAR = wx.NewId()
378 #splitvar = wx.MenuItem(menu_splittab, ID_SPLITVAR, _(u"Split from variable").decode('utf8'))
379 #menu_splittab.AppendItem(splitvar)
380 #matrix_menu.AppendMenu(-1, _(u"Split matrix").decode('utf8'), menu_splittab)
381 self.matrix_menu = matrix_menu
383 text_menu = wx.Menu()
384 analyses_text = [[ID_TEXTSTAT, _(u"Statistics").decode('utf8'), 'stat'],
385 [ID_ASLEX, _(u"Specificities and CA").decode('utf8'), 'spec'],
386 [ID_labbe, _(u"Labbe Distance").decode('utf8'),'labbe'],
387 {'name' : _(u"Clustering").decode('utf8'),
388 'content' : [[ID_TEXTREINERT, _(u"Reinert's Method").decode('utf8'), 'alceste']]},
389 [ID_SimiTxt, _(u"Similarities Analysis").decode('utf8'), 'simitxt'],
390 [ID_WC, _(u"WordCloud").decode('utf8'), 'wordcloud'],
391 {'name' : _(u"Sub corpus").decode('utf8'),
392 'content' : [[ID_Subtxtfrommeta, _(u'Sub corpus from metadata').decode('utf8'), 'subcorpusmeta'],
393 [ID_Subtxtfromthem, _(u'Sub corpus from thematic').decode('utf8'), 'subcorpusthema']]},
394 [ID_exportmeta, _(u"Export metadata table").decode('utf8'), 'exportmetatable'],
397 for analyse in analyses_text :
398 if not isinstance(analyse, dict) :
399 item = wx.MenuItem(text_menu, analyse[0], analyse[1])
400 item.SetBitmap(self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)))
401 text_menu.AppendItem(item)
404 for subana in analyse['content'] :
405 item = wx.MenuItem(nmenu, subana[0], subana[1])
406 item.SetBitmap(self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)))
407 nmenu.AppendItem(item)
408 text_menu.AppendMenu(-1, analyse['name'], nmenu)
409 #text_menu.Append(ID_CHECKCORPUS, u"Vérifier le corpus")
410 # text_menu.Append(ID_TEXTSTAT, _(u"Statistics").decode('utf8'))
411 # text_menu.Append(ID_ASLEX, _(u"Specificities and CA").decode('utf8'))
412 # #text_menu.Append(ID_TEXTAFCM, u"AFC sur UCI / Vocabulaire")
413 # menu_classiftxt = wx.Menu()
414 # menu_classiftxt.Append(ID_TEXTREINERT, _(u"Reinert's Method").decode('utf8'))
415 # #menu_classiftxt.Append(ID_TEXTPAM, u"Par matrice des distances")
416 # text_menu.AppendMenu(-1, _(u"Clustering").decode('utf8'), menu_classiftxt)
417 # text_menu.Append(ID_SimiTxt, _(u"Similarities Analysis").decode('utf8'))
419 # text_menu.Append(ID_WC, _(u"WordCloud").decode('utf8'))
420 self.text_menu = text_menu
422 help_menu = wx.Menu()
423 about = wx.MenuItem(help_menu, wx.ID_ABOUT, _(u"About...").decode('utf8'))
424 about.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_INFORMATION, size = (16,16)))
425 help_menu.AppendItem(about)
426 #help_menu.Append(wx.ID_ABOUT, _(u"About...").decode('utf8'))
427 help = wx.MenuItem(help_menu, wx.ID_HELP, _(u"Online help...").decode('utf8'))
428 help.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_HELP, size = (16,16)))
429 help_menu.AppendItem(help)
430 #help_menu.Append(wx.ID_HELP, _(u"Online help...").decode('utf8'))
432 self.mb.Append(file_menu, _(u"File").decode('utf8'))
433 self.mb.Append(edit_menu, _(u"Edition").decode('utf8'))
434 self.mb.Append(view_menu, _(u"View").decode('utf8'))
435 self.mb.Append(matrix_menu, _(u"Matrix analysis").decode('utf8'))
436 self.mb.Append(text_menu, _(u"Text analysis").decode('utf8'))
437 self.mb.Append(help_menu, _(u"Help").decode('utf8'))
439 self.SetMenuBar(self.mb)
440 #--------------------------------------------------------------------
441 self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP)
442 self.statusbar.SetStatusWidths([-2, -3])
443 self.statusbar.SetStatusText(_(u"Ready").decode('utf8'), 0)
444 self.statusbar.SetStatusText(_(u"Welcome").decode('utf8'), 1)
446 # min size for the frame itself isn't completely done.
447 # see the end up FrameManager::Update() for the test
448 # code. For now, just hard code a frame minimum size
449 self.SetMinSize(wx.Size(400, 400))
451 # create some toolbars
452 tb1 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
453 wx.TB_FLAT | wx.TB_NODIVIDER)
454 tb1.SetToolBitmapSize(wx.Size(16, 16))
455 tb1.AddLabelTool(ID_OpenData, "OpenData", self.images_analyses['matroot'], shortHelp=_(u"Matrix").decode('utf8'), longHelp=_(u"Open a matrix").decode('utf8'))
457 tb1.AddLabelTool(ID_OpenText, "OpenText", self.images_analyses['textroot'], shortHelp=_(u"Text").decode('utf8'), longHelp=_(u"Open a text corpus").decode('utf8'))
459 tb1.AddLabelTool(ID_OnOpenAnalyse, "OpenAnalyse", self.images_analyses['iramuteq'], shortHelp= _(u"Open an analysis").decode('utf8'), longHelp=_(u"Open an analysis").decode('utf8'))
461 tb1.AddLabelTool(ID_ImportTXM, "ImportTXM", self.images_analyses['TXM'], shortHelp= _(u"Import from TXM").decode('utf8'), longHelp=_(u"Import from TXM").decode('utf8'))
463 tb1.AddLabelTool(ID_ImportEuro, "ImportEuro", self.images_analyses['europress'], shortHelp= _(u"Import from Europress").decode('utf8'), longHelp=_(u"Import from Europress").decode('utf8'))
465 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'))
467 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'))
468 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'))
469 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'))
471 tb1.AddLabelTool(wx.ID_PREFERENCES, "Preferences", self.images_analyses['preferences'], shortHelp= _(u"Preferences").decode('utf8'), longHelp=_(u"Preferences").decode('utf8'))
473 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'))
474 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'))
477 tb_text = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
478 wx.TB_FLAT | wx.TB_NODIVIDER)
479 for analyse in analyses_text :
480 if not isinstance(analyse, dict) :
481 tb_text.AddLabelTool(analyse[0], analyse[1], self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)), shortHelp = analyse[1], longHelp = analyse[1])
483 for subana in analyse['content'] :
484 tb_text.AddLabelTool(subana[0], subana[1], self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)), shortHelp = subana[1], longHelp = subana[1])
487 tb_mat = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
488 wx.TB_FLAT | wx.TB_NODIVIDER)
489 for analyse in matanalyses :
490 if not isinstance(analyse, dict) :
491 tb_mat.AddLabelTool(analyse[0], analyse[1], self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)), shortHelp = analyse[1], longHelp = analyse[1])
493 for subana in analyse['content'] :
494 tb_mat.AddLabelTool(subana[0], subana[1], self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)), shortHelp = subana[1], longHelp = subana[1])
497 tb_help = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
498 wx.TB_FLAT | wx.TB_NODIVIDER)
499 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'))
500 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'))
502 #------------------------------------------------------------------------------------------------
504 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)
506 #self._mgr.AddPane(self.text_ctrl_txt, wx.aui.AuiPaneInfo().
507 # Name("Text").CenterPane())
508 self._mgr.AddPane(self.text_ctrl_txt, aui.AuiPaneInfo().
509 Name("Text").CenterPane())
510 #self._mgr.AddPane(IntroPanel(self), wx.aui.AuiPaneInfo().Name("Intro_Text").
512 self._mgr.AddPane(IntroPanel(self), aui.AuiPaneInfo().Name("Intro_Text").
514 #if not os.path.exists(os.path.join(UserConfigPath, 'history.db')) :
515 # with open(os.path.join(UserConfigPath, 'history.db'), 'w') as f :
517 self.history = History(os.path.join(UserConfigPath, 'history.db'))
518 self.tree = LeftTree(self)
519 self._mgr.AddPane(self.tree, aui.AuiPaneInfo().Name("lefttree").Caption(_(u"Historic").decode('utf8')).
520 Left().MinSize(wx.Size(200,500)).Layer(1).Position(1).CloseButton(False).MaximizeButton(True).
521 MinimizeButton(True))
523 #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)
524 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)
525 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
526 self.nb.SetAGWWindowStyleFlag(notebook_flags)
527 self.nb.SetArtProvider(aui.ChromeTabArt())
528 #self.nb.SetArtProvider(aui.VC8TabArt())
529 #self.nb.parent = self
530 #self._notebook_style = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | wx.NO_BORDER
531 #self._mgr.AddPane(self.nb, wx.aui.AuiPaneInfo().
532 # Name("Tab_content").
534 self._mgr.AddPane(self.nb, aui.AuiPaneInfo().
538 #self._mgr.AddPane(self.Sheet, wx.aui.AuiPaneInfo().Name("Data").CenterPane())
539 #self._mgr.AddPane(self.Sheet, aui.AuiPaneInfo().Name("Data").CenterPane())
540 self.nb.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnCloseTab)
541 self.nb.Bind(aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
542 # add the toolbars to the manager
544 #self._mgr.AddPane(tb1, wx.aui.AuiPaneInfo().
545 # Name("tb1").Caption("Fichiers").
546 # ToolbarPane().Top().
547 # LeftDockable(False).RightDockable(False))
548 self._mgr.AddPane(tb1, aui.AuiPaneInfo().
549 Name("tb1").Caption("Fichiers").
551 LeftDockable(True).RightDockable(False))
553 self._mgr.AddPane(tb_text, aui.AuiPaneInfo().
554 Name("tb_text").Caption("analyse_text").
556 LeftDockable(True).RightDockable(False))
558 self._mgr.AddPane(tb_mat, aui.AuiPaneInfo().
559 Name("tb_mat").Caption("analyse_matrix").
561 LeftDockable(True).RightDockable(False))
563 self._mgr.AddPane(tb_help, aui.AuiPaneInfo().
564 Name("tb_help").Caption("help").
566 LeftDockable(True).RightDockable(False))
568 self._mgr.GetPane('tb_text').Hide()
569 self._mgr.GetPane('tb_mat').Hide()
571 self.ShowAPane("Intro_Text")
572 self._mgr.GetPane("lefttree").Show()
573 self._mgr.GetPane("classif_tb").Hide()
574 # "commit" all changes made to FrameManager
577 # Show How To Use The Closing Panes Event
578 ##################################################################
579 self.Bind(wx.EVT_MENU, self.OnAcceuil, id=ID_ACCEUIL)
580 self.Bind(wx.EVT_MENU, self.ShowTab, id=ID_RESULT)
581 self.Bind(wx.EVT_MENU, self.OnOpenData, id=ID_OpenData)
582 self.Bind(wx.EVT_MENU, self.OnOpenText, id=ID_OpenText)
583 self.Bind(wx.EVT_MENU, self.OnOpenAnalyse, id=ID_OnOpenAnalyse)
584 self.Bind(wx.EVT_MENU, self.import_factiva_xml, fact_from_xml)
585 self.Bind(wx.EVT_MENU, self.import_factiva_mail, fact_from_mail)
586 self.Bind(wx.EVT_MENU, self.import_factiva_txt, fact_from_txt)
587 self.Bind(wx.EVT_MENU, self.ExtractTools, splitvar)
588 self.Bind(wx.EVT_MENU, self.ExtractTools, extractmod)
589 self.Bind(wx.EVT_MENU, self.ExtractTools, extractthem)
590 self.Bind(wx.EVT_MENU, self.OnFreq, id=ID_Freq)
591 self.Bind(wx.EVT_MENU, self.OnFreqMulti, id=ID_FreqMulti)
592 self.Bind(wx.EVT_MENU, self.OnChi2, id=ID_Chi2)
593 self.Bind(wx.EVT_MENU, self.OnChi2McNemar, id=ID_Chi2mc)
594 self.Bind(wx.EVT_MENU, self.OnStudent, id=ID_Student)
595 self.Bind(wx.EVT_MENU, self.OnCHDSIM, id=ID_CHDSIM)
596 self.Bind(wx.EVT_MENU, self.OnCHDReinert, id=ID_CHDReinert)
597 self.Bind(wx.EVT_MENU, self.OnAFCM, id=ID_AFCM)
598 self.Bind(wx.EVT_MENU, self.OnProto, id=ID_proto)
599 self.Bind(wx.EVT_MENU, self.OnSplitVar, id = ID_Splitfromvar)
600 #self.Bind(wx.EVT_MENU, self.OnRCode, id=ID_RCODE)
601 #self.Bind(wx.EVT_MENU, self.OnSplitVar, id=ID_SPLITVAR)
602 #self.Bind(wx.EVT_MENU, self.OnCheckcorpus, id = ID_CHECKCORPUS)
603 self.Bind(wx.EVT_MENU, self.OnTextStat, id=ID_TEXTSTAT)
604 self.Bind(wx.EVT_MENU, self.OnTextSpec, id=ID_ASLEX)
605 self.Bind(wx.EVT_MENU, self.OnTextLabbe, id=ID_labbe)
606 self.Bind(wx.EVT_MENU, self.OnTextAfcm, id=ID_TEXTAFCM)
607 self.Bind(wx.EVT_MENU, self.OnTextReinert, id=ID_TEXTREINERT)
608 self.Bind(wx.EVT_MENU, self.OnPamSimple, id=ID_TEXTPAM)
609 self.Bind(wx.EVT_MENU, self.OnSimiTxt, id=ID_SimiTxt)
610 self.Bind(wx.EVT_MENU, self.OnWordCloud, id=ID_WC)
611 self.Bind(wx.EVT_MENU, self.OnSubText, id = ID_Subtxtfrommeta)
612 self.Bind(wx.EVT_MENU, self.OnSubText, id = ID_Subtxtfromthem)
613 self.Bind(wx.EVT_MENU, self.OnSimiTab, id=ID_SIMI)
614 self.Bind(wx.EVT_MENU, self.OnExit, id=wx.ID_EXIT)
615 #self.Bind(wx.EVT_MENU, self.OnSaveTabAs, id=ID_SaveTab)
616 self.Bind(wx.EVT_MENU, self.OnAbout, id=wx.ID_ABOUT)
617 self.Bind(wx.EVT_MENU, self.OnHelp, id=wx.ID_HELP)
618 self.Bind(wx.EVT_MENU, self.OnPref, id=wx.ID_PREFERENCES)
619 self.Bind(wx.EVT_MENU, self.OnImportTXM, id=ID_ImportTXM)
620 self.Bind(wx.EVT_MENU, self.OnImportEuropress, id=ID_ImportEuro)
621 self.Bind(wx.EVT_MENU, self.OnImportDMI, id=ID_importdmi)
622 self.Bind(wx.EVT_MENU, self.OnExportMeta, id=ID_exportmeta)
623 self.Bind(wx.EVT_MENU, self.OnMergeGraph, id = ID_merge)
624 self.Bind(wx.EVT_CLOSE, self.OnClose)
625 ##################################################################
626 flags = self._mgr.GetAGWFlags()
627 #flags &= ~wx.aui.AUI_MGR_TRANSPARENT_HINT
628 #flags &= ~wx.aui.AUI_MGR_VENETIAN_BLINDS_HINT
629 #flags &= ~wx.aui.AUI_MGR_RECTANGLE_HINT
630 flags &= ~(aui.AUI_MGR_RECTANGLE_HINT | aui.AUI_MGR_ALLOW_FLOATING)
631 self._mgr.SetAGWFlags(self._mgr.GetAGWFlags() ^ (aui.AUI_MGR_RECTANGLE_HINT | aui.AUI_MGR_ALLOW_FLOATING))
632 self._mgr.GetArtProvider().SetMetric(aui.AUI_DOCKART_GRADIENT_TYPE, aui.AUI_GRADIENT_HORIZONTAL)
633 self.GetDockArt().SetColor(aui.AUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR, "#00FFF9")
636 self._icon = wx.Icon(os.path.join(ImagePath, "iraicone.ico"), wx.BITMAP_TYPE_ICO)
637 self.SetIcon(self._icon)
638 ##########################
640 self.input_path = [False]
641 self.TEMPDIR = tempfile.mkdtemp('iramuteq')
642 self.FileTabList = []
648 self.g_header = False
655 self.SysEncoding = sys.getdefaultencoding()
656 self.syscoding = sys.getdefaultencoding()
657 #print 'SysEncoding',self.SysEncoding
658 if self.SysEncoding == 'mac-roman' : self.SysEncoding = 'MacRoman'
661 ##############################################################@
662 self.ShowMenu('view', True)
663 self.ShowMenu('matrix', False)
664 self.ShowMenu('text', False)
675 def finish_init(self) :
677 self.pref.read(self.ConfigPath['preferences'])
680 self.pref.read(self.ConfigPath['preferences'])
687 self.pref.read(self.ConfigPath['preferences'])
689 self.sound = self.pref.getboolean('iramuteq', 'sound')
690 self.check_update = self.pref.getboolean('iramuteq', 'checkupdate')
691 self.version = ConfigGlob.get('DEFAULT', 'version')
692 #configuration des chemins de R
693 self.PathPath = ConfigParser()
694 self.PathPath.read(ConfigPath['path'])
696 if not CheckRPath(self.PathPath) :
697 if sys.platform == 'win32':
698 BestRPath = FindRPAthWin32()
700 BestRPath = FindRPathNix()
702 self.PathPath.set('PATHS', 'rpath', BestRPath)
703 with open(ConfigPath['path'], 'w') as f :
704 self.PathPath.write(f)
708 self.RPath = self.PathPath.get('PATHS', 'rpath')
711 if not RLibsAreInstalled(self) :
714 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'),
715 _(u"If R is installed, report its path in Preferences.").decode('utf8'),
716 _(u"IRaMuTeQ does not work without R.").decode('utf8')])
717 dlg = wx.MessageDialog(self, msg, _(u"Problem").decode('utf8'), wx.OK | wx.ICON_WARNING)
719 if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
723 def setlangue(self) :
724 self.pref.read(self.ConfigPath['preferences'])
726 guilangue = self.pref.get('iramuteq', 'guilanguage')
728 guilangue = DefaultConf.get('iramuteq', 'guilanguage')
729 self.preslangue.get(guilangue, 'english').install()
731 def OnVerif(self, evt) :
732 pack = CheckRPackages(self)
734 dlg = wx.MessageDialog(self, _(u"Installation OK").decode('utf8'), _(u"Installation").decode('utf8'), wx.OK | wx.ICON_INFORMATION | wx.STAY_ON_TOP)
736 if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
739 def ShowMenu(self, menu, Show=True):
743 self._mgr.GetPane('tb_text').Show()
745 self._mgr.GetPane('tb_text').Hide()
746 elif menu == 'matrix' :
749 self._mgr.GetPane('tb_mat').Show()
751 self._mgr.GetPane('tb_mat').Hide()
752 elif menu == 'view' :
757 #menu_pos = self.mb.FindMenu(menu)
758 if not menu_pos is None :
759 self.mb.EnableTop(menu_pos, Show)
760 self.mb.UpdateMenus()
763 #--------------------------------------------------------------------
764 def OnClose(self, event):
766 with open(self.ConfigPath['path'], 'w') as f :
767 self.PathPath.write(f)
772 def OnOpenData(self, event):
773 inputname, self.input_path = OnOpen(self, "Data")
775 #filename = self.input_path[0]
776 self.tableau = Tableau(self,os.path.abspath(self.input_path[0]))
777 val = get_table_param(self, self.input_path[0])
779 busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self)
782 self.tableau.make_content()
783 OpenAnalyse(self, self.tableau.parametres)
784 self.tree.OnItemAppend(self.tableau.parametres)
789 #self.tableau.show_tab()
791 def OnOpenAnalyse(self, event):
792 self.AnalysePath = OnOpen(self, "Analyse")
793 if self.AnalysePath :
794 OpenAnalyse(self, self.AnalysePath[1][0], True)
795 self.ShowMenu('view')
797 def OnOpenText(self, event):
798 inputname, self.input_path = OnOpen(self, "Texte")
799 self.filename = self.input_path[0]
803 def OnSubText(self, evt, corpus = None, parametres = None):
805 corpus = self.tree.getcorpus()
806 if evt.GetId() == ID_Subtxtfrommeta :
807 parametres = {'frommeta' : True}
808 elif evt.GetId() == ID_Subtxtfromthem :
809 parametres = {'fromtheme' : True}
810 builder = SubBuilder(self, corpus, parametres)
811 if builder.res == wx.ID_OK :
812 busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self)
814 corpus = builder.doanalyse()
815 self.history.add(corpus.parametres)
816 OpenAnalyse(self, corpus.parametres)
817 self.tree.OnItemAppend(corpus.parametres)
821 builder = Builder(self, 5)
822 if builder.res == wx.ID_OK :
824 corpus = builder.doanalyse()
825 self.history.add(corpus.parametres)
826 self.tree.OnItemAppend(corpus.parametres)
827 OpenAnalyse(self, corpus.parametres)
829 builder.dlg.Destroy()
833 keepGoing = builder.dlg.Update(count, u"Lecture du fichier")
834 self.ShowMenu('view')
835 self.ShowMenu('text')
836 self.ShowMenu('matrix', False)
841 keepGoing = builder.dlg.Update(count, u"Chargement du dictionnaire")
842 builder.dlg.Destroy()
844 def OnExit(self, event):
847 def OnAbout(self, event):
848 info = wx.AboutDialogInfo()
849 info.Name = ConfigGlob.get('DEFAULT', 'name')
850 info.Version = ConfigGlob.get('DEFAULT', 'version')
851 info.Copyright = ConfigGlob.get('DEFAULT', 'copyright')
852 info.Translators = ConfigGlob.get('DEFAULT', 'translators').decode('utf8').split(';')
853 info.Description = u"""
854 Interface de R pour les Analyses Multidimensionnelles
855 de Textes et de Questionnaires
858 construit avec des logiciels libres.
864 info.WebSite = ("http://www.iramuteq.org", u"Site web IRaMuTeQ")
865 dev = ConfigGlob.get('DEFAULT', 'dev').decode('utf8').split(';')
866 info.Developers = dev
867 info.License = u"""Iramuteq est un logiciel libre ; vous pouvez le diffuser et/ou le modifier
868 suivant les termes de la Licence Publique Générale GNU telle que publiée
869 par la Free Software Foundation ; soit la version 2 de cette licence,
870 soit (à votre convenance) une version ultérieure.
872 Iramuteq est diffusé dans l'espoir qu'il sera utile,
873 mais SANS AUCUNE GARANTIE ; sans même une garantie implicite
874 de COMMERCIALISATION ou d'ADÉQUATION À UN USAGE PARTICULIER.
875 Voyez la Licence Publique Générale GNU pour plus de détails.
877 Vous devriez avoir reçu une copie de la Licence Publique Générale GNU
878 avec Iramuteq ; sinon, veuillez écrire à la Free Software Foundation,
879 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis."""
882 def GetDockArt(self):
883 return self._mgr.GetArtProvider()
888 def OnPageChanged(self, event) :
889 new = event.GetSelection()
890 nobject = event.GetEventObject()
891 parent = nobject.GetParent()
892 if isinstance(parent, IraFrame) :
893 npage = self.nb.GetPage(new)
894 if 'parametres' in dir(npage) :
895 self.tree.GiveFocus(uuid=npage.parametres['uuid'])
896 if npage.parametres.get('matrix', False) :
897 self.ShowMenu('text', False)
898 self.ShowMenu('matrix', True)
899 elif npage.parametres.get('corpus', False) :
900 self.ShowMenu('text')
901 self.ShowMenu('matrix', False)
903 def OnCloseTab(self, evt):
904 #log.info('Closing tab %s' % str(evt.GetEventObject()))
905 ctrl = evt.GetEventObject()
906 if isinstance(ctrl.GetParent(), aui.AuiNotebook) or isinstance(ctrl.GetParent(), wx.Panel):
910 page = self.nb.GetPage(self.nb.GetSelection())
911 if 'parametres' in dir(page) and isinstance(ctrl.GetParent(), IraFrame) :
912 self.history.rmtab(page.parametres)
913 self.tree.CloseItem(uuid = page.parametres['uuid'])
914 TabTitle = self.nb.GetPageText(self.nb.GetSelection())
916 if self.nb.GetPageCount() == 1 and not notebook :
919 def LastTabClose(self) :
920 if self.nb.GetPageCount() == 1 :
922 self.ShowAPane("Text")
924 self.ShowAPane("Data")
926 self.ShowAPane("Intro_Text")
928 def GetStartPosition(self):
932 pt = self.ClientToScreen(wx.Point(0, 0))
934 return wx.Point(pt.x + x, pt.y + x)
936 def ShowAPane(self, panel):
937 for pane in self._mgr.GetAllPanes() :
938 if not pane.IsToolbar() and pane.name != 'lefttree':
940 self._mgr.GetPane(panel).Show()
943 def OnAcceuil(self, event):
944 self.ShowAPane(u"Intro_Text")
947 def CreateHTMLCtrl(self):
948 ctrl = wx.html.HtmlWindow(self, -1, wx.DefaultPosition, wx.Size(400, 300))
949 if "gtk2" in wx.PlatformInfo:
950 ctrl.SetStandardFonts()
951 ctrl.SetPage(u"text")
954 def ShowTab(self, evt):
955 self.ShowAPane("Tab_content")
957 ################################################################
959 ################################################################
960 def analyse_matrix(self, analyse, analyse_type = '', matrix = None, parametres = None, dlgnb = 1):
962 matrix = self.tree.getmatrix()
963 if parametres is not None :
964 parametres['type'] = analyse_type
966 parametres = {'type' : analyse_type}
968 #print 'plus de bug@@@@@@@@@@@@@@@@@@@@@@'
969 analyse(self, matrix, parametres = parametres, dlg = dlgnb)
973 def OnFreq(self, event, matrix = None):
974 self.analyse_matrix(Frequences, analyse_type = 'freq', matrix = matrix, dlgnb = 3)
976 def OnFreqMulti(self, event, matrix = None):
977 self.analyse_matrix(FreqMultiple, analyse_type = 'freqmulti', matrix = matrix, dlgnb = 3)
979 def OnChi2(self, event, matrix = None):
980 self.analyse_matrix(ChiSquare, matrix = matrix, analyse_type = 'chi2', dlgnb = 3)
982 def OnChi2McNemar(self, event, matrix = None):
983 self.analyse_matrix(McNemar, matrix = matrix, analyse_type = 'chi2mcnemar', dlgnb = 3)
985 def OnSimiTab(self, event, matrix = None):
986 self.analyse_matrix(DoSimi, matrix = matrix, analyse_type = 'simimatrix', dlgnb = 5)
988 def OnCHDReinert(self, event, matrix = None):
990 # matrix = self.tree.getmatrix()
991 #AnalyseQuest(self, matrix, parametres = {'type' : 'reinertmatrix'}, dlg = 3)
992 self.analyse_matrix(AnalyseQuest, matrix = matrix, analyse_type = 'reinertmatrix', dlgnb = 5)
994 def OnStudent(self, event):
1000 def OnRCode(self, event):
1006 def OnCHDSIM(self, event):
1008 # print 'ATTENTION!!!!'
1009 chdsim = ChdCluster(self)
1010 if chdsim.val == wx.ID_OK:
1015 # def OnCHDReinert(self, event):
1017 # # print('PLUS DE BUG SUR ALCESTE QUESTIONNAIRE')
1018 # self.quest = AnalyseQuest(self)
1019 # if self.quest.val == wx.ID_OK:
1023 def OnMergeGraph(self, evt):
1025 AnalyseMerge(self, {'type': 'merge', 'fileout' : '/tmp/test.txt'}, dlg = 5)
1027 def OnProto(self, evt, matrix = None) :
1028 self.analyse_matrix(Prototypical, matrix = matrix, analyse_type = 'proto', dlgnb = 3)
1029 #Prototypical(self, {'type' : 'proto'})
1031 def OnSplitVar(self, evt, matrix = None):
1033 matrix = self.tree.getmatrix()
1034 self.analyse_matrix(SplitMatrixFromVar, matrix = matrix, analyse_type = 'splitvar', parametres = {'pathout': matrix.pathout.dirout}, dlgnb = 3)
1035 #matrix = self.tree.getmatrix()
1038 def OnSimiTxt(self, evt, corpus = None) :
1039 # print 'PLUS DE BUG SUR SIMITXT'
1041 #self.Text = SimiTxt(self)
1043 corpus = self.tree.getcorpus()
1044 self.Text = SimiTxt(self, corpus, parametres = {'type': 'simitxt'}, dlg = 3)
1045 if self.Text.val == wx.ID_OK :
1050 def OnWordCloud(self, evt, corpus = None) :
1051 # print 'PLUS DE BUG SUR WORDCLOUD'
1054 corpus = self.tree.getcorpus()
1055 self.Text = WordCloud(self, corpus, parametres = {'type' : 'wordcloud'}, dlg = 3)
1056 if self.Text.val == wx.ID_OK :
1061 def OnClusterCloud(self, corpus, parametres = None) :
1062 self.Text = ClusterCloud(self, corpus, parametres = parametres, dlg = 3)
1064 def OnAFCM(self, event):
1070 def OnTextStat(self, event, corpus = None):
1071 #print 'PAS DE BUG SUR TEXT STAT'
1074 corpus = self.tree.getcorpus()
1075 self.Text = Stat(self, corpus, parametres = {'type': 'stat'}, dlg = 7)
1077 if self.Text.val == wx.ID_OK :
1082 def OnTextSpec(self, event, corpus = None):
1084 #self.Text = AsLexico(self)
1085 #print('ATTENTION : PLUS DE BUG SUR LEXICO')
1087 corpus = self.tree.getcorpus()
1088 self.Text = Lexico(self, corpus, parametres = {'type' : 'spec'}, dlg = 3)
1089 if self.Text.val == wx.ID_OK :
1094 def OnTextLabbe(self, event, corpus = None):
1097 corpus = self.tree.getcorpus()
1098 self.Text = DistLabbe(self, corpus, parametres = {'type' : 'labbe'}, dlg = 3)
1099 if self.Text.val == wx.ID_OK :
1105 def OnTextAfcm(self, event):
1112 def import_factiva_xml(self,event):
1114 ImportFactiva(self, 'xml')
1118 def import_factiva_mail(self, evt) :
1120 ImportFactiva(self, 'mail')
1124 def import_factiva_txt(self, evt) :
1126 ImportFactiva(self, 'txt')
1130 def OnImportTXM(self, evt) :
1132 ImportFactiva(self, 'txm')
1136 def OnImportEuropress(self, evt) :
1138 ImportFactiva(self, 'euro')
1142 def OnImportDMI(self, evt):
1145 def OnExportMeta(self, evt, corpus = None):
1147 corpus = self.tree.getcorpus()
1149 ExportMetaTable(self, corpus)
1153 def ExtractTools(self, evt) :
1155 if ID == self.ID_splitvar :
1156 Extract(self, 'splitvar')
1157 elif ID == self.ID_extractmod :
1158 Extract(self, 'mods')
1159 elif ID == self.ID_extractthem :
1160 Extract(self, 'them')
1162 def OnTextReinert(self, event, corpus = None):
1164 #print('ATTENTION : PLUS DE BUG SUR ALCESTE')
1165 #RunAnalyse(self, corpus, Alceste, OptAlceste)
1167 corpus = self.tree.getcorpus()
1168 self.Text = Reinert(self, corpus, parametres = {'type': 'alceste'}, dlg = 6)
1169 if self.Text.val == wx.ID_OK:
1174 def OnPamSimple(self, event, corpus = None):
1177 corpus = self.tree.getcorpus()
1178 self.Text = AnalysePam(self, corpus, parametres = {'type' : 'pamtxt'}, dlg = 6)
1179 if self.Text.val == wx.ID_OK:
1184 def SimiCluster(self, parametres = {}, fromprof = False, tableau = None) :
1185 self.analyse_matrix(DoSimi, parametres = parametres, analyse_type = 'simiclustermatrix', matrix = tableau, dlgnb = 5)
1187 # def OnSimi(self,evt):
1189 #print 'ATTENTION !!!! VERGES'
1190 #print 'PLUS DE BUG SUR SIMI'
1191 # self.res = DoSimi(self, param = None)
1192 #self.res = Verges(self)
1193 # if self.res.val == wx.ID_OK :
1197 #################################################################
1199 def OnHelp(self, event):
1200 webbrowser.open('http://www.iramuteq.org/documentation')
1202 def OnPref(self, event):
1203 dlg = PrefDialog(self)
1204 dlg.CenterOnParent()
1205 self.val = dlg.ShowModal()
1209 if self.check_update:
1212 print 'pas de verif'
1214 #CheckRPackages(self)
1216 def OnOpenFromCmdl(self):
1218 if options.filename :
1219 if os.path.exists(options.filename):
1220 self.filename = os.path.abspath(options.filename)
1224 if os.path.exists(os.path.realpath(args[0])):
1225 self.filename = os.path.abspath(os.path.realpath(args[0]))
1231 if os.path.splitext(self.filename)[1] in ['.csv', '.xls', '.ods']:
1232 self.tableau = Tableau(self, self.filename)
1233 val = get_table_param(self, self.filename)
1234 if val == wx.ID_OK :
1235 self.tableau.make_content()
1236 OpenAnalyse(self, self.tableau.parametres)
1237 self.tree.OnItemAppend(self.tableau.parametres)
1238 #get_table_param(self, self.filename)
1239 #self.tableau.make_content()
1240 #self.tableau.show_tab()
1241 #open_data(self, self.filename)
1242 elif os.path.splitext(self.filename)[1] == '.txt':
1244 elif os.path.splitext(self.filename)[1] == '.ira' :
1245 #self.corpus = Corpus(self)
1246 #self.Text = OpenAnalyse(self, self.filename)
1247 OpenAnalyse(self, self.filename)
1249 print 'This file does not exist'
1253 class IntroPanel(wx.Panel):
1254 def __init__(self, parent):
1255 wx.Panel.__init__(self, parent)
1256 #col = randint(0, 255)
1257 #col1 = randint(0,255)
1258 #col2 = randint(0,255)
1263 bckgrdcolor = wx.Colour(col, col1, col2)
1264 self.SetBackgroundColour(bckgrdcolor)
1265 txtcolour = wx.Colour(250, 250, 250)
1266 linkcolor = wx.Colour(255, 0, 0)
1267 sizer1 = wx.BoxSizer(wx.VERTICAL)
1268 sizer2 = wx.BoxSizer(wx.VERTICAL)
1269 sizer4 = wx.BoxSizer(wx.HORIZONTAL)
1270 grid_sizer_1 = wx.FlexGridSizer(1, 4, 0, 0)
1271 grid_sizer_3 = wx.FlexGridSizer(1, 4, 0, 0)
1272 grid_sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
1274 iralink = hl.HyperLinkCtrl(self, wx.ID_ANY, u"http://www.iramuteq.org", URL="http://www.iramuteq.org")
1275 iralink.SetColours(linkcolor, linkcolor, "RED")
1276 iralink.SetBackgroundColour(bckgrdcolor)
1277 iralink.EnableRollover(True)
1278 iralink.SetUnderlines(False, False, True)
1279 iralink.SetBold(True)
1280 iralink.UpdateLink()
1282 PanelPres = wx.Panel(self)
1283 bckgrdcolor = wx.Colour(randint(0, 255), randint(0, 255), randint(0, 255))
1284 PanelPres.SetBackgroundColour(bckgrdcolor)
1286 label_1 = wx.StaticText(self, -1, u"IRaMuTeQ", size=(-1, -1))
1287 label_1.SetFont(wx.Font(46, wx.TELETYPE, wx.NORMAL, wx.BOLD, 0, "Purisa"))
1288 label_1.SetForegroundColour(wx.RED)
1290 iraicone = wx.Image(os.path.join(ImagePath,'iraicone100x100.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1291 but_ira = wx.StaticBitmap(self, -1, bitmap = iraicone)
1294 label2 = wx.StaticText(PanelPres, -1 , u'\nVersion ' + ConfigGlob.get('DEFAULT', 'version') + '\n')
1295 label2.SetForegroundColour(txtcolour)
1296 label2.SetBackgroundColour(bckgrdcolor)
1297 self.hyper2 = hl.HyperLinkCtrl(PanelPres, wx.ID_ANY, u"REPERE", URL="http://repere.no-ip.org/")
1298 self.hyper2.SetColours(linkcolor, linkcolor, "RED")
1299 self.hyper2.SetBackgroundColour(bckgrdcolor)
1300 self.hyper2.EnableRollover(True)
1301 self.hyper2.SetUnderlines(False, False, True)
1302 self.hyper2.SetBold(True)
1303 self.hyper2.UpdateLink()
1305 label_lerass = wx.StaticText(PanelPres, -1, u'Laboratoire ')
1306 label_lerass.SetForegroundColour(txtcolour)
1307 label_lerass.SetBackgroundColour(bckgrdcolor)
1309 self.hyper_lerass = hl.HyperLinkCtrl(PanelPres, -1, u'LERASS', URL="http://www.lerass.com")
1310 self.hyper_lerass.SetColours(linkcolor, linkcolor, "RED")
1311 self.hyper_lerass.SetBackgroundColour(bckgrdcolor)
1312 self.hyper_lerass.EnableRollover(True)
1313 self.hyper_lerass.SetUnderlines(False, False, True)
1314 self.hyper_lerass.SetBold(True)
1315 self.hyper_lerass.UpdateLink()
1317 blank = wx.StaticText(PanelPres, -1, u'\n')
1318 blank1 = wx.StaticText(PanelPres, -1, u'\n')
1320 labellicence = wx.StaticText(PanelPres, -1, _(u"License GNU GPL").decode('utf8'))
1321 labellicence.SetForegroundColour(txtcolour)
1322 labellicence.SetBackgroundColour(bckgrdcolor)
1324 labelcopy = wx.StaticText(PanelPres, -1, ConfigGlob.get('DEFAULT', 'copyright'))
1325 labelcopy.SetForegroundColour(txtcolour)
1326 labelcopy.SetBackgroundColour(bckgrdcolor)
1328 python_img = wx.Image(os.path.join(ImagePath,'python-logo.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1329 r_img = wx.Image(os.path.join(ImagePath,'Rlogo.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1330 lexique_img = wx.Image(os.path.join(ImagePath,'LexTexte4.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1331 but_python = wx.BitmapButton(self, -1, python_img)
1332 but_lexique = wx.BitmapButton(self, -1, lexique_img)
1333 but_r = wx.BitmapButton(self, -1, r_img)
1334 self.Bind(wx.EVT_BUTTON, self.OnPython, but_python)
1335 self.Bind(wx.EVT_BUTTON, self.OnLexique, but_lexique)
1336 self.Bind(wx.EVT_BUTTON, self.OnR, but_r)
1339 grid_sizer_1.Add(self.hyper2, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1340 grid_sizer_3.Add(label_lerass, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1341 grid_sizer_3.Add(self.hyper_lerass, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1342 sizer4.Add(label_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5)
1344 sizer2.Add(label2, 0, wx.ALIGN_CENTER, 5)
1345 sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 5)
1346 sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 5)
1347 sizer2.Add(grid_sizer_3, 0, wx.ALIGN_CENTER, 5)
1348 sizer2.Add(wx.StaticText(PanelPres, -1, u' '), 0, wx.ALIGN_CENTER, 5)
1349 sizer2.Add(grid_sizer_1, 0, wx.ALIGN_CENTER, 5)
1350 sizer2.Add(labellicence, 0, wx.ALIGN_CENTER, 5)
1351 sizer2.Add(labelcopy, 0, wx.ALIGN_CENTER, 5)
1352 sizer1.Add(sizer4, 2, wx.ALIGN_CENTER_HORIZONTAL, 0)
1353 sizer1.Add(but_ira, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5)
1354 sizer1.Add(iralink, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_TOP, 5)
1355 sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 10)
1356 PanelPres.SetSizer(sizer2)
1357 grid_sizer_2.Add(but_python, 1, wx.ALIGN_BOTTOM)
1358 grid_sizer_2.Add(but_lexique, 1, wx.ALIGN_BOTTOM)
1359 grid_sizer_2.Add(but_r, 1, wx.ALIGN_BOTTOM)
1361 sizer1.Add(PanelPres, 0, wx.EXPAND |wx.ALL, 10)
1362 sizer1.Add(grid_sizer_2, 2, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 1)
1363 self.SetSizer(sizer1)
1366 def OnPython(self,evt):
1367 webbrowser.open('http://www.python.org')
1369 def OnLexique(self,evt):
1370 webbrowser.open('http://www.lexique.org')
1373 webbrowser.open('http://www.r-project.org')
1375 class MySplashScreen(wx.SplashScreen):
1377 bmp = wx.Image(os.path.join(ImagePath, 'splash.png')).ConvertToBitmap()
1378 wx.SplashScreen.__init__(self, bmp,
1379 wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,
1381 self.Bind(wx.EVT_CLOSE, self.OnClose)
1382 self.fc = wx.FutureCall(1, self.ShowMain)
1384 def OnClose(self, evt):
1388 if self.fc.IsRunning():
1393 displaySize = wx.DisplaySize()
1394 w = displaySize[0]/1.2
1395 h = displaySize[1]/1.2
1396 frame = IraFrame(None, -1, "IRaMuTeQ " + ConfigGlob.get('DEFAULT', 'version'), size=(w, h))
1400 frame.OnOpenFromCmdl()
1401 # if self.fc.IsRunning():
1403 #wx.CallAfter(frame.ShowTip)
1405 class MyApp(wx.App):
1408 Create and show the splash screen. It will then create and show
1409 the main frame when it is time to do so.
1411 wx.SystemOptions.SetOptionInt("mac.window-plain-transition", 1)
1412 self.SetAppName("Iramuteq")
1413 splash = MySplashScreen()
1421 if __name__ == '__main__':