1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2008-2020 Pierre Ratinaud
4 #modification pour python 3 : Laurent Mérat, 6x7 - mai 2020
7 #------------------------------------
8 # import des modules python
9 #------------------------------------
15 from random import randint
16 from configparser import ConfigParser, RawConfigParser
20 from optparse import OptionParser
21 parser = OptionParser()
22 parser.add_option("-f", "--file", dest="filename",
23 help="open FILE", metavar="FILE", default=False)
24 (options, args) = parser.parse_args()
26 #------------------------------------
27 # import des modules wx
28 #------------------------------------
31 import wx.lib.agw.aui as aui
34 import wx.lib.agw.hyperlink as hl
36 #------------------------------------
37 # import des fichiers du projet
38 #------------------------------------
39 from analyse_merge import AnalyseMerge
40 from checkinstall import CreateIraDirectory, CheckRPath, FindRPAthWin32, FindRPathNix, CheckRPackages, IsNew, UpgradeConf, CopyConf, RLibsAreInstalled
41 from checkversion import NewVersion
42 from chemins import RscriptsPath, ConstructConfigPath, ConstructDicoPath, ConstructGlobalPath, PathOut
43 from corpus import Builder, SubBuilder, MergeClusters
44 from dialog import PrefDialog
45 from functions import BugReport, PlaySound, History, progressbar
46 from guifunct import *
47 from openanalyse import OpenAnalyse
48 from parse_dmi import ImportDMI
49 from parse_factiva_xml import ImportFactiva
50 from tabafcm import DoAFCM
51 from tabchdalc import AnalyseQuest
52 from tabchddist import ChdCluster
53 from tabchi2 import ChiSquare
54 from tabchi2mcnemar import McNemar
55 from tabfrequence import Frequences, FreqMultiple
56 from tableau import Tableau
57 from tabrsimple import InputText
58 from tabsimi import DoSimi
59 from tabcatego import Categorisation
60 from tabsplitvar import SplitMatrixFromVar
61 from tabverges import Prototypical
62 from textaslexico import Lexico
63 from textlabbe import DistLabbe
64 from textreinert import Reinert
65 from textsimi import SimiTxt, SimiFromCluster
66 from textstat import Stat
67 from textwordcloud import WordCloud, ClusterCloud
68 from tools import Extract
69 from tree import LeftTree
75 #------------------------------------
76 # les ID uniques pour tous les éléments qui vont en avoir besoin
77 #------------------------------------
78 ID_OpenData = wx.Window.NewControlId()
79 ID_Import = wx.Window.NewControlId()
80 ID_OpenText = wx.Window.NewControlId()
81 ID_OnOpenAnalyse = wx.Window.NewControlId()
82 ID_Freq = wx.Window.NewControlId()
83 ID_Chi2 = wx.Window.NewControlId()
84 ID_Chi2mc = wx.Window.NewControlId()
85 ID_Student = wx.Window.NewControlId()
86 ID_CHDSIM = wx.Window.NewControlId()
87 ID_CHDReinert = wx.Window.NewControlId()
88 ID_TEXTAFCM = wx.Window.NewControlId()
89 ID_TEXTSTAT = wx.Window.NewControlId()
90 ID_ASLEX = wx.Window.NewControlId()
91 ID_TEXTREINERT = wx.Window.NewControlId()
92 ID_TEXTPAM = wx.Window.NewControlId()
93 ID_CHECKCORPUS = wx.Window.NewControlId()
94 ID_Tabcontent = wx.Window.NewControlId()
95 ID_AFCM = wx.Window.NewControlId()
96 ID_SIMI = wx.Window.NewControlId()
97 ID_CATE = wx.Window.NewControlId()
98 ID_CloseTab = wx.Window.NewControlId()
99 ID_SaveTab = wx.Window.NewControlId()
100 ID_CreateText = wx.Window.NewControlId()
101 ID_ACCEUIL = wx.Window.NewControlId()
102 ID_RESULT = wx.Window.NewControlId()
103 ID_HTMLcontent = wx.Window.NewControlId()
104 ID_SimiTxt = wx.Window.NewControlId()
105 ID_proto = wx.Window.NewControlId()
106 ID_ImportTXM = wx.Window.NewControlId()
107 ID_FreqMulti = wx.Window.NewControlId()
108 ID_Splitfromvar = wx.Window.NewControlId()
109 ID_Subtxtfrommeta = wx.Window.NewControlId()
110 ID_Subtxtfromthem = wx.Window.NewControlId()
111 ID_WC = wx.Window.NewControlId()
112 ID_ImportEuro = wx.Window.NewControlId()
113 ID_Fact_xml = wx.Window.NewControlId()
114 ID_Fact_mail = wx.Window.NewControlId()
115 ID_Fact_copy = wx.Window.NewControlId()
116 ID_exportmeta = wx.Window.NewControlId()
117 ID_importdmi = wx.Window.NewControlId()
118 ID_merge = wx.Window.NewControlId()
119 ID_merge_clusters = wx.Window.NewControlId()
120 ID_labbe = wx.Window.NewControlId()
122 #------------------------------------
123 # elements de configuration
124 #------------------------------------
127 # if sys.platform == 'darwin' :
128 # sys.setdefaultencoding('UTF-8')
129 # wx.SetDefaultPyEncoding('UTF-8')
131 # sys.setdefaultencoding(locale.getpreferredencoding())
133 #chemin de l'application
134 AppliPath = os.path.abspath(os.path.dirname(os.path.realpath(sys.argv[0])))
137 ImagePath = os.path.join(AppliPath, 'images')
139 #configuration generale
140 DictConfigPath = ConstructGlobalPath(AppliPath)
141 ConfigGlob = ConfigParser()
142 ConfigGlob.read(DictConfigPath['global'])
143 DefaultConf = ConfigParser()
144 DefaultConf.read(DictConfigPath['preferences'])
146 #repertoire de l'utilisateur
147 user_home = os.getenv('HOME')
148 if user_home is None :
149 user_home = os.path.expanduser('~')
151 UserConfigPath = os.path.abspath(os.path.join(user_home, '.iramuteq-%s' % ConfigGlob.get('DEFAULT', 'version_nb')))
152 ConfigPath = ConstructConfigPath(UserConfigPath)
154 #Si pas de fichiers de config utilisateur, on cree le repertoire
155 CreateIraDirectory(UserConfigPath, AppliPath)
157 #fichiers log pour windows (py2exe)
158 log = logging.getLogger('iramuteq')
159 fh = logging.FileHandler(os.path.join(UserConfigPath,'stdout.log'))
160 formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
161 fh.setFormatter(formatter)
163 if sys.platform != 'win32' and sys.platform != 'darwin':
164 ch = logging.StreamHandler()
165 ch.setFormatter(formatter)
167 log.setLevel(logging.INFO)
170 class writer(object):
172 def write(self, data):
173 if data.strip() != '' :
174 log.info('ERROR : %s' % data)
177 class printer(object) :
179 def write(self, data) :
180 if data.strip() != '' :
181 log.info('Print : %s' % data)
183 # pour eviter des lignes de log d'erreur
187 #sys.stderr = writer()
188 #sys.stdout = printer()
191 'textroot' : 'textroot.png',
192 'alceste' : 'reinert.png',
193 'reinert' : 'reinert.png',
194 'corpus' : 'textcorpus.png',
195 'wordcloud' :'wordcloud.png',
197 'simitxt' : 'simitxt.png',
198 'clustersimitxt' :'clustersimitxt.png',
199 'clustercloud' : 'clustercloud.png',
201 'matroot' : 'matroot.png',
202 'matrix' : 'matrix.png',
203 'freq' : 'frequences.png',
204 'freqmulti' : 'frequences.png',
206 'chi2mcnemar' : 'chi2.png',
207 'reinertmatrix' : 'reinertmatrix.png',
208 'simimatrix' : 'simimatrix.png',
209 'simiclustermatrix' : 'simimatrix.png',
210 'proto' : 'proto.png',
212 'europress' : 'europress.png',
213 'factiva_xml' : 'factiva_xml.png',
214 'factiva_copy' : 'factiva_copy.png',
215 'factiva_mail': 'factiva_mail.png',
216 'iramuteq' : 'iraicone.png',
217 'subcorpusmeta' : 'subcorpusmeta.png',
218 'subcorpusthema' : 'subcorpusthema.png',
219 'preferences' : 'preferences.png',
220 'exportmetatable' : 'exportmetatable.png',
221 'importdmi' : 'twitter.png',
222 'labbe' : 'spec.png',
223 'categorisation' : 'spec.png',
227 #------------------------------------
228 # l'ensemble du contexte de Iramuteq : menu, fenetre, etc.
229 #------------------------------------
230 class IraFrame(wx.Frame):
232 def __init__(self, parent,
234 pos=wx.DefaultPosition,
236 style=wx.DEFAULT_FRAME_STYLE |
239 log.info('Starting Iramuteq... ' )
240 log.info('version : %s' % ConfigGlob.get('DEFAULT', 'version'))
242 wx.Frame.__init__(self, parent, id, title, pos, size, style)
245 self.AppliPath = AppliPath
246 self.images_path = os.path.join(AppliPath,'images')
247 self.UserConfigPath = UserConfigPath
248 #self.RscriptsPath = ConstructRscriptsPath(AppliPath)
249 self.RscriptsPath = PathOut(dirout=os.path.join(AppliPath, 'Rscripts'))
250 self.RscriptsPath.basefiles(RscriptsPath)
251 #self.DictPath = ConstructDicoPath(AppliPath)
252 self.DictPath = ConstructDicoPath(UserConfigPath)
253 self.ConfigGlob = ConfigGlob
254 self.ConfigPath = ConstructConfigPath(self.UserConfigPath)
255 self.pref = RawConfigParser()
256 # workaround for import problem
257 self.SimiFromCluster = SimiFromCluster
258 # tell FrameManager to manage this frame
259 self._mgr = aui.AuiManager()
260 self._mgr.SetManagedWindow(self)
264 self.pref.read(self.ConfigPath['preferences'])
265 self.fontsize = self.pref.getint('iramuteq','fontsize')
267 print('no pref : setting fontsize to 12')
269 self.SetFont(wx.Font(self.fontsize, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
271 #--------------------------------------------------------------------------------
273 #--------------------------------------------------------------------------------
274 self.images_analyses = images_analyses
275 for img in images_analyses :
276 self.images_analyses[img] = wx.Image(os.path.join(self.images_path, self.images_analyses[img]),
277 wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()
278 self.mb = wx.MenuBar()
280 # menu 'Fichier' de la barre de menu (en haut de l'écran)
281 file_menu = wx.Menu()
282 item = wx.MenuItem(file_menu, ID_OpenData, _("Open a matrix"), _("Open a matrix"))
283 #item.SetBitmap(wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN))
284 item.SetBitmap(self.images_analyses['matroot'])
285 file_menu.Append(item)
286 item = wx.MenuItem(file_menu, ID_OpenText, _("Open a text corpus"), _("Open a text corpus"))
287 item.SetBitmap(self.images_analyses['textroot'])
288 file_menu.Append(item)
289 item = wx.MenuItem(file_menu, ID_OnOpenAnalyse, _("Open an analysis"), _("Open an analysis"))
290 item.SetBitmap(self.images_analyses['iramuteq'])
291 file_menu.Append(item)
292 item = wx.MenuItem(file_menu, ID_ImportTXM, _("Import from TXM"), _("Import from TXM"))
293 item.SetBitmap(self.images_analyses['TXM'])
294 file_menu.Append(item)
295 item = wx.MenuItem(file_menu, ID_ImportEuro, _("Import from Europress"), _("Import from Europress"))
296 item.SetBitmap(self.images_analyses['europress'])
297 file_menu.Append(item)
298 item = wx.MenuItem(file_menu, ID_importdmi, _("Import from DMI-TCAT (exp.)"), _("Import from DMI-TCAT (exp.)"))
299 item.SetBitmap(self.images_analyses['importdmi'])
300 file_menu.Append(item)
301 item = wx.MenuItem(file_menu, ID_merge, _('Merge graphs'), _('Merge graphs'))
302 file_menu.Append(item)
303 item = wx.MenuItem(file_menu, ID_merge_clusters, _('Corpus from merge clusters'), _('Corpus from merge clusters'))
304 file_menu.Append(item)
307 menuFactiva = wx.Menu()
308 fact_from_xml = wx.MenuItem(menuFactiva, ID_Fact_xml, _("from xml"))
309 fact_from_xml.SetBitmap(self.images_analyses['factiva_xml'])
310 fact_from_mail = wx.MenuItem(menuFactiva, ID_Fact_mail, _("from mail"))
311 fact_from_mail.SetBitmap(self.images_analyses['factiva_mail'])
312 fact_from_txt = wx.MenuItem(menuFactiva, ID_Fact_copy, _("from copy/paste"))
313 fact_from_txt.SetBitmap(self.images_analyses['factiva_copy'])
314 menuFactiva.Append(fact_from_xml)
315 menuFactiva.Append(fact_from_mail)
316 menuFactiva.Append(fact_from_txt)
317 file_menu.Append(-1, _("Import from factiva"), menuFactiva)
319 menuTools = wx.Menu()
320 splitvar = wx.MenuItem(menuTools, wx.ID_ANY, _("Split from variable"))
321 extractmod = wx.MenuItem(menuTools, wx.ID_ANY, _("Extract mods"))
322 extractthem = wx.MenuItem(menuTools, wx.ID_ANY, _("Extract thematics"))
323 menuTools.Append(splitvar)
324 menuTools.Append(extractmod)
325 menuTools.Append(extractthem)
326 self.ID_splitvar = splitvar.GetId()
327 self.ID_extractmod = extractmod.GetId()
328 self.ID_extractthem = extractthem.GetId()
329 file_menu.Append(-1, _("Tools"), menuTools)
332 #item = wx.MenuItem(file_menu, ID_SaveTab, _(u"Save tab as..."), _(u"Save tab as..."))
333 #item.SetBitmap(wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE_AS))
334 #file_menu.AppendItem(item)
336 file_menu.Append(wx.ID_EXIT, _("Exit"))
337 # sous macOS cet élément est apparemment déplacé automatiquement vers le menu 'pomme' ???
339 # menu 'Edition' de la barre de menu (en haut de l'écran)
340 # sous macOS, il est déplacé dans le menu 'App'
341 # alors que le menu édition (copier/coller etc. reste vide)
342 edit_menu = wx.Menu()
343 pref = wx.MenuItem(edit_menu, wx.ID_PREFERENCES, _('Preferences'))
344 pref.SetBitmap(self.images_analyses['preferences'])
345 edit_menu.Append(pref)
347 # menu 'Vue' de la barre de menu (en haut de l'écran)
348 view_menu = wx.Menu()
349 home = wx.MenuItem(view_menu, ID_ACCEUIL, _("Home page"))
350 home.SetBitmap(wx.ArtProvider.GetBitmap(wx.ART_GO_HOME, size = (16,16)))
351 view_menu.Append(home)
352 results = wx.MenuItem(view_menu, ID_RESULT, _('Show results'))
353 results.SetBitmap(wx.ArtProvider.GetBitmap(wx.ART_LIST_VIEW, size = (16,16)))
354 view_menu.Append(results)
356 # menu 'Analyses de matrice' de la barre de menu (en haut de l'écran)
357 matrix_menu = wx.Menu()
358 matanalyses = [[ID_Freq, _("Frequencies"), 'freq'],
359 [ID_FreqMulti, _("Multiple Frequencies"), 'freqmulti'],
360 [ID_Chi2, _("Chi2"), 'chi2'],
361 [ID_Chi2mc, _("Chi2 McNemar"), 'chi2mcnemar'],
362 {'name' : _("Clustering"),
363 'content' : [[ID_CHDReinert, _("Reinert's Method"), 'reinertmatrix']]
365 [ID_SIMI, _("Similarities Analysis"), 'simimatrix'],
366 [ID_proto, _("Prototypical Analysis"), 'proto'],
367 [ID_Splitfromvar, _("Split from variable"), 'subcorpusmeta'],
368 [ID_CATE, _("ElCaTeGoRiZatoR"), 'categorisation'],
370 for analyse in matanalyses :
371 if not isinstance(analyse, dict) :
372 item = wx.MenuItem(matrix_menu, analyse[0], analyse[1])
373 item.SetBitmap(self.images_analyses.get(analyse[2], wx.Bitmap(16,16)))
374 matrix_menu.Append(item)
377 for subana in analyse['content'] :
378 item = wx.MenuItem(nmenu, subana[0], subana[1])
379 item.SetBitmap(self.images_analyses.get(subana[2], wx.Bitmap(16,16)))
381 matrix_menu.Append(-1, analyse['name'], nmenu)
382 self.matrix_menu = matrix_menu
384 # menu 'Analyse de texte' de la barre de menu (en haut de l'écran)
385 text_menu = wx.Menu()
386 analyses_text = [[ID_TEXTSTAT, _("Statistics"), 'stat'],
387 [ID_ASLEX, _("Specificities and CA"), 'spec'],
388 [ID_labbe, _("Labbe Distance"),'labbe'],
389 {'name' : _("Clustering"),
390 'content' : [[ID_TEXTREINERT, _("Reinert's Method"), 'alceste']]
392 [ID_SimiTxt, _("Similarities Analysis"), 'simitxt'],
393 [ID_WC, _("WordCloud"), 'wordcloud'],
394 {'name' : _("Sub corpus"),
395 'content' : [[ID_Subtxtfrommeta, _('Sub corpus from metadata'), 'subcorpusmeta'],
396 [ID_Subtxtfromthem, _('Sub corpus from thematic'), 'subcorpusthema']]
398 [ID_exportmeta, _("Export metadata table"), 'exportmetatable'],
400 for analyse in analyses_text :
401 if not isinstance(analyse, dict) :
402 item = wx.MenuItem(text_menu, analyse[0], analyse[1])
403 item.SetBitmap(self.images_analyses.get(analyse[2], wx.Bitmap(16,16)))
404 text_menu.Append(item)
407 for subana in analyse['content'] :
408 item = wx.MenuItem(nmenu, subana[0], subana[1])
409 item.SetBitmap(self.images_analyses.get(subana[2], wx.Bitmap(16,16)))
411 text_menu.Append(-1, analyse['name'], nmenu)
412 self.text_menu = text_menu
414 # menu 'Aide' et 'A propos' de la barre de menu (en haut de l'écran)
415 # mais le "à propos est déplacé par macOS sous le menu "Pomme"
416 # et il n'a pas d'action apparemment
417 help_menu = wx.Menu()
418 about = wx.MenuItem(help_menu, wx.ID_ABOUT, _("About..."))
419 about.SetBitmap(wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, size = (16,16)))
420 help_menu.Append(about)
421 help = wx.MenuItem(help_menu, wx.ID_HELP, _("Online help..."))
422 help.SetBitmap(wx.ArtProvider.GetBitmap(wx.ART_HELP, size = (16,16)))
423 help_menu.Append(help)
425 # après avoir construit chaque menu, on les ajoute à barre de menu (en haut de l'écran)
426 self.mb.Append(file_menu, _("File"))
427 self.mb.Append(edit_menu, _("Edition"))
428 self.mb.Append(view_menu, _("View"))
429 self.mb.Append(matrix_menu, _("Matrix analysis"))
430 self.mb.Append(text_menu, _("Text analysis"))
431 self.mb.Append(help_menu, _("Help"))
432 self.SetMenuBar(self.mb)
434 #--------------------------------------------------------------------
435 # barre de statut : sur macOS, c'est la barre en bas de la fenêtre Iramuteq
436 #--------------------------------------------------------------------
437 self.statusbar = self.CreateStatusBar(2, wx.STB_SIZEGRIP)
438 self.statusbar.SetStatusWidths([-2, -3])
439 self.statusbar.SetStatusText(_("Ready"), 0)
440 self.statusbar.SetStatusText(_("Welcome"), 1)
441 # min size for the frame itself isn't completely done.
442 # see the end up FrameManager::Update() for the test
443 # code. For now, just hard code a frame minimum size
444 self.SetMinSize(wx.Size(800, 600))
446 #--------------------------------------------------------------------
447 # barre d'outils : le menu de petits icones en haut de la fenetre
448 # il y en a 4 : tb1, tb_text, tb_mat, tb_help
449 #--------------------------------------------------------------------
451 tb1 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER)
452 tb1.SetToolBitmapSize(wx.Size(16, 16))
453 tb1.AddTool(ID_OpenData, "OpenData", self.images_analyses['matroot'], shortHelp=_("Open a matrix"))
455 tb1.AddTool(ID_OpenText, "OpenText", self.images_analyses['textroot'], shortHelp=_("Open a text corpus"))
457 tb1.AddTool(ID_OnOpenAnalyse, "OpenAnalyse", self.images_analyses['iramuteq'], shortHelp= _("Open an analysis"))
459 tb1.AddTool(ID_ImportTXM, "ImportTXM", self.images_analyses['TXM'], shortHelp= _("Import from TXM"))
461 tb1.AddTool(ID_ImportEuro, "ImportEuro", self.images_analyses['europress'], shortHelp= _("Import from Europress"))
463 tb1.AddTool(ID_importdmi, "ImportDMI", self.images_analyses['importdmi'], shortHelp= _("Import from DMI-TCAT (exp.)"))
465 tb1.AddTool(ID_Fact_xml, "ImportFactxml", self.images_analyses['factiva_xml'], shortHelp= _("Factiva from xml"))
466 tb1.AddTool(ID_Fact_mail, "ImportFactmail", self.images_analyses['factiva_mail'], shortHelp= _("Factiva from mail"))
467 tb1.AddTool(ID_Fact_copy, "ImportFactcopy", self.images_analyses['factiva_copy'], shortHelp= _("Factiva from copy/paste"))
469 tb1.AddTool(wx.ID_PREFERENCES, "Preferences", self.images_analyses['preferences'], shortHelp= _("Preferences"))
471 tb1.AddTool(ID_ACCEUIL, "Home", wx.ArtProvider.GetBitmap(wx.ART_GO_HOME, size = (16,16)), shortHelp= _("Home page"))
472 tb1.AddTool(ID_RESULT, "Results", wx.ArtProvider.GetBitmap(wx.ART_LIST_VIEW, size = (16,16)), shortHelp= _('Show results'))
475 tb_text = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER)
476 for analyse in analyses_text :
477 if not isinstance(analyse, dict) :
478 tb_text.AddTool(analyse[0], analyse[1], self.images_analyses.get(analyse[2], wx.Bitmap(16,16)), shortHelp = analyse[1])
480 for subana in analyse['content'] :
481 tb_text.AddTool(subana[0], subana[1], self.images_analyses.get(subana[2], wx.Bitmap(16,16)), shortHelp = subana[1])
484 tb_mat = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER)
485 for analyse in matanalyses :
486 if not isinstance(analyse, dict) :
487 tb_mat.AddTool(analyse[0], analyse[1], self.images_analyses.get(analyse[2], wx.Bitmap(16,16)), shortHelp = analyse[1])
489 for subana in analyse['content'] :
490 tb_mat.AddTool(subana[0], subana[1], self.images_analyses.get(subana[2], wx.Bitmap(16,16)), shortHelp = subana[1])
493 tb_help = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER)
494 tb_help.AddTool(wx.ID_ABOUT, "About", wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, size=(16,16)), shortHelp=_("About..."))
495 tb_help.AddTool(wx.ID_HELP, "Help", wx.ArtProvider.GetBitmap(wx.ART_HELP, size=(16,16)), shortHelp=_("Online help..."))
499 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)
500 self._mgr.AddPane(self.text_ctrl_txt, aui.AuiPaneInfo().Name("Text").CenterPane())
501 self._mgr.AddPane(IntroPanel(self), aui.AuiPaneInfo().Name("Intro_Text").CenterPane())
503 #------------------------------------------------------------------------------------------------
504 # fichier d'historique de Iramuteq
505 #------------------------------------------------------------------------------------------------
506 if not os.path.exists(os.path.join(UserConfigPath, 'history.db')) :
507 with open(os.path.join(UserConfigPath, 'history.db'), 'w') as f :
509 self.history = History(os.path.join(UserConfigPath, 'history.db'))
510 # l'extension ".db" est ajoutée automatiquement par le module
512 #------------------------------------------------------------------------------------------------
513 # colonne gauche de la fenetre de Iramuteq, classe "Lefttree"
514 #------------------------------------------------------------------------------------------------
515 #self.history.dostat()
516 self.tree = LeftTree(self)
517 self._mgr.AddPane(self.tree,
520 Caption(_("Historic")).
522 MinSize(wx.Size(200,400)).
523 BestSize(wx.Size(300,-1)).
527 MaximizeButton(True).
528 MinimizeButton(True))
530 self.nb = aui.AuiNotebook(self,
534 aui.AUI_NB_DEFAULT_STYLE)
535 # | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_FLOAT | wx.NO_BORDER)
536 notebook_flags = aui.AUI_NB_DEFAULT_STYLE
537 # | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_FLOAT| wx.NO_BORDER
538 self.nb.SetAGWWindowStyleFlag(notebook_flags)
539 self.nb.SetArtProvider(aui.ChromeTabArt())
540 self.nb.SetFont(wx.Font(self.fontsize, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
541 #self.nb.SetArtProvider(aui.VC8TabArt())
542 #self.nb.parent = self
543 #self._notebook_style = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | wx.NO_BORDER
545 #------------------------------------------------------------------------------------------------
546 # colonne droite de la fenetre de Iramuteq "Tab_content"
547 #------------------------------------------------------------------------------------------------
548 self._mgr.AddPane(self.nb,
553 #self._mgr.AddPane(self.Sheet, wx.aui.AuiPaneInfo().Name("Data").CenterPane())
554 #self._mgr.AddPane(self.Sheet, aui.AuiPaneInfo().Name("Data").CenterPane())
555 self.nb.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnCloseTab)
556 self.nb.Bind(aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
558 #------------------------------------------------------------------------------------------------
559 # ajout des toolbars à la fenetre de Iramuteq
560 # Iramuteq n'utilise pas directement les 'toolbar' au sens de wx.python
561 # mais en fait des ToolbarPane ???
562 #------------------------------------------------------------------------------------------------
563 self._mgr.AddPane(tb1, aui.AuiPaneInfo().
569 RightDockable(False))
570 self._mgr.AddPane(tb_text, aui.AuiPaneInfo().
572 Caption("analyse_text").
576 RightDockable(False))
577 self._mgr.AddPane(tb_mat, aui.AuiPaneInfo().
579 Caption("analyse_matrix").
583 RightDockable(False))
584 self._mgr.AddPane(tb_help, aui.AuiPaneInfo().
590 RightDockable(False))
591 # ces deux toolbars sont cachées car elles dépendent du contexte des éléments sélectionnés dans lefttree
592 self._mgr.GetPane('tb_text').Hide()
593 self._mgr.GetPane('tb_mat').Hide()
595 self.ShowAPane("Intro_Text")
596 self._mgr.GetPane("lefttree").Show()
597 self._mgr.GetPane("classif_tb").Hide() # utilisé nulle part ailleurs que sur cette ligne ???
598 # "commit" all changes made to FrameManager
601 # Attache les événements aux éléments d'interface
602 self.Bind(wx.EVT_MENU, self.OnAcceuil, id=ID_ACCEUIL)
603 self.Bind(wx.EVT_MENU, self.ShowTab, id=ID_RESULT)
604 self.Bind(wx.EVT_MENU, self.OnOpenData, id=ID_OpenData)
605 self.Bind(wx.EVT_MENU, self.OnOpenText, id=ID_OpenText)
606 self.Bind(wx.EVT_MENU, self.OnOpenAnalyse, id=ID_OnOpenAnalyse)
607 self.Bind(wx.EVT_MENU, self.import_factiva_xml, fact_from_xml)
608 self.Bind(wx.EVT_MENU, self.import_factiva_mail, fact_from_mail)
609 self.Bind(wx.EVT_MENU, self.import_factiva_txt, fact_from_txt)
610 self.Bind(wx.EVT_MENU, self.ExtractTools, splitvar)
611 self.Bind(wx.EVT_MENU, self.ExtractTools, extractmod)
612 self.Bind(wx.EVT_MENU, self.ExtractTools, extractthem)
613 self.Bind(wx.EVT_MENU, self.OnFreq, id=ID_Freq)
614 self.Bind(wx.EVT_MENU, self.OnFreqMulti, id=ID_FreqMulti)
615 self.Bind(wx.EVT_MENU, self.OnChi2, id=ID_Chi2)
616 self.Bind(wx.EVT_MENU, self.OnChi2McNemar, id=ID_Chi2mc)
617 self.Bind(wx.EVT_MENU, self.OnStudent, id=ID_Student)
618 self.Bind(wx.EVT_MENU, self.OnCHDSIM, id=ID_CHDSIM)
619 self.Bind(wx.EVT_MENU, self.OnCHDReinert, id=ID_CHDReinert)
620 self.Bind(wx.EVT_MENU, self.OnAFCM, id=ID_AFCM)
621 self.Bind(wx.EVT_MENU, self.OnProto, id=ID_proto)
622 self.Bind(wx.EVT_MENU, self.OnSplitVar, id = ID_Splitfromvar)
623 self.Bind(wx.EVT_MENU, self.OnCategorisation, id = ID_CATE)
624 #self.Bind(wx.EVT_MENU, self.OnRCode, id=ID_RCODE) #???
625 #self.Bind(wx.EVT_MENU, self.OnSplitVar, id=ID_SPLITVAR) #???
626 #self.Bind(wx.EVT_MENU, self.OnCheckcorpus, id = ID_CHECKCORPUS) #???
627 self.Bind(wx.EVT_MENU, self.OnTextStat, id=ID_TEXTSTAT)
628 self.Bind(wx.EVT_MENU, self.OnTextSpec, id=ID_ASLEX)
629 self.Bind(wx.EVT_MENU, self.OnTextLabbe, id=ID_labbe)
630 self.Bind(wx.EVT_MENU, self.OnTextAfcm, id=ID_TEXTAFCM)
631 self.Bind(wx.EVT_MENU, self.OnTextReinert, id=ID_TEXTREINERT)
632 self.Bind(wx.EVT_MENU, self.OnPamSimple, id=ID_TEXTPAM)
633 self.Bind(wx.EVT_MENU, self.OnSimiTxt, id=ID_SimiTxt)
634 self.Bind(wx.EVT_MENU, self.OnWordCloud, id=ID_WC)
635 self.Bind(wx.EVT_MENU, self.OnSubText, id = ID_Subtxtfrommeta)
636 self.Bind(wx.EVT_MENU, self.OnSubText, id = ID_Subtxtfromthem)
637 self.Bind(wx.EVT_MENU, self.OnSimiTab, id=ID_SIMI)
638 self.Bind(wx.EVT_MENU, self.OnExit, id=wx.ID_EXIT)
639 #self.Bind(wx.EVT_MENU, self.OnSaveTabAs, id=ID_SaveTab) #???
640 self.Bind(wx.EVT_MENU, self.OnAbout, id=wx.ID_ABOUT)
641 self.Bind(wx.EVT_MENU, self.OnHelp, id=wx.ID_HELP)
642 self.Bind(wx.EVT_MENU, self.OnPref, id=wx.ID_PREFERENCES)
643 self.Bind(wx.EVT_MENU, self.OnImportTXM, id=ID_ImportTXM)
644 self.Bind(wx.EVT_MENU, self.OnImportEuropress, id=ID_ImportEuro)
645 self.Bind(wx.EVT_MENU, self.OnImportDMI, id=ID_importdmi)
646 self.Bind(wx.EVT_MENU, self.OnExportMeta, id=ID_exportmeta)
647 self.Bind(wx.EVT_MENU, self.OnMergeGraph, id = ID_merge)
648 self.Bind(wx.EVT_MENU, self.OnMergeClusters, id = ID_merge_clusters)
649 self.Bind(wx.EVT_CLOSE, self.OnClose)
651 flags = self._mgr.GetAGWFlags()
652 #flags &= ~wx.aui.AUI_MGR_TRANSPARENT_HINT
653 #flags &= ~wx.aui.AUI_MGR_VENETIAN_BLINDS_HINT
654 #flags &= ~wx.aui.AUI_MGR_RECTANGLE_HINT
655 flags &= ~(aui.AUI_MGR_RECTANGLE_HINT | aui.AUI_MGR_ALLOW_FLOATING)
656 self._mgr.SetAGWFlags(self._mgr.GetAGWFlags() ^ (aui.AUI_MGR_RECTANGLE_HINT | aui.AUI_MGR_ALLOW_FLOATING))
657 self._mgr.GetArtProvider().SetMetric(aui.AUI_DOCKART_GRADIENT_TYPE, aui.AUI_GRADIENT_HORIZONTAL)
658 self.GetDockArt().SetColor(aui.AUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR, "#00FFF9")
660 self._icon = wx.Icon(os.path.join(ImagePath, "iraicone.ico"), wx.BITMAP_TYPE_ICO)
661 self.SetIcon(self._icon)
664 self.input_path = [False]
665 self.TEMPDIR = tempfile.mkdtemp('iramuteq')
666 self.FileTabList = []
672 self.g_header = False
679 self.SysEncoding = sys.getdefaultencoding()
680 self.syscoding = sys.getdefaultencoding()
681 if self.SysEncoding == 'mac-roman' : self.SysEncoding = 'MacRoman'
683 #------------------------------------------------------------------------------------------------
685 # 'view', 'matrix' et 'text' sont des valeurs attendues par la fonction ShowMenu
686 #self.ShowMenu('view', True)
687 #self.ShowMenu('matrix', False)
688 #self.ShowMenu('text', False)
689 # je commente ces trois lignes car je ne comprends pas
690 # mais je les garde pour le moment, au cas où il y a un mécanisme que je n'ai pas encore compris
691 #------------------------------------------------------------------------------------------------
700 def finish_init(self) :
702 self.pref.read(self.ConfigPath['preferences'])
705 self.pref.read(self.ConfigPath['preferences'])
712 self.pref.read(self.ConfigPath['preferences'])
714 self.sound = self.pref.getboolean('iramuteq', 'sound')
715 self.check_update = self.pref.getboolean('iramuteq', 'checkupdate')
716 self.version = ConfigGlob.get('DEFAULT', 'version')
717 # configuration des chemins de R
718 self.PathPath = ConfigParser()
719 self.PathPath.read(ConfigPath['path'])
721 if not CheckRPath(self.PathPath) :
722 if sys.platform == 'win32':
723 if os.path.exists(self.AppliPath + '\\R\\R\\x64\\R.exe') :
724 BestRPath = self.AppliPath + '\\R\\R\\bin\\x64\\R.exe'
725 elif os.path.exists(self.AppliPath + '\\R\\R\\i386\\R.exe') :
726 BestRPath = self.AppliPath + '\\R\\R\\bin\\i386\\R.exe'
728 BestRPath = FindRPAthWin32()
729 elif os.path.exists(self.AppliPath + '/R/R') :
730 BestRPath = self.AppliPath + '/R/R'
732 BestRPath = FindRPathNix()
734 self.PathPath.set('PATHS', 'rpath', BestRPath)
735 with open(ConfigPath['path'], 'w') as f :
736 self.PathPath.write(f)
740 self.RPath = self.PathPath.get('PATHS', 'rpath')
743 if not RLibsAreInstalled(self) :
746 msg = '\n'.join([_("Can't find R executable"), _("If R is not installed, get it from http://www.r-project.org."),
747 _("If R is installed, report its path in Preferences."),
748 _("IRaMuTeQ does not work without R.")])
749 dlg = wx.MessageDialog(self, msg, _("Problem"), wx.OK | wx.ICON_WARNING)
751 if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
755 def OnVerif(self, evt) :
756 pack = CheckRPackages(self)
758 dlg = wx.MessageDialog(self, _("Installation OK"), _("Installation"), wx.OK | wx.ICON_INFORMATION | wx.STAY_ON_TOP)
760 if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
763 # appelé par des fonctions de ce fichier et tree.py : OnSelChanged
764 # vu comme elle est écrite, impossible de gérer
765 # l'affichage/masquage des toolbars en fonction du contexte
766 def ShowMenu(self, menu, Show=True):
770 if self._mgr.GetPane('tb_text').IsShown() :
772 self._mgr.GetPane('tb_text').Show()
773 self._mgr.GetPane('tb_mat').Hide()
774 self.mb.EnableTop(menu_pos, Show)
775 self.mb.EnableTop(3, False)
777 self._mgr.GetPane('tb_text').Hide()
778 elif menu == 'matrix' :
781 if self._mgr.GetPane('tb_mat').IsShown():
783 self._mgr.GetPane('tb_mat').Show()
784 self._mgr.GetPane('tb_text').Hide()
785 self.mb.EnableTop(menu_pos, Show)
786 self.mb.EnableTop(4, False)
788 self._mgr.GetPane('tb_mat').Hide()
789 elif menu == 'view' :
793 if not menu_pos is None :
794 #self.mb.EnableTop(menu_pos, Show)
799 #--------------------------------------------------------------------
800 # fin de __init__ du wx.Frame
801 #--------------------------------------------------------------------
803 # evenement attaché au bouton de fermeture des fenetres ou onglets ?
804 def OnClose(self, event):
805 print('onclose Iramuteq')
806 with open(self.ConfigPath['path'], 'w') as f :
807 self.PathPath.write(f)
812 # evenement attaché au menu 'ouvrir matrice'
813 def OnOpenData(self, event):
814 print('on open data')
815 inputname, self.input_path = OnOpen(self, "Data")
817 # filename = self.input_path[0]
818 self.tableau = Tableau(self,os.path.abspath(self.input_path[0]))
819 val = get_table_param(self, self.input_path[0])
821 busy = wx.BusyInfo(_("Please wait..."), self)
824 self.tableau.make_content()
825 OpenAnalyse(self, self.tableau.parametres)
826 self.tree.OnItemAppend(self.tableau.parametres)
831 # self.tableau.show_tab()
833 # evenement attaché au menu 'ouvrir analyse'
834 def OnOpenAnalyse(self, event):
835 print('on open analyse')
836 self.AnalysePath = OnOpen(self, "Analyse")
837 if self.AnalysePath :
838 OpenAnalyse(self, self.AnalysePath[1][0], True)
839 self.ShowMenu('view')
841 # evenement attaché au menu 'ouvrir un texte/corpus'
842 def OnOpenText(self, event):
843 print('on open text')
844 inputname, self.input_path = OnOpen(self, "Texte")
845 self.filename = self.input_path[0]
849 # evenement attaché au menu 'ouvrir analyse'
850 def OnSubText(self, evt, corpus = None, parametres = None):
853 corpus = self.tree.getcorpus()
854 if evt.GetId() == ID_Subtxtfrommeta :
855 parametres = {'frommeta' : True}
856 elif evt.GetId() == ID_Subtxtfromthem :
857 parametres = {'fromtheme' : True}
858 builder = SubBuilder(self, corpus, parametres)
859 if builder.res == wx.ID_OK :
860 busy = wx.BusyInfo(_("Please wait..."), self)
862 corpus = builder.doanalyse()
863 self.history.add(corpus.parametres)
864 OpenAnalyse(self, corpus.parametres)
865 self.tree.OnItemAppend(corpus.parametres)
868 # action d'ouverture d'un texte
871 builder = Builder(self, 5)
872 if builder.res == wx.ID_OK :
874 corpus = builder.doanalyse()
875 self.history.add(corpus.parametres)
876 self.tree.OnItemAppend(corpus.parametres)
877 OpenAnalyse(self, corpus.parametres)
879 builder.dlg.Destroy()
883 keepGoing = builder.dlg.Update(count, "Lecture du fichier")
884 self.ShowMenu('view')
885 self.ShowMenu('text')
886 self.ShowMenu('matrix', False)
891 keepGoing = builder.dlg.Update(count, "Chargement du dictionnaire")
892 builder.dlg.Destroy()
894 # evenement attaché au menu 'quitter'
895 def OnExit(self, event):
898 # evenement attaché au menu 'à propos'
899 def OnAbout(self, event):
901 info = wx.adv.AboutDialogInfo()
902 info.Name = ConfigGlob.get('DEFAULT', 'name')
903 info.Version = ConfigGlob.get('DEFAULT', 'version')
904 info.Copyright = ConfigGlob.get('DEFAULT', 'copyright')
905 info.Translators = ConfigGlob.get('DEFAULT', 'translators').split(';')
906 info.Description = """
907 Interface de R pour les Analyses Multidimensionnelles
908 de Textes et de Questionnaires
911 construit avec des logiciels libres.
917 info.WebSite = ("http://www.iramuteq.org", "Site web IRaMuTeQ")
918 dev = ConfigGlob.get('DEFAULT', 'dev').split(';')
919 info.Developers = dev
920 info.License = """Iramuteq est un logiciel libre ; vous pouvez le diffuser et/ou le modifier
921 suivant les termes de la Licence Publique Générale GNU telle que publiée
922 par la Free Software Foundation ; soit la version 2 de cette licence,
923 soit (à votre convenance) une version ultérieure.
925 Iramuteq est diffusé dans l'espoir qu'il sera utile,
926 mais SANS AUCUNE GARANTIE ; sans même une garantie implicite
927 de COMMERCIALISATION ou d'ADÉQUATION À UN USAGE PARTICULIER.
928 Voyez la Licence Publique Générale GNU pour plus de détails.
930 Vous devriez avoir reçu une copie de la Licence Publique Générale GNU
931 avec Iramuteq ; sinon, veuillez écrire à la Free Software Foundation,
932 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis."""
933 wx.adv.AboutBox(info)
935 # appelé seulement pour l'initialisation de la fenetre principale de Iramuteq
936 def GetDockArt(self):
937 return self._mgr.GetArtProvider()
939 # appelé seulement pour l'initialisation de la fenetre principale de Iramuteq
943 # action ou évènement ?
944 def OnPageChanged(self, event) :
945 new = event.GetSelection()
946 nobject = event.GetEventObject()
947 parent = nobject.GetParent()
948 if isinstance(parent, IraFrame) :
949 npage = self.nb.GetPage(new)
950 if 'parametres' in dir(npage) :
951 self.tree.GiveFocus(uuid=npage.parametres['uuid'])
953 # action ou évènement ?
954 def OnCloseTab(self, evt):
955 #log.info('Closing tab %s' % str(evt.GetEventObject()))
956 ctrl = evt.GetEventObject()
957 if isinstance(ctrl.GetParent(), aui.AuiNotebook) or isinstance(ctrl.GetParent(), wx.Panel):
961 page = self.nb.GetPage(self.nb.GetSelection())
962 if 'parametres' in dir(page) and isinstance(ctrl.GetParent(), IraFrame) :
963 self.history.rmtab(page.parametres)
964 self.tree.CloseItem(uuid = page.parametres['uuid'])
965 TabTitle = self.nb.GetPageText(self.nb.GetSelection())
966 if self.nb.GetPageCount() == 1 and not notebook :
969 # action ou évènement ?
970 def LastTabClose(self) :
971 if self.nb.GetPageCount() == 1 :
973 self.ShowAPane("Text")
975 self.ShowAPane("Data")
977 self.ShowAPane("Intro_Text")
979 # action ou évènement ?
980 def GetStartPosition(self):
983 pt = self.ClientToScreen(wx.Point(0, 0))
984 return wx.Point(pt.x + x, pt.y + x)
986 # action ou évènement ?
987 def ShowAPane(self, panel):
989 for pane in self._mgr.GetAllPanes() :
990 if not pane.IsToolbar() and pane.name != 'lefttree':
992 self._mgr.GetPane(panel).Show()
994 wx.CallAfter(self.nb.SendSizeEvent)
997 # action ou évènement ?
998 def OnAcceuil(self, event):
999 self.ShowAPane("Intro_Text")
1002 # action ou évènement ?
1003 def CreateHTMLCtrl(self):
1004 ctrl = wx.html.HtmlWindow(self, -1, wx.DefaultPosition, wx.Size(400, 300))
1005 if "gtk2" in wx.PlatformInfo:
1006 ctrl.SetStandardFonts()
1007 ctrl.SetPage("text")
1010 # action ou évènement ?
1011 def ShowTab(self, evt):
1012 self.ShowAPane("Tab_content")
1014 ################################################################
1016 ################################################################
1017 def analyse_matrix(self, analyse, analyse_type = '', matrix = None, parametres = None, dlgnb = 1):
1019 matrix = self.tree.getmatrix()
1020 if parametres is not None :
1021 parametres['type'] = analyse_type
1023 parametres = {'type' : analyse_type}
1025 #print 'plus de bug@@@@@@@@@@@@@@@@@@@@@@'
1026 analyse(self, matrix, parametres = parametres, dlg = dlgnb)
1030 def OnFreq(self, event, matrix = None):
1031 self.analyse_matrix(Frequences, analyse_type = 'freq', matrix = matrix, dlgnb = 3)
1033 def OnFreqMulti(self, event, matrix = None):
1034 self.analyse_matrix(FreqMultiple, analyse_type = 'freqmulti', matrix = matrix, dlgnb = 3)
1036 def OnChi2(self, event, matrix = None):
1037 self.analyse_matrix(ChiSquare, matrix = matrix, analyse_type = 'chi2', dlgnb = 3)
1039 def OnChi2McNemar(self, event, matrix = None):
1040 self.analyse_matrix(McNemar, matrix = matrix, analyse_type = 'chi2mcnemar', dlgnb = 3)
1042 def OnSimiTab(self, event, matrix = None):
1043 self.analyse_matrix(DoSimi, matrix = matrix, analyse_type = 'simimatrix', dlgnb = 5)
1045 def OnCategorisation(self, event, matrix = None) :
1046 self.analyse_matrix(Categorisation, matrix = matrix, analyse_type = 'categorisation', dlgnb = 1)
1049 def OnCHDReinert(self, event, matrix = None):
1050 #if matrix is None :
1051 # matrix = self.tree.getmatrix()
1052 #AnalyseQuest(self, matrix, parametres = {'type' : 'reinertmatrix'}, dlg = 3)
1053 self.analyse_matrix(AnalyseQuest, matrix = matrix, analyse_type = 'reinertmatrix', dlgnb = 5)
1055 def OnStudent(self, event):
1061 def OnRCode(self, event):
1067 def OnCHDSIM(self, event):
1069 chdsim = ChdCluster(self)
1070 if chdsim.val == wx.ID_OK:
1075 # def OnCHDReinert(self, event):
1077 # # print('PLUS DE BUG SUR ALCESTE QUESTIONNAIRE')
1078 # self.quest = AnalyseQuest(self)
1079 # if self.quest.val == wx.ID_OK:
1084 def OnMergeGraph(self, evt):
1086 AnalyseMerge(self, {'type': 'merge', 'fileout' : '/tmp/test.txt'}, dlg = 5)
1088 def OnMergeClusters(self, evt) :
1089 print('on merge clusters')
1090 builder = MergeClusters(self, {})
1091 if builder.res == wx.ID_OK :
1092 busy = wx.BusyInfo(_("Please wait..."), self)
1094 corpus = builder.doanalyse()
1095 self.history.add(corpus.parametres)
1096 OpenAnalyse(self, corpus.parametres)
1097 self.tree.OnItemAppend(corpus.parametres)
1100 def OnProto(self, evt, matrix = None) :
1101 self.analyse_matrix(Prototypical, matrix = matrix, analyse_type = 'proto', dlgnb = 3)
1102 #Prototypical(self, {'type' : 'proto'})
1104 def OnSplitVar(self, evt, matrix = None):
1106 matrix = self.tree.getmatrix()
1107 self.analyse_matrix(SplitMatrixFromVar, matrix = matrix, analyse_type = 'splitvar', parametres = {'pathout': matrix.pathout.dirout}, dlgnb = 3)
1108 #matrix = self.tree.getmatrix()
1110 def OnSimiTxt(self, evt, corpus = None) :
1112 #self.Text = SimiTxt(self)
1114 corpus = self.tree.getcorpus()
1115 self.Text = SimiTxt(self, corpus, parametres = {'type': 'simitxt'}, dlg = 3)
1116 if self.Text.val == wx.ID_OK :
1121 def OnWordCloud(self, evt, corpus = None) :
1124 corpus = self.tree.getcorpus()
1125 self.Text = WordCloud(self, corpus, parametres = {'type' : 'wordcloud'}, dlg = 3)
1126 if self.Text.val == wx.ID_OK :
1131 def OnClusterCloud(self, corpus, parametres = None) :
1132 self.Text = ClusterCloud(self, corpus, parametres = parametres, dlg = 3)
1134 def OnAFCM(self, event):
1140 def OnTextStat(self, event, corpus = None):
1143 corpus = self.tree.getcorpus()
1144 self.Text = Stat(self, corpus, parametres = {'type': 'stat'}, dlg = 7)
1145 if self.Text.val == wx.ID_OK :
1150 def OnTextSpec(self, event, corpus = None):
1152 #self.Text = AsLexico(self)
1154 corpus = self.tree.getcorpus()
1155 self.Text = Lexico(self, corpus, parametres = {'type' : 'spec'}, dlg = 3)
1156 if self.Text.val == wx.ID_OK :
1161 def OnTextLabbe(self, event, corpus = None):
1164 corpus = self.tree.getcorpus()
1165 self.Text = DistLabbe(self, corpus, parametres = {'type' : 'labbe'}, dlg = 3)
1166 if self.Text.val == wx.ID_OK :
1171 def OnTextAfcm(self, event):
1178 def import_factiva_xml(self,event):
1180 ImportFactiva(self, 'xml')
1184 def import_factiva_mail(self, evt) :
1186 ImportFactiva(self, 'mail')
1190 def import_factiva_txt(self, evt) :
1192 ImportFactiva(self, 'txt')
1196 def OnImportTXM(self, evt) :
1198 ImportFactiva(self, 'txm')
1202 def OnImportEuropress(self, evt) :
1204 ImportFactiva(self, 'euro')
1208 def OnImportDMI(self, evt):
1211 def OnExportMeta(self, evt, corpus = None):
1213 corpus = self.tree.getcorpus()
1215 ExportMetaTable(self, corpus)
1219 def ExtractTools(self, evt) :
1221 if ID == self.ID_splitvar :
1222 Extract(self, 'splitvar')
1223 elif ID == self.ID_extractmod :
1224 Extract(self, 'mods')
1225 elif ID == self.ID_extractthem :
1226 Extract(self, 'them')
1228 def OnTextReinert(self, event, corpus = None):
1230 #RunAnalyse(self, corpus, Alceste, OptAlceste)
1232 corpus = self.tree.getcorpus()
1233 self.Text = Reinert(self, corpus, parametres = {'type': 'alceste'}, dlg = 6)
1234 if self.Text.val == wx.ID_OK:
1239 def OnPamSimple(self, event, corpus = None):
1242 corpus = self.tree.getcorpus()
1243 self.Text = AnalysePam(self, corpus, parametres = {'type' : 'pamtxt'}, dlg = 6)
1244 if self.Text.val == wx.ID_OK:
1249 def SimiCluster(self, parametres = {}, fromprof = False, tableau = None) :
1250 self.analyse_matrix(DoSimi, parametres = parametres, analyse_type = 'simiclustermatrix', matrix = tableau, dlgnb = 5)
1252 # def OnSimi(self,evt):
1254 # self.res = DoSimi(self, param = None)
1255 #self.res = Verges(self)
1256 # if self.res.val == wx.ID_OK :
1261 def OnHelp(self, event):
1262 webbrowser.open('http://www.iramuteq.org/documentation')
1264 def OnPref(self, event):
1265 dlg = PrefDialog(self)
1266 dlg.CenterOnParent()
1267 self.val = dlg.ShowModal()
1271 if self.check_update:
1274 print('pas de verif')
1276 #CheckRPackages(self)
1278 def OnOpenFromCmdl(self):
1280 if options.filename :
1281 if os.path.exists(options.filename):
1282 self.filename = os.path.abspath(options.filename)
1286 if os.path.exists(os.path.realpath(args[0])):
1287 self.filename = os.path.abspath(os.path.realpath(args[0]))
1293 if os.path.splitext(self.filename)[1] in ['.csv', '.xls', '.ods']:
1294 self.tableau = Tableau(self, self.filename)
1295 val = get_table_param(self, self.filename)
1296 if val == wx.ID_OK :
1297 self.tableau.make_content()
1298 OpenAnalyse(self, self.tableau.parametres)
1299 self.tree.OnItemAppend(self.tableau.parametres)
1300 #get_table_param(self, self.filename)
1301 #self.tableau.make_content()
1302 #self.tableau.show_tab()
1303 #open_data(self, self.filename)
1304 elif os.path.splitext(self.filename)[1] == '.txt':
1306 elif os.path.splitext(self.filename)[1] == '.ira' :
1307 #self.corpus = Corpus(self)
1308 #self.Text = OpenAnalyse(self, self.filename)
1309 OpenAnalyse(self, self.filename)
1311 print('This file does not exist')
1314 #--------------------------------------------------------------------
1315 # contenu de l'ecran d'accueil
1316 # appelé seulement dans l'initialisation de IraFrame
1317 #--------------------------------------------------------------------
1318 class IntroPanel(wx.Panel):
1319 def __init__(self, parent):
1320 wx.Panel.__init__(self, parent)
1321 #col = randint(0, 255)
1322 #col1 = randint(0,255)
1323 #col2 = randint(0,255)
1328 bckgrdcolor = wx.Colour(col, col1, col2)
1329 self.SetBackgroundColour(bckgrdcolor)
1330 txtcolour = wx.Colour(250, 250, 250)
1331 linkcolor = wx.Colour(255, 0, 0)
1332 sizer1 = wx.BoxSizer(wx.VERTICAL)
1333 sizer2 = wx.BoxSizer(wx.VERTICAL)
1334 sizer4 = wx.BoxSizer(wx.HORIZONTAL)
1335 grid_sizer_1 = wx.FlexGridSizer(1, 4, 0, 0)
1336 grid_sizer_3 = wx.FlexGridSizer(1, 4, 0, 0)
1337 grid_sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
1338 iralink = hl.HyperLinkCtrl(self,
1340 "http://www.iramuteq.org",
1341 URL="http://www.iramuteq.org")
1342 iralink.SetColours(linkcolor, linkcolor, "RED")
1343 iralink.SetBackgroundColour(bckgrdcolor)
1344 iralink.EnableRollover(True)
1345 iralink.SetUnderlines(False, False, True)
1346 iralink.SetBold(True)
1347 iralink.UpdateLink()
1348 PanelPres = wx.Panel(self)
1349 bckgrdcolor = wx.Colour(randint(0, 255), randint(0, 255), randint(0, 255))
1350 PanelPres.SetBackgroundColour(bckgrdcolor)
1351 label_1 = wx.StaticText(self, -1, "IRaMuTeQ", size=(-1, -1))
1352 label_1.SetFont(wx.Font(46,
1353 wx.FONTFAMILY_TELETYPE,
1354 wx.FONTSTYLE_NORMAL,
1358 label_1.SetForegroundColour(wx.RED)
1359 iraicone = wx.Image(os.path.join(ImagePath,'iraicone100x100.png'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1360 but_ira = wx.StaticBitmap(self, -1, bitmap = iraicone)
1361 label2 = wx.StaticText(PanelPres, -1 , '\nVersion ' + ConfigGlob.get('DEFAULT', 'version') + '\n')
1362 label2.SetForegroundColour(txtcolour)
1363 label2.SetBackgroundColour(bckgrdcolor)
1364 self.hyper2 = hl.HyperLinkCtrl(PanelPres, wx.ID_ANY, "REPERE", URL="http://repere.no-ip.org/")
1365 self.hyper2.SetColours(linkcolor, linkcolor, "RED")
1366 self.hyper2.SetBackgroundColour(bckgrdcolor)
1367 self.hyper2.EnableRollover(True)
1368 self.hyper2.SetUnderlines(False, False, True)
1369 self.hyper2.SetBold(True)
1370 self.hyper2.UpdateLink()
1371 label_lerass = wx.StaticText(PanelPres, -1, 'Laboratoire ')
1372 label_lerass.SetForegroundColour(txtcolour)
1373 label_lerass.SetBackgroundColour(bckgrdcolor)
1374 self.hyper_lerass = hl.HyperLinkCtrl(PanelPres, -1, 'LERASS', URL="http://www.lerass.com")
1375 self.hyper_lerass.SetColours(linkcolor, linkcolor, "RED")
1376 self.hyper_lerass.SetBackgroundColour(bckgrdcolor)
1377 self.hyper_lerass.EnableRollover(True)
1378 self.hyper_lerass.SetUnderlines(False, False, True)
1379 self.hyper_lerass.SetBold(True)
1380 self.hyper_lerass.UpdateLink()
1381 blank = wx.StaticText(PanelPres, -1, '\n')
1382 blank1 = wx.StaticText(PanelPres, -1, '\n')
1383 labellicence = wx.StaticText(PanelPres, -1, _("License GNU GPL"))
1384 labellicence.SetForegroundColour(txtcolour)
1385 labellicence.SetBackgroundColour(bckgrdcolor)
1386 labelcopy = wx.StaticText(PanelPres, -1, ConfigGlob.get('DEFAULT', 'copyright'))
1387 labelcopy.SetForegroundColour(txtcolour)
1388 labelcopy.SetBackgroundColour(bckgrdcolor)
1389 python_img = wx.Image(os.path.join(ImagePath,'python-logo.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1390 r_img = wx.Image(os.path.join(ImagePath,'Rlogo.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1391 lexique_img = wx.Image(os.path.join(ImagePath,'LexTexte4.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
1392 but_python = wx.BitmapButton(self, -1, python_img)
1393 but_lexique = wx.BitmapButton(self, -1, lexique_img)
1394 but_r = wx.BitmapButton(self, -1, r_img)
1395 self.Bind(wx.EVT_BUTTON, self.OnPython, but_python)
1396 self.Bind(wx.EVT_BUTTON, self.OnLexique, but_lexique)
1397 self.Bind(wx.EVT_BUTTON, self.OnR, but_r)
1398 grid_sizer_1.Add(self.hyper2, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1399 grid_sizer_3.Add(label_lerass, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1400 grid_sizer_3.Add(self.hyper_lerass, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
1401 sizer4.Add(label_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5)
1402 sizer2.Add(label2, 0, wx.ALIGN_CENTER, 5)
1403 sizer2.Add(wx.StaticText(PanelPres, -1, ''), 0, wx.ALIGN_CENTER, 5)
1404 sizer2.Add(wx.StaticText(PanelPres, -1, ''), 0, wx.ALIGN_CENTER, 5)
1405 sizer2.Add(grid_sizer_3, 0, wx.ALIGN_CENTER, 5)
1406 sizer2.Add(wx.StaticText(PanelPres, -1, ' '), 0, wx.ALIGN_CENTER, 5)
1407 sizer2.Add(grid_sizer_1, 0, wx.ALIGN_CENTER, 5)
1408 sizer2.Add(labellicence, 0, wx.ALIGN_CENTER, 5)
1409 sizer2.Add(labelcopy, 0, wx.ALIGN_CENTER, 5)
1410 sizer1.Add(sizer4, 2, wx.ALIGN_CENTER_HORIZONTAL, 0)
1411 sizer1.Add(but_ira, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5)
1412 sizer1.Add(iralink, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_TOP, 5)
1413 sizer2.Add(wx.StaticText(PanelPres, -1, ''), 0, wx.ALIGN_CENTER, 10)
1414 PanelPres.SetSizer(sizer2)
1415 grid_sizer_2.Add(but_python, 1, wx.ALIGN_BOTTOM)
1416 grid_sizer_2.Add(but_lexique, 1, wx.ALIGN_BOTTOM)
1417 grid_sizer_2.Add(but_r, 1, wx.ALIGN_BOTTOM)
1418 sizer1.Add(PanelPres, 0, wx.EXPAND |wx.ALL, 10)
1419 sizer1.Add(grid_sizer_2, 2, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 1)
1420 self.SetSizer(sizer1)
1423 def OnPython(self,evt):
1424 webbrowser.open('http://www.python.org')
1426 def OnLexique(self,evt):
1427 webbrowser.open('http://www.lexique.org')
1430 webbrowser.open('http://www.r-project.org')
1433 #--------------------------------------------------------------------
1435 # appelé seulement par MyApp
1436 #--------------------------------------------------------------------
1437 class MySplashScreen(wx.adv.SplashScreen):
1440 bmp = wx.Image(os.path.join(ImagePath, 'splash.png')).ConvertToBitmap()
1441 wx.adv.SplashScreen.__init__(self, bmp,
1442 wx.adv.SPLASH_CENTRE_ON_SCREEN |
1443 wx.adv.SPLASH_TIMEOUT,
1447 self.Bind(wx.EVT_CLOSE, self.OnClose)
1448 self.fc = wx.CallLater(1, self.ShowMain)
1450 def OnClose(self, evt):
1453 if self.fc.IsRunning():
1458 displaySize = wx.DisplaySize()
1459 w = displaySize[0]/1.2
1460 h = displaySize[1]/1.2
1461 frame = IraFrame(None, -1, "IRaMuTeQ " + ConfigGlob.get('DEFAULT', 'version'), size=(int(w), int(h)))
1465 frame.OnOpenFromCmdl()
1466 #if self.fc.IsRunning():
1468 #wx.CallAfter(frame.ShowTip)
1471 class MyApp(wx.App):
1475 Create and show the splash screen. It will then create and show
1476 the main frame when it is time to do so.
1478 wx.SystemOptions.SetOption("mac.window-plain-transition", 1)
1479 self.SetAppName("Iramuteq")
1480 splash = MySplashScreen()
1488 if __name__ == '__main__':