2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2008-2020, Pierre Ratinaud
8 from optparse import OptionParser
10 parser = OptionParser()
11 parser.add_option("-f", "--file", dest="filename",
12 help="open FILE", metavar="FILE", default=False)
13 (options, args) = parser.parse_args()
17 #sys.path.insert(0, '/usr/lib/python2.7/dist-packages/wxPython-4.0.1-py2.7-linux-amd64.egg')
22 from random import randint
23 from ConfigParser import ConfigParser, RawConfigParser
27 #------------------------------------
29 import wx.lib.agw.aui as aui
32 import wx.lib.hyperlink as hl
33 #import wx.lib.agw.hyperlink as hl
34 #------------------------------------
35 from functions import BugReport, PlaySound, History, progressbar
36 from checkversion import NewVersion
37 from guifunct import *
38 from tableau import Tableau
39 from dialog import PrefDialog
40 from tabfrequence import Frequences, FreqMultiple
41 from tabchi2 import ChiSquare
42 from tabchi2mcnemar import McNemar
43 #from tabstudent import MakeStudent
44 from tabchddist import ChdCluster
45 from tabafcm import DoAFCM
46 from tabchdalc import AnalyseQuest
47 from tabsimi import DoSimi
48 from tabrsimple import InputText
49 from tabverges import Prototypical
50 from tabsplitvar import SplitMatrixFromVar
51 #frog textdist import AnalysePam
52 from textstat import Stat
53 from textaslexico import Lexico
54 from textlabbe import DistLabbe
55 from textsimi import SimiTxt, SimiFromCluster
56 from textwordcloud import WordCloud, ClusterCloud
57 from textreinert import Reinert#, ReDoReinert
58 #from textcheckcorpus import checkcorpus
59 from openanalyse import OpenAnalyse
60 from corpus import Builder, SubBuilder, MergeClusters
61 from checkinstall import CreateIraDirectory, CheckRPath, FindRPAthWin32, FindRPathNix, CheckRPackages, IsNew, UpgradeConf, CopyConf, RLibsAreInstalled
62 from chemins import RscriptsPath, ConstructConfigPath, ConstructDicoPath, ConstructGlobalPath, PathOut
63 from parse_factiva_xml import ImportFactiva
64 from parse_dmi import ImportDMI
65 from tools import Extract
66 from analyse_merge import AnalyseMerge
68 from tree import LeftTree
69 ##########################################################
70 ID_OpenData = wx.NewId()
71 ID_Import = wx.NewId()
72 ID_OpenText = wx.NewId()
73 ID_OnOpenAnalyse = wx.NewId()
76 ID_Chi2mc = wx.NewId()
77 ID_Student = wx.NewId()
78 ID_CHDSIM = wx.NewId()
79 ID_CHDReinert = wx.NewId()
80 ID_TEXTAFCM = wx.NewId()
81 ID_TEXTSTAT = wx.NewId()
83 ID_TEXTREINERT = wx.NewId()
84 ID_TEXTPAM = wx.NewId()
85 ID_CHECKCORPUS = wx.NewId()
86 ID_Tabcontent = wx.NewId()
89 ID_CloseTab = wx.NewId()
90 ID_SaveTab = wx.NewId()
91 ID_CreateText = wx.NewId()
92 ID_ACCEUIL = wx.NewId()
93 ID_RESULT = wx.NewId()
94 ID_HTMLcontent = wx.NewId()
95 ID_SimiTxt = wx.NewId()
97 ID_ImportTXM = wx.NewId()
98 ID_FreqMulti = wx.NewId()
99 ID_Splitfromvar = wx.NewId()
100 ID_Subtxtfrommeta = wx.NewId()
101 ID_Subtxtfromthem = wx.NewId()
103 ID_ImportEuro = wx.NewId()
104 ID_Fact_xml = wx.NewId()
105 ID_Fact_mail = wx.NewId()
106 ID_Fact_copy = wx.NewId()
107 ID_exportmeta = wx.NewId()
108 ID_importdmi = wx.NewId()
109 ID_merge = wx.NewId()
110 ID_merge_clusters = wx.NewId()
111 ID_labbe = wx.NewId()
112 ##########################################################
113 #elements de configuration
114 ##########################################################
116 if sys.platform == 'darwin' :
117 sys.setdefaultencoding('UTF-8')
118 wx.SetDefaultPyEncoding('UTF-8')
120 sys.setdefaultencoding(locale.getpreferredencoding())
122 #chemin de l'application
123 AppliPath = os.path.abspath(os.path.dirname(os.path.realpath(sys.argv[0])))
125 ImagePath = os.path.join(AppliPath, 'images')
126 #configuration generale
127 DictConfigPath = ConstructGlobalPath(AppliPath)
128 ConfigGlob = ConfigParser()
129 ConfigGlob.read(DictConfigPath['global'])
130 DefaultConf = ConfigParser()
131 DefaultConf.read(DictConfigPath['preferences'])
132 #repertoire de l'utilisateur
133 user_home = os.getenv('HOME')
134 if user_home is None :
135 user_home = os.path.expanduser('~')
137 UserConfigPath = os.path.abspath(os.path.join(user_home, '.iramuteq-%s' % ConfigGlob.get('DEFAULT', 'version_nb')))
138 #Si pas de fichiers de config utilisateur, on cree le repertoire
139 CreateIraDirectory(UserConfigPath, AppliPath)
140 #fichiers log pour windows (py2exe)
141 log = logging.getLogger('iramuteq')
142 fh = logging.FileHandler(os.path.join(UserConfigPath,'stdout.log'))
143 formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
144 fh.setFormatter(formatter)
146 if sys.platform != 'win32' and sys.platform != 'darwin':
147 ch = logging.StreamHandler()
148 ch.setFormatter(formatter)
150 log.setLevel(logging.INFO)
152 class writer(object):
153 def write(self, data):
154 if data.strip() != '' :
155 log.info('ERROR : %s' % data)
157 class printer(object) :
158 def write(self, data) :
159 if data.strip() != '' :
160 log.info('Print : %s' % data)
162 sys.stderr = writer()
163 sys.stdout = printer()
165 ConfigPath = ConstructConfigPath(UserConfigPath)
167 langues = {'french' : wx.LANGUAGE_FRENCH,
168 'english' : wx.LANGUAGE_ENGLISH,
169 'portuguese' : wx.LANGUAGE_PORTUGUESE,
170 'italian' : wx.LANGUAGE_ITALIAN,
171 'spanish' : wx.LANGUAGE_SPANISH
174 code_langues = {'french' : 'fr_FR',
176 'portuguese' : 'pt_PT',
182 'textroot' : 'textroot.png',
183 'alceste' : 'reinert.png',
184 'reinert' : 'reinert.png',
185 'corpus' : 'textcorpus.png',
186 'wordcloud' :'wordcloud.png',
188 'simitxt' : 'simitxt.png',
189 'clustersimitxt' :'clustersimitxt.png',
190 'clustercloud' : 'clustercloud.png',
192 'matroot' : 'matroot.png',
193 'matrix' : 'matrix.png',
194 'freq' : 'frequences.png',
195 'freqmulti' : 'frequences.png',
197 'chi2mcnemar' : 'chi2.png',
198 'reinertmatrix' : 'reinertmatrix.png',
199 'simimatrix' : 'simimatrix.png',
200 'simiclustermatrix' : 'simimatrix.png',
201 'proto' : 'proto.png',
203 'europress' : 'europress.png',
204 'factiva_xml' : 'factiva_xml.png',
205 'factiva_copy' : 'factiva_copy.png',
206 'factiva_mail': 'factiva_mail.png',
207 'iramuteq' : 'iraicone.png',
208 'subcorpusmeta' : 'subcorpusmeta.png',
209 'subcorpusthema' : 'subcorpusthema.png',
210 'preferences' : 'preferences.png',
211 'exportmetatable' : 'exportmetatable.png',
212 'importdmi' : 'twitter.png',
215 #####################################################################
217 class IraFrame(wx.Frame):
218 def __init__(self, parent, id= -1, title="", pos=wx.DefaultPosition,
219 size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE |
222 log.info('Starting... ' )
223 log.info('version : %s' % ConfigGlob.get('DEFAULT', 'version'))
224 wx.Frame.__init__(self, parent, id, title, pos, size, style)
226 self.AppliPath = AppliPath
227 self.images_path = os.path.join(AppliPath,'images')
228 self.UserConfigPath = UserConfigPath
229 #self.RscriptsPath = ConstructRscriptsPath(AppliPath)
230 self.RscriptsPath = PathOut(dirout=os.path.join(AppliPath, 'Rscripts'))
231 self.RscriptsPath.basefiles(RscriptsPath)
232 #self.DictPath = ConstructDicoPath(AppliPath)
233 self.DictPath = ConstructDicoPath(UserConfigPath)
234 self.ConfigGlob = ConfigGlob
235 self.ConfigPath = ConstructConfigPath(UserConfigPath)
236 self.pref = RawConfigParser()
237 #workaround for import problem
238 self.SimiFromCluster = SimiFromCluster
240 gettext.install('iramuteq', os.path.join(AppliPath,'locale'), unicode=True)
241 #langues = ['fr_FR', 'en', 'pt_PT']
245 for langue in code_langues :
246 self.preslangue[langue] = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=[code_langues[langue]])
248 #self.presLan_fr = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=['fr_FR'])
249 #self.presLan_en = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=['en'])
250 # tell FrameManager to manage this frame
251 #self._mgr = wx.aui.AuiManager()
252 self._mgr = aui.AuiManager()
253 self._mgr.SetManagedWindow(self)
256 #--------------------------------------------------------------------------------
257 self.images_analyses = images_analyses
258 for img in images_analyses :
259 self.images_analyses[img] = wx.Image(os.path.join(self.images_path, self.images_analyses[img]), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()
260 self.mb = wx.MenuBar()
262 file_menu = wx.Menu()
263 item = wx.MenuItem(file_menu, ID_OpenData, _(u"Open a matrix").decode('utf8'), _(u"Open a matrix").decode('utf8'))
264 #item.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN))
265 item.SetBitmap(self.images_analyses['matroot'])
266 file_menu.AppendItem(item)
268 item = wx.MenuItem(file_menu, ID_OpenText, _(u"Open a text corpus").decode('utf8'), _(u"Open a text corpus").decode('utf8'))
269 item.SetBitmap(self.images_analyses['textroot'])
270 file_menu.AppendItem(item)
272 item = wx.MenuItem(file_menu, ID_OnOpenAnalyse, _(u"Open an analysis").decode('utf8'), _(u"Open an analysis").decode('utf8'))
273 item.SetBitmap(self.images_analyses['iramuteq'])
274 file_menu.AppendItem(item)
276 item = wx.MenuItem(file_menu, ID_ImportTXM, _(u"Import from TXM").decode('utf8'), _(u"Import from TXM").decode('utf8'))
277 item.SetBitmap(self.images_analyses['TXM'])
278 file_menu.AppendItem(item)
280 item = wx.MenuItem(file_menu, ID_ImportEuro, _(u"Import from Europress").decode('utf8'), _(u"Import from Europress").decode('utf8'))
281 item.SetBitmap(self.images_analyses['europress'])
282 file_menu.AppendItem(item)
284 item = wx.MenuItem(file_menu, ID_importdmi, _(u"Import from DMI-TCAT (exp.)").decode('utf8'), _(u"Import from DMI-TCAT (exp.)").decode('utf8'))
285 item.SetBitmap(self.images_analyses['importdmi'])
286 file_menu.AppendItem(item)
288 item = wx.MenuItem(file_menu, ID_merge, _(u'Merge graphs').decode('utf8'), _(u'Merge graphs').decode('utf8'))
289 file_menu.AppendItem(item)
291 item = wx.MenuItem(file_menu, ID_merge_clusters, _(u'Corpus from merge clusters').decode('utf8'), _(u'Corpus from merge clusters').decode('utf8'))
292 file_menu.AppendItem(item)
294 menuFactiva = wx.Menu()
295 fact_from_xml = wx.MenuItem(menuFactiva, ID_Fact_xml, _(u"from xml").decode('utf8'))
296 fact_from_xml.SetBitmap(self.images_analyses['factiva_xml'])
297 fact_from_mail = wx.MenuItem(menuFactiva, ID_Fact_mail, _(u"from mail").decode('utf8'))
298 fact_from_mail.SetBitmap(self.images_analyses['factiva_mail'])
299 fact_from_txt = wx.MenuItem(menuFactiva, ID_Fact_copy, _(u"from copy/paste").decode('utf8'))
300 fact_from_txt.SetBitmap(self.images_analyses['factiva_copy'])
301 menuFactiva.AppendItem(fact_from_xml)
302 menuFactiva.AppendItem(fact_from_mail)
303 menuFactiva.AppendItem(fact_from_txt)
304 file_menu.AppendMenu(-1, _(u"Import from factiva").decode('utf8'), menuFactiva)
306 menuTools = wx.Menu()
307 splitvar = wx.MenuItem(menuTools, wx.ID_ANY, _(u"Split from variable").decode('utf8'))
308 extractmod = wx.MenuItem(menuTools, wx.ID_ANY, _(u"Extract mods").decode('utf8'))
309 extractthem = wx.MenuItem(menuTools, wx.ID_ANY, _(u"Extract thematics").decode('utf8'))
310 menuTools.AppendItem(splitvar)
311 menuTools.AppendItem(extractmod)
312 menuTools.AppendItem(extractthem)
313 self.ID_splitvar = splitvar.GetId()
314 self.ID_extractmod = extractmod.GetId()
315 self.ID_extractthem = extractthem.GetId()
316 file_menu.AppendMenu(-1, _(u"Tools").decode('utf8'), menuTools)
319 #item = wx.MenuItem(file_menu, ID_SaveTab, _(u"Save tab as...").decode('utf8'), _(u"Save tab as...").decode('utf8'))
320 #item.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_FILE_SAVE_AS))
321 #file_menu.AppendItem(item)
323 file_menu.Append(wx.ID_EXIT, _(u"Exit").decode('utf8'))
325 edit_menu = wx.Menu()
326 pref = wx.MenuItem(edit_menu, wx.ID_PREFERENCES, _(u'Preferences').decode('utf8'))
327 pref.SetBitmap(self.images_analyses['preferences'])
328 edit_menu.AppendItem(pref)
329 #edit_menu.Append(wx.ID_PREFERENCES, _(u'Preferences').decode('utf8'))
331 view_menu = wx.Menu()
332 home = wx.MenuItem(view_menu, ID_ACCEUIL, _(u"Home page").decode('utf8'))
333 home.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_GO_HOME, size = (16,16)))
334 view_menu.AppendItem(home)
335 #view_menu.Append(ID_ACCEUIL, _(u"Home page").decode('utf8'))
336 results = wx.MenuItem(view_menu, ID_RESULT, _(u'Show results').decode('utf8'))
337 results.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_LIST_VIEW, size = (16,16)))
338 view_menu.AppendItem(results)
339 #view_menu.Append(ID_RESULT, _(u'Show results').decode('utf8'))
340 #view_menu.AppendSeparator()
341 matrix_menu = wx.Menu()
342 matanalyses = [[ID_Freq, _(u"Frequencies").decode('utf8'), 'freq'],
343 [ID_FreqMulti, _(u"Multiple Frequencies").decode('utf8'), 'freqmulti'],
344 [ID_Chi2, _(u"Chi2").decode('utf8'), 'chi2'],
345 [ID_Chi2mc, _(u"Chi2 McNemar").decode('utf8'), 'chi2mcnemar'],
346 {'name' : _(u"Clustering").decode('utf8'),
347 'content' : [[ID_CHDReinert, _(u"Reinert's Method").decode('utf8'), 'reinertmatrix']]},
348 [ID_SIMI, _(u"Similarities Analysis").decode('utf8'), 'simimatrix'],
349 [ID_proto, _(u"Prototypical Analysis").decode('utf8'), 'proto'],
350 [ID_Splitfromvar, _(u"Split from variable").decode('utf8'), 'subcorpusmeta'],
353 for analyse in matanalyses :
354 if not isinstance(analyse, dict) :
355 item = wx.MenuItem(matrix_menu, analyse[0], analyse[1])
356 item.SetBitmap(self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)))
357 matrix_menu.AppendItem(item)
360 for subana in analyse['content'] :
361 item = wx.MenuItem(nmenu, subana[0], subana[1])
362 item.SetBitmap(self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)))
363 nmenu.AppendItem(item)
364 matrix_menu.AppendMenu(-1, analyse['name'], nmenu)
365 #item = wx.MenuItem(matrix_menu, ID_Freq, _(u"Frequencies").decode('utf8'))
366 #item.SetBitmap(self.images_analyses['freq'])
367 #matrix_menu.AppendItem(item)
368 #matrix_menu.Append(ID_Freq, _(u"Frequencies").decode('utf8'))
369 #item = wx.MenuItem(matrix_menu, ID_Freq, _(u"Multiple Frequencies").decode('utf8'))
370 #item.SetBitmap(self.images_analyses['freqmulti'])
371 #matrix_menu.Append(ID_FreqMulti, _(u'Multiple frequencies').decode('utf8'))
372 #matrix_menu.AppendItem(item)
373 #matrix_menu.Append(ID_Chi2, _(u"Chi2").decode('utf8'))
374 #matrix_menu.Append(ID_Student, u"t de Student")
375 #menu_classif = wx.Menu()
376 #menu_classif.Append(ID_CHDReinert, _(u"Reinert's Method").decode('utf8'))
377 #menu_classif.Append(ID_CHDSIM, u"Par matrice des distances")
378 #matrix_menu.AppendMenu(-1, _(u"Clustering").decode('utf8'), menu_classif)
379 #matrix_menu.Append(ID_AFCM, u"AFCM")
380 #matrix_menu.Append(ID_SIMI, _(u"Similarities Analysis").decode('utf8'))
381 #matrix_menu.Append(ID_proto, _(u"Prototypical Analysis").decode('utf8'))
382 ID_RCODE = wx.NewId()
383 #matrix_menu.Append(ID_RCODE, u"Code R...")
384 #menu_splittab = wx.Menu()
385 #ID_SPLITVAR = wx.NewId()
386 #splitvar = wx.MenuItem(menu_splittab, ID_SPLITVAR, _(u"Split from variable").decode('utf8'))
387 #menu_splittab.AppendItem(splitvar)
388 #matrix_menu.AppendMenu(-1, _(u"Split matrix").decode('utf8'), menu_splittab)
389 self.matrix_menu = matrix_menu
391 text_menu = wx.Menu()
392 analyses_text = [[ID_TEXTSTAT, _(u"Statistics").decode('utf8'), 'stat'],
393 [ID_ASLEX, _(u"Specificities and CA").decode('utf8'), 'spec'],
394 [ID_labbe, _(u"Labbe Distance").decode('utf8'),'labbe'],
395 {'name' : _(u"Clustering").decode('utf8'),
396 'content' : [[ID_TEXTREINERT, _(u"Reinert's Method").decode('utf8'), 'alceste']]},
397 [ID_SimiTxt, _(u"Similarities Analysis").decode('utf8'), 'simitxt'],
398 [ID_WC, _(u"WordCloud").decode('utf8'), 'wordcloud'],
399 {'name' : _(u"Sub corpus").decode('utf8'),
400 'content' : [[ID_Subtxtfrommeta, _(u'Sub corpus from metadata').decode('utf8'), 'subcorpusmeta'],
401 [ID_Subtxtfromthem, _(u'Sub corpus from thematic').decode('utf8'), 'subcorpusthema']]},
402 [ID_exportmeta, _(u"Export metadata table").decode('utf8'), 'exportmetatable'],
405 for analyse in analyses_text :
406 if not isinstance(analyse, dict) :
407 item = wx.MenuItem(text_menu, analyse[0], analyse[1])
408 item.SetBitmap(self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)))
409 text_menu.AppendItem(item)
412 for subana in analyse['content'] :
413 item = wx.MenuItem(nmenu, subana[0], subana[1])
414 item.SetBitmap(self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)))
415 nmenu.AppendItem(item)
416 text_menu.AppendMenu(-1, analyse['name'], nmenu)
417 #text_menu.Append(ID_CHECKCORPUS, u"Vérifier le corpus")
418 # text_menu.Append(ID_TEXTSTAT, _(u"Statistics").decode('utf8'))
419 # text_menu.Append(ID_ASLEX, _(u"Specificities and CA").decode('utf8'))
420 # #text_menu.Append(ID_TEXTAFCM, u"AFC sur UCI / Vocabulaire")
421 # menu_classiftxt = wx.Menu()
422 # menu_classiftxt.Append(ID_TEXTREINERT, _(u"Reinert's Method").decode('utf8'))
423 # #menu_classiftxt.Append(ID_TEXTPAM, u"Par matrice des distances")
424 # text_menu.AppendMenu(-1, _(u"Clustering").decode('utf8'), menu_classiftxt)
425 # text_menu.Append(ID_SimiTxt, _(u"Similarities Analysis").decode('utf8'))
427 # text_menu.Append(ID_WC, _(u"WordCloud").decode('utf8'))
428 self.text_menu = text_menu
430 help_menu = wx.Menu()
431 about = wx.MenuItem(help_menu, wx.ID_ABOUT, _(u"About...").decode('utf8'))
432 about.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_INFORMATION, size = (16,16)))
433 help_menu.AppendItem(about)
434 #help_menu.Append(wx.ID_ABOUT, _(u"About...").decode('utf8'))
435 help = wx.MenuItem(help_menu, wx.ID_HELP, _(u"Online help...").decode('utf8'))
436 help.SetBitmap(wx.ArtProvider_GetBitmap(wx.ART_HELP, size = (16,16)))
437 help_menu.AppendItem(help)
438 #help_menu.Append(wx.ID_HELP, _(u"Online help...").decode('utf8'))
440 self.mb.Append(file_menu, _(u"File").decode('utf8'))
441 self.mb.Append(edit_menu, _(u"Edition").decode('utf8'))
442 self.mb.Append(view_menu, _(u"View").decode('utf8'))
443 self.mb.Append(matrix_menu, _(u"Matrix analysis").decode('utf8'))
444 self.mb.Append(text_menu, _(u"Text analysis").decode('utf8'))
445 self.mb.Append(help_menu, _(u"Help").decode('utf8'))
447 self.SetMenuBar(self.mb)
448 #--------------------------------------------------------------------
449 self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP)
450 self.statusbar.SetStatusWidths([-2, -3])
451 self.statusbar.SetStatusText(_(u"Ready").decode('utf8'), 0)
452 self.statusbar.SetStatusText(_(u"Welcome").decode('utf8'), 1)
454 # min size for the frame itself isn't completely done.
455 # see the end up FrameManager::Update() for the test
456 # code. For now, just hard code a frame minimum size
457 self.SetMinSize(wx.Size(400, 400))
459 # create some toolbars
460 tb1 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
461 wx.TB_FLAT | wx.TB_NODIVIDER)
462 tb1.SetToolBitmapSize(wx.Size(16, 16))
463 tb1.AddLabelTool(ID_OpenData, "OpenData", self.images_analyses['matroot'], shortHelp=_(u"Matrix").decode('utf8'), longHelp=_(u"Open a matrix").decode('utf8'))
465 tb1.AddLabelTool(ID_OpenText, "OpenText", self.images_analyses['textroot'], shortHelp=_(u"Text").decode('utf8'), longHelp=_(u"Open a text corpus").decode('utf8'))
467 tb1.AddLabelTool(ID_OnOpenAnalyse, "OpenAnalyse", self.images_analyses['iramuteq'], shortHelp= _(u"Open an analysis").decode('utf8'), longHelp=_(u"Open an analysis").decode('utf8'))
469 tb1.AddLabelTool(ID_ImportTXM, "ImportTXM", self.images_analyses['TXM'], shortHelp= _(u"Import from TXM").decode('utf8'), longHelp=_(u"Import from TXM").decode('utf8'))
471 tb1.AddLabelTool(ID_ImportEuro, "ImportEuro", self.images_analyses['europress'], shortHelp= _(u"Import from Europress").decode('utf8'), longHelp=_(u"Import from Europress").decode('utf8'))
473 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'))
475 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'))
476 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'))
477 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'))
479 tb1.AddLabelTool(wx.ID_PREFERENCES, "Preferences", self.images_analyses['preferences'], shortHelp= _(u"Preferences").decode('utf8'), longHelp=_(u"Preferences").decode('utf8'))
481 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'))
482 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'))
485 tb_text = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
486 wx.TB_FLAT | wx.TB_NODIVIDER)
487 for analyse in analyses_text :
488 if not isinstance(analyse, dict) :
489 tb_text.AddLabelTool(analyse[0], analyse[1], self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)), shortHelp = analyse[1], longHelp = analyse[1])
491 for subana in analyse['content'] :
492 tb_text.AddLabelTool(subana[0], subana[1], self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)), shortHelp = subana[1], longHelp = subana[1])
495 tb_mat = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
496 wx.TB_FLAT | wx.TB_NODIVIDER)
497 for analyse in matanalyses :
498 if not isinstance(analyse, dict) :
499 tb_mat.AddLabelTool(analyse[0], analyse[1], self.images_analyses.get(analyse[2], wx.EmptyBitmap(16,16)), shortHelp = analyse[1], longHelp = analyse[1])
501 for subana in analyse['content'] :
502 tb_mat.AddLabelTool(subana[0], subana[1], self.images_analyses.get(subana[2], wx.EmptyBitmap(16,16)), shortHelp = subana[1], longHelp = subana[1])
505 tb_help = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
506 wx.TB_FLAT | wx.TB_NODIVIDER)
507 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'))
508 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'))
510 #------------------------------------------------------------------------------------------------
512 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)
514 #self._mgr.AddPane(self.text_ctrl_txt, wx.aui.AuiPaneInfo().
515 # Name("Text").CenterPane())
516 self._mgr.AddPane(self.text_ctrl_txt, aui.AuiPaneInfo().
517 Name("Text").CenterPane())
518 #self._mgr.AddPane(IntroPanel(self), wx.aui.AuiPaneInfo().Name("Intro_Text").
520 self._mgr.AddPane(IntroPanel(self), aui.AuiPaneInfo().Name("Intro_Text").
522 #if not os.path.exists(os.path.join(UserConfigPath, 'history.db')) :
523 # with open(os.path.join(UserConfigPath, 'history.db'), 'w') as f :
525 self.history = History(os.path.join(UserConfigPath, 'history.db'))
526 #self.history.dostat()
527 self.tree = LeftTree(self)
528 self._mgr.AddPane(self.tree, aui.AuiPaneInfo().Name("lefttree").Caption(_(u"Historic").decode('utf8')).
529 Left().MinSize(wx.Size(200,500)).Layer(1).Position(1).CloseButton(False).MaximizeButton(True).
530 MinimizeButton(True))
532 #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)
533 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)
534 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
535 self.nb.SetAGWWindowStyleFlag(notebook_flags)
536 self.nb.SetArtProvider(aui.ChromeTabArt())
537 #self.nb.SetArtProvider(aui.VC8TabArt())
538 #self.nb.parent = self
539 #self._notebook_style = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | wx.NO_BORDER
540 #self._mgr.AddPane(self.nb, wx.aui.AuiPaneInfo().
541 # Name("Tab_content").
543 self._mgr.AddPane(self.nb, aui.AuiPaneInfo().
547 #self._mgr.AddPane(self.Sheet, wx.aui.AuiPaneInfo().Name("Data").CenterPane())
548 #self._mgr.AddPane(self.Sheet, aui.AuiPaneInfo().Name("Data").CenterPane())
549 self.nb.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnCloseTab)
550 self.nb.Bind(aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
551 # add the toolbars to the manager
553 #self._mgr.AddPane(tb1, wx.aui.AuiPaneInfo().
554 # Name("tb1").Caption("Fichiers").
555 # ToolbarPane().Top().
556 # LeftDockable(False).RightDockable(False))
557 self._mgr.AddPane(tb1, aui.AuiPaneInfo().
558 Name("tb1").Caption("Fichiers").
560 LeftDockable(True).RightDockable(False))
562 self._mgr.AddPane(tb_text, aui.AuiPaneInfo().
563 Name("tb_text").Caption("analyse_text").
565 LeftDockable(True).RightDockable(False))
567 self._mgr.AddPane(tb_mat, aui.AuiPaneInfo().
568 Name("tb_mat").Caption("analyse_matrix").
570 LeftDockable(True).RightDockable(False))
572 self._mgr.AddPane(tb_help, aui.AuiPaneInfo().
573 Name("tb_help").Caption("help").
575 LeftDockable(True).RightDockable(False))
577 self._mgr.GetPane('tb_text').Hide()
578 self._mgr.GetPane('tb_mat').Hide()
580 self.ShowAPane("Intro_Text")
581 self._mgr.GetPane("lefttree").Show()
582 self._mgr.GetPane("classif_tb").Hide()
583 # "commit" all changes made to FrameManager
586 # Show How To Use The Closing Panes Event
587 ##################################################################
588 self.Bind(wx.EVT_MENU, self.OnAcceuil, id=ID_ACCEUIL)
589 self.Bind(wx.EVT_MENU, self.ShowTab, id=ID_RESULT)
590 self.Bind(wx.EVT_MENU, self.OnOpenData, id=ID_OpenData)
591 self.Bind(wx.EVT_MENU, self.OnOpenText, id=ID_OpenText)
592 self.Bind(wx.EVT_MENU, self.OnOpenAnalyse, id=ID_OnOpenAnalyse)
593 self.Bind(wx.EVT_MENU, self.import_factiva_xml, fact_from_xml)
594 self.Bind(wx.EVT_MENU, self.import_factiva_mail, fact_from_mail)
595 self.Bind(wx.EVT_MENU, self.import_factiva_txt, fact_from_txt)
596 self.Bind(wx.EVT_MENU, self.ExtractTools, splitvar)
597 self.Bind(wx.EVT_MENU, self.ExtractTools, extractmod)
598 self.Bind(wx.EVT_MENU, self.ExtractTools, extractthem)
599 self.Bind(wx.EVT_MENU, self.OnFreq, id=ID_Freq)
600 self.Bind(wx.EVT_MENU, self.OnFreqMulti, id=ID_FreqMulti)
601 self.Bind(wx.EVT_MENU, self.OnChi2, id=ID_Chi2)
602 self.Bind(wx.EVT_MENU, self.OnChi2McNemar, id=ID_Chi2mc)
603 self.Bind(wx.EVT_MENU, self.OnStudent, id=ID_Student)
604 self.Bind(wx.EVT_MENU, self.OnCHDSIM, id=ID_CHDSIM)
605 self.Bind(wx.EVT_MENU, self.OnCHDReinert, id=ID_CHDReinert)
606 self.Bind(wx.EVT_MENU, self.OnAFCM, id=ID_AFCM)
607 self.Bind(wx.EVT_MENU, self.OnProto, id=ID_proto)
608 self.Bind(wx.EVT_MENU, self.OnSplitVar, id = ID_Splitfromvar)
609 #self.Bind(wx.EVT_MENU, self.OnRCode, id=ID_RCODE)
610 #self.Bind(wx.EVT_MENU, self.OnSplitVar, id=ID_SPLITVAR)
611 #self.Bind(wx.EVT_MENU, self.OnCheckcorpus, id = ID_CHECKCORPUS)
612 self.Bind(wx.EVT_MENU, self.OnTextStat, id=ID_TEXTSTAT)
613 self.Bind(wx.EVT_MENU, self.OnTextSpec, id=ID_ASLEX)
614 self.Bind(wx.EVT_MENU, self.OnTextLabbe, id=ID_labbe)
615 self.Bind(wx.EVT_MENU, self.OnTextAfcm, id=ID_TEXTAFCM)
616 self.Bind(wx.EVT_MENU, self.OnTextReinert, id=ID_TEXTREINERT)
617 self.Bind(wx.EVT_MENU, self.OnPamSimple, id=ID_TEXTPAM)
618 self.Bind(wx.EVT_MENU, self.OnSimiTxt, id=ID_SimiTxt)
619 self.Bind(wx.EVT_MENU, self.OnWordCloud, id=ID_WC)
620 self.Bind(wx.EVT_MENU, self.OnSubText, id = ID_Subtxtfrommeta)
621 self.Bind(wx.EVT_MENU, self.OnSubText, id = ID_Subtxtfromthem)
622 self.Bind(wx.EVT_MENU, self.OnSimiTab, id=ID_SIMI)
623 self.Bind(wx.EVT_MENU, self.OnExit, id=wx.ID_EXIT)
624 #self.Bind(wx.EVT_MENU, self.OnSaveTabAs, id=ID_SaveTab)
625 self.Bind(wx.EVT_MENU, self.OnAbout, id=wx.ID_ABOUT)
626 self.Bind(wx.EVT_MENU, self.OnHelp, id=wx.ID_HELP)
627 self.Bind(wx.EVT_MENU, self.OnPref, id=wx.ID_PREFERENCES)
628 self.Bind(wx.EVT_MENU, self.OnImportTXM, id=ID_ImportTXM)
629 self.Bind(wx.EVT_MENU, self.OnImportEuropress, id=ID_ImportEuro)
630 self.Bind(wx.EVT_MENU, self.OnImportDMI, id=ID_importdmi)
631 self.Bind(wx.EVT_MENU, self.OnExportMeta, id=ID_exportmeta)
632 self.Bind(wx.EVT_MENU, self.OnMergeGraph, id = ID_merge)
633 self.Bind(wx.EVT_MENU, self.OnMergeClusters, id = ID_merge_clusters)
634 self.Bind(wx.EVT_CLOSE, self.OnClose)
635 ##################################################################
636 flags = self._mgr.GetAGWFlags()
637 #flags &= ~wx.aui.AUI_MGR_TRANSPARENT_HINT
638 #flags &= ~wx.aui.AUI_MGR_VENETIAN_BLINDS_HINT
639 #flags &= ~wx.aui.AUI_MGR_RECTANGLE_HINT
640 flags &= ~(aui.AUI_MGR_RECTANGLE_HINT | aui.AUI_MGR_ALLOW_FLOATING)
641 self._mgr.SetAGWFlags(self._mgr.GetAGWFlags() ^ (aui.AUI_MGR_RECTANGLE_HINT | aui.AUI_MGR_ALLOW_FLOATING))
642 self._mgr.GetArtProvider().SetMetric(aui.AUI_DOCKART_GRADIENT_TYPE, aui.AUI_GRADIENT_HORIZONTAL)
643 self.GetDockArt().SetColor(aui.AUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR, "#00FFF9")
646 self._icon = wx.Icon(os.path.join(ImagePath, "iraicone.ico"), wx.BITMAP_TYPE_ICO)
647 self.SetIcon(self._icon)
648 ##########################
650 self.input_path = [False]
651 self.TEMPDIR = tempfile.mkdtemp('iramuteq')
652 self.FileTabList = []
658 self.g_header = False
665 self.SysEncoding = sys.getdefaultencoding()
666 self.syscoding = sys.getdefaultencoding()
667 #print 'SysEncoding',self.SysEncoding
668 if self.SysEncoding == 'mac-roman' : self.SysEncoding = 'MacRoman'
671 ##############################################################@
672 self.ShowMenu('view', True)
673 self.ShowMenu('matrix', False)
674 self.ShowMenu('text', False)
685 def finish_init(self) :
687 self.pref.read(self.ConfigPath['preferences'])
690 self.pref.read(self.ConfigPath['preferences'])
697 self.pref.read(self.ConfigPath['preferences'])
699 self.sound = self.pref.getboolean('iramuteq', 'sound')
700 self.check_update = self.pref.getboolean('iramuteq', 'checkupdate')
701 self.version = ConfigGlob.get('DEFAULT', 'version')
702 #configuration des chemins de R
703 self.PathPath = ConfigParser()
704 self.PathPath.read(ConfigPath['path'])
706 if not CheckRPath(self.PathPath) :
707 if sys.platform == 'win32':
708 BestRPath = FindRPAthWin32()
710 BestRPath = FindRPathNix()
712 self.PathPath.set('PATHS', 'rpath', BestRPath)
713 with open(ConfigPath['path'], 'w') as f :
714 self.PathPath.write(f)
718 self.RPath = self.PathPath.get('PATHS', 'rpath')
721 if not RLibsAreInstalled(self) :
724 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'),
725 _(u"If R is installed, report its path in Preferences.").decode('utf8'),
726 _(u"IRaMuTeQ does not work without R.").decode('utf8')])
727 dlg = wx.MessageDialog(self, msg, _(u"Problem").decode('utf8'), wx.OK | wx.ICON_WARNING)
729 if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
733 def setlangue(self) :
734 self.pref.read(self.ConfigPath['preferences'])
736 guilangue = self.pref.get('iramuteq', 'guilanguage')
738 guilangue = DefaultConf.get('iramuteq', 'guilanguage')
739 self.preslangue.get(guilangue, 'english').install()
741 def OnVerif(self, evt) :
742 pack = CheckRPackages(self)
744 dlg = wx.MessageDialog(self, _(u"Installation OK").decode('utf8'), _(u"Installation").decode('utf8'), wx.OK | wx.ICON_INFORMATION | wx.STAY_ON_TOP)
746 if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
749 def ShowMenu(self, menu, Show=True):
753 self._mgr.GetPane('tb_text').Show()
755 self._mgr.GetPane('tb_text').Hide()
756 elif menu == 'matrix' :
759 self._mgr.GetPane('tb_mat').Show()
761 self._mgr.GetPane('tb_mat').Hide()
762 elif menu == 'view' :
767 #menu_pos = self.mb.FindMenu(menu)
768 if not menu_pos is None :
769 self.mb.EnableTop(menu_pos, Show)
770 self.mb.UpdateMenus()
773 #--------------------------------------------------------------------
774 def OnClose(self, event):
776 with open(self.ConfigPath['path'], 'w') as f :
777 self.PathPath.write(f)
782 def OnOpenData(self, event):
783 inputname, self.input_path = OnOpen(self, "Data")
785 #filename = self.input_path[0]
786 self.tableau = Tableau(self,os.path.abspath(self.input_path[0]))
787 val = get_table_param(self, self.input_path[0])
789 busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self)
792 self.tableau.make_content()
793 OpenAnalyse(self, self.tableau.parametres)
794 self.tree.OnItemAppend(self.tableau.parametres)
799 #self.tableau.show_tab()
801 def OnOpenAnalyse(self, event):
802 self.AnalysePath = OnOpen(self, "Analyse")
803 if self.AnalysePath :
804 OpenAnalyse(self, self.AnalysePath[1][0], True)
805 self.ShowMenu('view')
807 def OnOpenText(self, event):
808 inputname, self.input_path = OnOpen(self, "Texte")
809 self.filename = self.input_path[0]
813 def OnSubText(self, evt, corpus = None, parametres = None):
815 corpus = self.tree.getcorpus()
816 if evt.GetId() == ID_Subtxtfrommeta :
817 parametres = {'frommeta' : True}
818 elif evt.GetId() == ID_Subtxtfromthem :
819 parametres = {'fromtheme' : True}
820 builder = SubBuilder(self, corpus, parametres)
821 if builder.res == wx.ID_OK :
822 busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self)
824 corpus = builder.doanalyse()
825 self.history.add(corpus.parametres)
826 OpenAnalyse(self, corpus.parametres)
827 self.tree.OnItemAppend(corpus.parametres)
831 builder = Builder(self, 5)
832 if builder.res == wx.ID_OK :
834 corpus = builder.doanalyse()
835 self.history.add(corpus.parametres)
836 self.tree.OnItemAppend(corpus.parametres)
837 OpenAnalyse(self, corpus.parametres)
839 builder.dlg.Destroy()
843 keepGoing = builder.dlg.Update(count, u"Lecture du fichier")
844 self.ShowMenu('view')
845 self.ShowMenu('text')
846 self.ShowMenu('matrix', False)
851 keepGoing = builder.dlg.Update(count, u"Chargement du dictionnaire")
852 builder.dlg.Destroy()
854 def OnExit(self, event):
857 def OnAbout(self, event):
858 info = wx.AboutDialogInfo()
859 info.Name = ConfigGlob.get('DEFAULT', 'name')
860 info.Version = ConfigGlob.get('DEFAULT', 'version')
861 info.Copyright = ConfigGlob.get('DEFAULT', 'copyright')
862 info.Translators = ConfigGlob.get('DEFAULT', 'translators').decode('utf8').split(';')
863 info.Description = u"""
864 Interface de R pour les Analyses Multidimensionnelles
865 de Textes et de Questionnaires
868 construit avec des logiciels libres.
874 info.WebSite = ("http://www.iramuteq.org", u"Site web IRaMuTeQ")
875 dev = ConfigGlob.get('DEFAULT', 'dev').decode('utf8').split(';')
876 info.Developers = dev
877 info.License = u"""Iramuteq est un logiciel libre ; vous pouvez le diffuser et/ou le modifier
878 suivant les termes de la Licence Publique Générale GNU telle que publiée
879 par la Free Software Foundation ; soit la version 2 de cette licence,
880 soit (à votre convenance) une version ultérieure.
882 Iramuteq est diffusé dans l'espoir qu'il sera utile,
883 mais SANS AUCUNE GARANTIE ; sans même une garantie implicite
884 de COMMERCIALISATION ou d'ADÉQUATION À UN USAGE PARTICULIER.
885 Voyez la Licence Publique Générale GNU pour plus de détails.
887 Vous devriez avoir reçu une copie de la Licence Publique Générale GNU
888 avec Iramuteq ; sinon, veuillez écrire à la Free Software Foundation,
889 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis."""
892 def GetDockArt(self):
893 return self._mgr.GetArtProvider()
898 def OnPageChanged(self, event) :
899 new = event.GetSelection()
900 nobject = event.GetEventObject()
901 parent = nobject.GetParent()
902 if isinstance(parent, IraFrame) :
903 npage = self.nb.GetPage(new)
904 if 'parametres' in dir(npage) :
905 self.tree.GiveFocus(uuid=npage.parametres['uuid'])
906 if npage.parametres.get('matrix', False) :
907 self.ShowMenu('text', False)
908 self.ShowMenu('matrix', True)
909 elif npage.parametres.get('corpus', False) :
910 self.ShowMenu('text')
911 self.ShowMenu('matrix', False)
913 def OnCloseTab(self, evt):
914 #log.info('Closing tab %s' % str(evt.GetEventObject()))
915 ctrl = evt.GetEventObject()
916 if isinstance(ctrl.GetParent(), aui.AuiNotebook) or isinstance(ctrl.GetParent(), wx.Panel):
920 page = self.nb.GetPage(self.nb.GetSelection())
921 if 'parametres' in dir(page) and isinstance(ctrl.GetParent(), IraFrame) :
922 self.history.rmtab(page.parametres)
923 self.tree.CloseItem(uuid = page.parametres['uuid'])
924 TabTitle = self.nb.GetPageText(self.nb.GetSelection())
926 if self.nb.GetPageCount() == 1 and not notebook :
929 def LastTabClose(self) :
930 if self.nb.GetPageCount() == 1 :
932 self.ShowAPane("Text")
934 self.ShowAPane("Data")
936 self.ShowAPane("Intro_Text")
938 def GetStartPosition(self):
942 pt = self.ClientToScreen(wx.Point(0, 0))
944 return wx.Point(pt.x + x, pt.y + x)
946 def ShowAPane(self, panel):
947 for pane in self._mgr.GetAllPanes() :
948 if not pane.IsToolbar() and pane.name != 'lefttree':
950 self._mgr.GetPane(panel).Show()
953 def OnAcceuil(self, event):
954 self.ShowAPane(u"Intro_Text")
957 def CreateHTMLCtrl(self):
958 ctrl = wx.html.HtmlWindow(self, -1, wx.DefaultPosition, wx.Size(400, 300))
959 if "gtk2" in wx.PlatformInfo:
960 ctrl.SetStandardFonts()
961 ctrl.SetPage(u"text")
964 def ShowTab(self, evt):
965 self.ShowAPane("Tab_content")
967 ################################################################
969 ################################################################
970 def analyse_matrix(self, analyse, analyse_type = '', matrix = None, parametres = None, dlgnb = 1):
972 matrix = self.tree.getmatrix()
973 if parametres is not None :
974 parametres['type'] = analyse_type
976 parametres = {'type' : analyse_type}
978 #print 'plus de bug@@@@@@@@@@@@@@@@@@@@@@'
979 analyse(self, matrix, parametres = parametres, dlg = dlgnb)
983 def OnFreq(self, event, matrix = None):
984 self.analyse_matrix(Frequences, analyse_type = 'freq', matrix = matrix, dlgnb = 3)
986 def OnFreqMulti(self, event, matrix = None):
987 self.analyse_matrix(FreqMultiple, analyse_type = 'freqmulti', matrix = matrix, dlgnb = 3)
989 def OnChi2(self, event, matrix = None):
990 self.analyse_matrix(ChiSquare, matrix = matrix, analyse_type = 'chi2', dlgnb = 3)
992 def OnChi2McNemar(self, event, matrix = None):
993 self.analyse_matrix(McNemar, matrix = matrix, analyse_type = 'chi2mcnemar', dlgnb = 3)
995 def OnSimiTab(self, event, matrix = None):
996 self.analyse_matrix(DoSimi, matrix = matrix, analyse_type = 'simimatrix', dlgnb = 5)
998 def OnCHDReinert(self, event, matrix = None):
1000 # matrix = self.tree.getmatrix()
1001 #AnalyseQuest(self, matrix, parametres = {'type' : 'reinertmatrix'}, dlg = 3)
1002 self.analyse_matrix(AnalyseQuest, matrix = matrix, analyse_type = 'reinertmatrix', dlgnb = 5)
1004 def OnStudent(self, event):
1010 def OnRCode(self, event):
1016 def OnCHDSIM(self, event):
1018 # print 'ATTENTION!!!!'
1019 chdsim = ChdCluster(self)
1020 if chdsim.val == wx.ID_OK:
1025 # def OnCHDReinert(self, event):
1027 # # print('PLUS DE BUG SUR ALCESTE QUESTIONNAIRE')
1028 # self.quest = AnalyseQuest(self)
1029 # if self.quest.val == wx.ID_OK:
1033 def OnMergeGraph(self, evt):
1035 AnalyseMerge(self, {'type': 'merge', 'fileout' : '/tmp/test.txt'}, dlg = 5)
1037 def OnEliminate(self, corpus, parametres) :
1040 def OnMergeClusters(self, evt) :
1041 builder = MergeClusters(self, {})
1042 if builder.res == wx.ID_OK :
1043 busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self)
1045 corpus = builder.doanalyse()
1046 self.history.add(corpus.parametres)
1047 OpenAnalyse(self, corpus.parametres)
1048 self.tree.OnItemAppend(corpus.parametres)
1051 def OnProto(self, evt, matrix = None) :
1052 self.analyse_matrix(Prototypical, matrix = matrix, analyse_type = 'proto', dlgnb = 3)
1053 #Prototypical(self, {'type' : 'proto'})
1055 def OnSplitVar(self, evt, matrix = None):
1057 matrix = self.tree.getmatrix()
1058 self.analyse_matrix(SplitMatrixFromVar, matrix = matrix, analyse_type = 'splitvar', parametres = {'pathout': matrix.pathout.dirout}, dlgnb = 3)
1059 #matrix = self.tree.getmatrix()
1062 def OnSimiTxt(self, evt, corpus = None) :
1063 # print 'PLUS DE BUG SUR SIMITXT'
1065 #self.Text = SimiTxt(self)
1067 corpus = self.tree.getcorpus()
1068 self.Text = SimiTxt(self, corpus, parametres = {'type': 'simitxt'}, dlg = 3)
1069 if self.Text.val == wx.ID_OK :
1074 def OnWordCloud(self, evt, corpus = None) :
1075 # print 'PLUS DE BUG SUR WORDCLOUD'
1078 corpus = self.tree.getcorpus()
1079 self.Text = WordCloud(self, corpus, parametres = {'type' : 'wordcloud'}, dlg = 3)
1080 if self.Text.val == wx.ID_OK :
1085 def OnClusterCloud(self, corpus, parametres = None) :
1086 self.Text = ClusterCloud(self, corpus, parametres = parametres, dlg = 3)
1088 def OnAFCM(self, event):
1094 def OnTextStat(self, event, corpus = None):
1095 #print 'PAS DE BUG SUR TEXT STAT'
1098 corpus = self.tree.getcorpus()
1099 self.Text = Stat(self, corpus, parametres = {'type': 'stat'}, dlg = 7)
1101 if self.Text.val == wx.ID_OK :
1106 def OnTextSpec(self, event, corpus = None):
1108 #self.Text = AsLexico(self)
1109 #print('ATTENTION : PLUS DE BUG SUR LEXICO')
1111 corpus = self.tree.getcorpus()
1112 self.Text = Lexico(self, corpus, parametres = {'type' : 'spec'}, dlg = 3)
1113 if self.Text.val == wx.ID_OK :
1118 def OnTextLabbe(self, event, corpus = None):
1121 corpus = self.tree.getcorpus()
1122 self.Text = DistLabbe(self, corpus, parametres = {'type' : 'labbe'}, dlg = 3)
1123 if self.Text.val == wx.ID_OK :
1129 def OnTextAfcm(self, event):
1136 def import_factiva_xml(self,event):
1138 ImportFactiva(self, 'xml')
1142 def import_factiva_mail(self, evt) :
1144 ImportFactiva(self, 'mail')
1148 def import_factiva_txt(self, evt) :
1150 ImportFactiva(self, 'txt')
1154 def OnImportTXM(self, evt) :
1156 ImportFactiva(self, 'txm')
1160 def OnImportEuropress(self, evt) :
1162 ImportFactiva(self, 'euro')
1166 def OnImportDMI(self, evt):
1169 def OnExportMeta(self, evt, corpus = None):
1171 corpus = self.tree.getcorpus()
1173 ExportMetaTable(self, corpus)
1177 def ExtractTools(self, evt) :
1179 if ID == self.ID_splitvar :
1180 Extract(self, 'splitvar')
1181 elif ID == self.ID_extractmod :
1182 Extract(self, 'mods')
1183 elif ID == self.ID_extractthem :
1184 Extract(self, 'them')
1186 def OnTextReinert(self, event, corpus = None):
1188 #print('ATTENTION : PLUS DE BUG SUR ALCESTE')
1189 #RunAnalyse(self, corpus, Alceste, OptAlceste)
1191 corpus = self.tree.getcorpus()
1192 self.Text = Reinert(self, corpus, parametres = {'type': 'alceste'}, dlg = 6)
1193 if self.Text.val == wx.ID_OK:
1198 def OnPamSimple(self, event, corpus = None):
1201 corpus = self.tree.getcorpus()
1202 self.Text = AnalysePam(self, corpus, parametres = {'type' : 'pamtxt'}, dlg = 6)
1203 if self.Text.val == wx.ID_OK:
1208 def SimiCluster(self, parametres = {}, fromprof = False, tableau = None) :
1209 self.analyse_matrix(DoSimi, parametres = parametres, analyse_type = 'simiclustermatrix', matrix = tableau, dlgnb = 5)
1211 # def OnSimi(self,evt):
1213 #print 'ATTENTION !!!! VERGES'
1214 #print 'PLUS DE BUG SUR SIMI'
1215 # self.res = DoSimi(self, param = None)
1216 #self.res = Verges(self)
1217 # if self.res.val == wx.ID_OK :
1221 #################################################################
1223 def OnHelp(self, event):
1224 webbrowser.open('http://www.iramuteq.org/documentation')
1226 def OnPref(self, event):
1227 dlg = PrefDialog(self)
1228 dlg.CenterOnParent()
1229 self.val = dlg.ShowModal()
1233 if self.check_update:
1236 print 'pas de verif'
1238 #CheckRPackages(self)
1240 def OnOpenFromCmdl(self):
1242 if options.filename :
1243 if os.path.exists(options.filename):
1244 self.filename = os.path.abspath(options.filename)
1248 if os.path.exists(os.path.realpath(args[0])):
1249 self.filename = os.path.abspath(os.path.realpath(args[0]))
1255 if os.path.splitext(self.filename)[1] in ['.csv', '.xls', '.ods']:
1256 self.tableau = Tableau(self, self.filename)
1257 val = get_table_param(self, self.filename)
1258 if val == wx.ID_OK :
1259 self.tableau.make_content()
1260 OpenAnalyse(self, self.tableau.parametres)
1261 self.tree.OnItemAppend(self.tableau.parametres)
1262 #get_table_param(self, self.filename)
1263 #self.tableau.make_content()
1264 #self.tableau.show_tab()
1265 #open_data(self, self.filename)
1266 elif os.path.splitext(self.filename)[1] == '.txt':
1268 elif os.path.splitext(self.filename)[1] == '.ira' :
1269 #self.corpus = Corpus(self)
1270 #self.Text = OpenAnalyse(self, self.filename)
1271 OpenAnalyse(self, self.filename)
1273 print 'This file does not exist'
1276 class IntroPanel(wx.Panel):
1277 def __init__(self, parent):
1278 wx.Panel.__init__(self, parent)
1279 #col = randint(0, 255)
1280 #col1 = randint(0,255)
1281 #col2 = randint(0,255)
1286 bckgrdcolor = wx.Colour(col, col1, col2)
1287 self.SetBackgroundColour(bckgrdcolor)
1288 txtcolour = wx.Colour(250, 250, 250)
1289 linkcolor = wx.Colour(255, 0, 0)
1290 sizer1 = wx.BoxSizer(wx.VERTICAL)
1291 sizer2 = wx.BoxSizer(wx.VERTICAL)
1292 sizer4 = wx.BoxSizer(wx.HORIZONTAL)
1293 grid_sizer_1 = wx.FlexGridSizer(1, 4, 0, 0)
1294 grid_sizer_3 = wx.FlexGridSizer(1, 4, 0, 0)
1295 grid_sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
1297 iralink = hl.HyperLinkCtrl(self, wx.ID_ANY, u"http://www.iramuteq.org", URL="http://www.iramuteq.org")
1298 iralink.SetColours(linkcolor, linkcolor, "RED")
1299 iralink.SetBackgroundColour(bckgrdcolor)
1300 iralink.EnableRollover(True)
1301 iralink.SetUnderlines(False, False, True)
1302 iralink.SetBold(True)
1303 iralink.UpdateLink()
1305 PanelPres = wx.Panel(self)
1306 bckgrdcolor = wx.Colour(randint(0, 255), randint(0, 255), randint(0, 255))
1307 PanelPres.SetBackgroundColour(bckgrdcolor)
1309 label_1 = wx.StaticText(self, -1, u"IRaMuTeQ", size=(-1, -1))
1310 label_1.SetFont(wx.Font(46, wx.TELETYPE, wx.NORMAL, wx.BOLD, 0, "Purisa"))
1311 label_1.SetForegroundColour(wx.RED)
1313 iraicone = wx.Image(os.path.join(ImagePath,'iraicone100x100.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1314 but_ira = wx.StaticBitmap(self, -1, bitmap = iraicone)
1317 label2 = wx.StaticText(PanelPres, -1 , u'\nVersion ' + ConfigGlob.get('DEFAULT', 'version') + '\n')
1318 label2.SetForegroundColour(txtcolour)
1319 label2.SetBackgroundColour(bckgrdcolor)
1320 self.hyper2 = hl.HyperLinkCtrl(PanelPres, wx.ID_ANY, u"REPERE", URL="http://repere.no-ip.org/")
1321 self.hyper2.SetColours(linkcolor, linkcolor, "RED")
1322 self.hyper2.SetBackgroundColour(bckgrdcolor)
1323 self.hyper2.EnableRollover(True)
1324 self.hyper2.SetUnderlines(False, False, True)
1325 self.hyper2.SetBold(True)
1326 self.hyper2.UpdateLink()
1328 label_lerass = wx.StaticText(PanelPres, -1, u'Laboratoire ')
1329 label_lerass.SetForegroundColour(txtcolour)
1330 label_lerass.SetBackgroundColour(bckgrdcolor)
1332 self.hyper_lerass = hl.HyperLinkCtrl(PanelPres, -1, u'LERASS', URL="http://www.lerass.com")
1333 self.hyper_lerass.SetColours(linkcolor, linkcolor, "RED")
1334 self.hyper_lerass.SetBackgroundColour(bckgrdcolor)
1335 self.hyper_lerass.EnableRollover(True)
1336 self.hyper_lerass.SetUnderlines(False, False, True)
1337 self.hyper_lerass.SetBold(True)
1338 self.hyper_lerass.UpdateLink()
1340 blank = wx.StaticText(PanelPres, -1, u'\n')
1341 blank1 = wx.StaticText(PanelPres, -1, u'\n')
1343 labellicence = wx.StaticText(PanelPres, -1, _(u"License GNU GPL").decode('utf8'))
1344 labellicence.SetForegroundColour(txtcolour)
1345 labellicence.SetBackgroundColour(bckgrdcolor)
1347 labelcopy = wx.StaticText(PanelPres, -1, ConfigGlob.get('DEFAULT', 'copyright'))
1348 labelcopy.SetForegroundColour(txtcolour)
1349 labelcopy.SetBackgroundColour(bckgrdcolor)
1351 python_img = wx.Image(os.path.join(ImagePath,'python-logo.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1352 r_img = wx.Image(os.path.join(ImagePath,'Rlogo.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1353 lexique_img = wx.Image(os.path.join(ImagePath,'LexTexte4.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1354 but_python = wx.BitmapButton(self, -1, python_img)
1355 but_lexique = wx.BitmapButton(self, -1, lexique_img)
1356 but_r = wx.BitmapButton(self, -1, r_img)
1357 self.Bind(wx.EVT_BUTTON, self.OnPython, but_python)
1358 self.Bind(wx.EVT_BUTTON, self.OnLexique, but_lexique)
1359 self.Bind(wx.EVT_BUTTON, self.OnR, but_r)
1361 grid_sizer_1.Add(self.hyper2, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1362 grid_sizer_3.Add(label_lerass, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1363 grid_sizer_3.Add(self.hyper_lerass, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1364 sizer4.Add(label_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5)
1366 sizer2.Add(label2, 0, wx.ALIGN_CENTER, 5)
1367 sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 5)
1368 sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 5)
1369 sizer2.Add(grid_sizer_3, 0, wx.ALIGN_CENTER, 5)
1370 sizer2.Add(wx.StaticText(PanelPres, -1, u' '), 0, wx.ALIGN_CENTER, 5)
1371 sizer2.Add(grid_sizer_1, 0, wx.ALIGN_CENTER, 5)
1372 sizer2.Add(labellicence, 0, wx.ALIGN_CENTER, 5)
1373 sizer2.Add(labelcopy, 0, wx.ALIGN_CENTER, 5)
1374 sizer1.Add(sizer4, 2, wx.ALIGN_CENTER_HORIZONTAL, 0)
1375 sizer1.Add(but_ira, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5)
1376 sizer1.Add(iralink, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_TOP, 5)
1377 sizer2.Add(wx.StaticText(PanelPres, -1, u''), 0, wx.ALIGN_CENTER, 10)
1378 PanelPres.SetSizer(sizer2)
1379 grid_sizer_2.Add(but_python, 1, wx.ALIGN_BOTTOM)
1380 grid_sizer_2.Add(but_lexique, 1, wx.ALIGN_BOTTOM)
1381 grid_sizer_2.Add(but_r, 1, wx.ALIGN_BOTTOM)
1383 sizer1.Add(PanelPres, 0, wx.EXPAND |wx.ALL, 10)
1384 sizer1.Add(grid_sizer_2, 2, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 1)
1385 self.SetSizer(sizer1)
1388 def OnPython(self,evt):
1389 webbrowser.open('http://www.python.org')
1391 def OnLexique(self,evt):
1392 webbrowser.open('http://www.lexique.org')
1395 webbrowser.open('http://www.r-project.org')
1397 class MySplashScreen(wx.SplashScreen):
1399 bmp = wx.Image(os.path.join(ImagePath, 'splash.png')).ConvertToBitmap()
1400 wx.SplashScreen.__init__(self, bmp,
1401 wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,
1403 self.Bind(wx.EVT_CLOSE, self.OnClose)
1404 self.fc = wx.FutureCall(1, self.ShowMain)
1406 def OnClose(self, evt):
1410 if self.fc.IsRunning():
1415 displaySize = wx.DisplaySize()
1416 w = displaySize[0]/1.2
1417 h = displaySize[1]/1.2
1418 frame = IraFrame(None, -1, "IRaMuTeQ " + ConfigGlob.get('DEFAULT', 'version'), size=(w, h))
1422 frame.OnOpenFromCmdl()
1423 # if self.fc.IsRunning():
1425 #wx.CallAfter(frame.ShowTip)
1427 class MyApp(wx.App):
1430 Create and show the splash screen. It will then create and show
1431 the main frame when it is time to do so.
1433 wx.SystemOptions.SetOptionInt("mac.window-plain-transition", 1)
1434 self.SetAppName("Iramuteq")
1435 splash = MySplashScreen()
1443 if __name__ == '__main__':