#License: GNU GPL
from optparse import OptionParser
+from wx import BusyCursor
parser = OptionParser()
parser.add_option("-f", "--file", dest="filename",
help="open FILE", metavar="FILE", default=False)
(options, args) = parser.parse_args()
-#print args
-#print options
import sys
reload(sys)
import locale
import tempfile
import codecs
import os
-import shutil
from random import randint
-from ConfigParser import *
+from ConfigParser import ConfigParser, RawConfigParser
import webbrowser
import gettext
import logging
#------------------------------------
import wx
-#import wx.aui
import wx.lib.agw.aui as aui
import wx.html
import wx.grid
import wx.lib.hyperlink as hl
#------------------------------------
-from functions import BugReport, PlaySound, ReadLexique, History, DoConf, ReadDicoAsDico, progressbar
+from functions import BugReport, PlaySound, History
from checkversion import NewVersion
from guifunct import *
from tableau import Tableau
-from dialog import PrefDialog, CorpusPref
-from tabfrequence import Frequences
+from dialog import PrefDialog
+from tabfrequence import Frequences, FreqMultiple
from tabchi2 import ChiSquare
#from tabstudent import MakeStudent
from tabchddist import ChdCluster
from tabrsimple import InputText
from tabverges import Prototypical
from tabsplitvar import SplitMatrixFromVar
-#from textafcuci import AfcUci
-from textdist import AnalysePam
+#from textdist import AnalysePam
from textstat import Stat
from textaslexico import Lexico
from textsimi import SimiTxt, SimiFromCluster
from textwordcloud import WordCloud, ClusterCloud
from textreinert import Reinert
-#from profile_segment import ProfileSegment
#from textcheckcorpus import checkcorpus
from openanalyse import OpenAnalyse
from corpus import Builder, SubBuilder
-#from sheet import MySheet
from checkinstall import CreateIraDirectory, CheckRPath, FindRPAthWin32, FindRPathNix, CheckRPackages, IsNew, UpgradeConf, CopyConf, RLibsAreInstalled
from chemins import RscriptsPath, ConstructConfigPath, ConstructDicoPath, ConstructGlobalPath, PathOut
from parse_factiva_xml import ImportFactiva
ID_SimiTxt = wx.NewId()
ID_proto = wx.NewId()
ID_ImportTXM = wx.NewId()
+ID_FreqMulti = wx.NewId()
##########################################################
#elements de configuration
##########################################################
DictConfigPath = ConstructGlobalPath(AppliPath)
ConfigGlob = ConfigParser()
ConfigGlob.read(DictConfigPath['global'])
+DefaultConf = ConfigParser()
+DefaultConf.read(DictConfigPath['preferences'])
#repertoire de l'utilisateur
if os.getenv('HOME') != None:
user_home = os.getenv('HOME')
ConfigPath = ConstructConfigPath(UserConfigPath)
langues = {'french' : wx.LANGUAGE_FRENCH,
- 'english' : wx.LANGUAGE_ENGLISH,}
+ 'english' : wx.LANGUAGE_ENGLISH,
+ 'portuguese' : wx.LANGUAGE_PORTUGUESE,
+ 'italian' : wx.LANGUAGE_ITALIAN,
+ 'spanish' : wx.LANGUAGE_SPANISH
+ }
+
+code_langues = {'french' : 'fr_FR',
+ 'english' : 'en',
+ 'portuguese' : 'pt_PT',
+ 'italian' : 'it_IT',
+ 'spanish' : 'es_ES'
+ }
#####################################################################
class IraFrame(wx.Frame):
self.SimiFromCluster = SimiFromCluster
#langues
gettext.install('iramuteq', os.path.join(AppliPath,'locale'), unicode=True)
- self.presLan_fr = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=['fr_FR'])
- self.presLan_en = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=['en'])
+ #langues = ['fr_FR', 'en', 'pt_PT']
+ #for l in langues :
+ # pass
+ self.preslangue = {}
+ for langue in code_langues :
+ self.preslangue[langue] = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=[code_langues[langue]])
self.setlangue()
+ #self.presLan_fr = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=['fr_FR'])
+ #self.presLan_en = gettext.translation("iramuteq", os.path.join(AppliPath,'locale'), languages=['en'])
# tell FrameManager to manage this frame
#self._mgr = wx.aui.AuiManager()
self._mgr = aui.AuiManager()
file_menu.Append(wx.ID_EXIT, _(u"Exit").decode('utf8'))
edit_menu = wx.Menu()
- edit_menu.Append(wx.ID_PREFERENCES, '', _(u'Preferences').decode('utf8'))
+ edit_menu.Append(wx.ID_PREFERENCES, _(u'Preferences').decode('utf8'))
view_menu = wx.Menu()
view_menu.Append(ID_ACCEUIL, _(u"Home page").decode('utf8'))
#view_menu.AppendSeparator()
matrix_menu = wx.Menu()
matrix_menu.Append(ID_Freq, _(u"Frequencies").decode('utf8'))
+ matrix_menu.Append(ID_FreqMulti, _(u'Multiple frequencies').decode('utf8'))
matrix_menu.Append(ID_Chi2, _(u"Chi2").decode('utf8'))
#matrix_menu.Append(ID_Student, u"t de Student")
menu_classif = wx.Menu()
matrix_menu.Append(ID_SIMI, _(u"Similarities Analysis").decode('utf8'))
matrix_menu.Append(ID_proto, _(u"Prototypical Analysis").decode('utf8'))
ID_RCODE = wx.NewId()
- matrix_menu.Append(ID_RCODE, u"Code R...")
+ #matrix_menu.Append(ID_RCODE, u"Code R...")
#menu_splittab = wx.Menu()
#ID_SPLITVAR = wx.NewId()
#splitvar = wx.MenuItem(menu_splittab, ID_SPLITVAR, _(u"Split from variable").decode('utf8'))
#--------------------------------------------------------------------
self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP)
self.statusbar.SetStatusWidths([-2, -3])
- self.statusbar.SetStatusText(u"Prêt", 0)
- self.statusbar.SetStatusText(u"Bienvenue", 1)
+ self.statusbar.SetStatusText(_(u"Ready").decode('utf8'), 0)
+ self.statusbar.SetStatusText(_(u"Welcome").decode('utf8'), 1)
# min size for the frame itself isn't completely done.
# see the end up FrameManager::Update() for the test
# f.write('')
self.history = History(os.path.join(UserConfigPath, 'history.db'))
self.tree = LeftTree(self)
- self._mgr.AddPane(self.tree, aui.AuiPaneInfo().Name("lefttree").Caption(_(u"Navigator").decode('utf8')).
+ self._mgr.AddPane(self.tree, aui.AuiPaneInfo().Name("lefttree").Caption(_(u"Historic").decode('utf8')).
Left().MinSize(wx.Size(200,500)).Layer(1).Position(1).CloseButton(False).MaximizeButton(True).
MinimizeButton(True))
self.Bind(wx.EVT_MENU, self.ExtractTools, extractmod)
self.Bind(wx.EVT_MENU, self.ExtractTools, extractthem)
self.Bind(wx.EVT_MENU, self.OnFreq, id=ID_Freq)
+ self.Bind(wx.EVT_MENU, self.OnFreqMulti, id=ID_FreqMulti)
self.Bind(wx.EVT_MENU, self.OnChi2, id=ID_Chi2)
self.Bind(wx.EVT_MENU, self.OnStudent, id=ID_Student)
self.Bind(wx.EVT_MENU, self.OnCHDSIM, id=ID_CHDSIM)
self.Bind(wx.EVT_MENU, self.OnCHDReinert, id=ID_CHDReinert)
self.Bind(wx.EVT_MENU, self.OnAFCM, id=ID_AFCM)
self.Bind(wx.EVT_MENU, self.OnProto, id=ID_proto)
- self.Bind(wx.EVT_MENU, self.OnRCode, id=ID_RCODE)
+ #self.Bind(wx.EVT_MENU, self.OnRCode, id=ID_RCODE)
#self.Bind(wx.EVT_MENU, self.OnSplitVar, id=ID_SPLITVAR)
#self.Bind(wx.EVT_MENU, self.OnCheckcorpus, id = ID_CHECKCORPUS)
self.Bind(wx.EVT_MENU, self.OnTextStat, id=ID_TEXTSTAT)
##############################################################@
self.DisEnSaveTabAs(False)
- self.ShowMenu(_("View").decode('utf8'), False)
- self.ShowMenu(_("Matrix analysis").decode('utf8'), False)
- self.ShowMenu(_("Text analysis").decode('utf8'), False)
+ self.ShowMenu('view', False)
+ self.ShowMenu('matrix', False)
+ self.ShowMenu('text', False)
self._mgr.Update()
pass
dlg.Destroy()
-
def setlangue(self) :
+ self.pref.read(self.ConfigPath['preferences'])
try :
- self.pref.read(self.ConfigPath['preferences'])
guilangue = self.pref.get('iramuteq', 'guilanguage')
- if guilangue == 'french' :
- self.presLan_fr.install()
- else :
- self.presLan_en.install()
- mylocale = wx.Locale(langues[guilangue])
- mylocale.AddCatalogLookupPathPrefix(os.path.join(AppliPath,'locale'))
- mylocale.AddCatalog('iramuteq')
except :
- self.presLan_fr.install()
- mylocale = wx.Locale(langues['french'])
- mylocale.AddCatalogLookupPathPrefix(os.path.join(AppliPath,'locale'))
- mylocale.AddCatalog('iramuteq')
-
+ guilangue = DefaultConf.get('iramuteq', 'guilanguage')
+ self.preslangue.get(guilangue, 'english').install()
def OnVerif(self, evt) :
pack = CheckRPackages(self)
item.Enable(DISEN)
def ShowMenu(self, menu, Show=True):
- menu_pos = self.mb.FindMenu(menu)
- self.mb.EnableTop(menu_pos, Show)
- self.mb.UpdateMenus()
+ if menu == 'text' :
+ menu_pos = 4
+ elif menu == 'matrix' :
+ menu_pos = 3
+ elif menu == 'view' :
+ menu_pos = 2
+ else :
+ menu_pos = None
+
+ #menu_pos = self.mb.FindMenu(menu)
+ if not menu_pos is None :
+ self.mb.EnableTop(menu_pos, Show)
+ self.mb.UpdateMenus()
#--------------------------------------------------------------------
self.tableau = Tableau(self,os.path.abspath(self.input_path[0]))
val = get_table_param(self, self.input_path[0])
if val == wx.ID_OK :
- self.tableau.make_content()
- OpenAnalyse(self, self.tableau.parametres)
- self.tree.OnItemAppend(self.tableau.parametres)
+ busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self)
+ wx.SafeYield()
+ try :
+ self.tableau.make_content()
+ OpenAnalyse(self, self.tableau.parametres)
+ self.tree.OnItemAppend(self.tableau.parametres)
+ del busy
+ except :
+ del busy
+ BugReport(self)
#self.tableau.show_tab()
def OnOpenAnalyse(self, event):
self.AnalysePath = OnOpen(self, "Analyse")
OpenAnalyse(self, self.AnalysePath[1][0], True)
- self.ShowMenu(_("View"))
+ self.ShowMenu('view')
def OnOpenText(self, event):
inputname, self.input_path = OnOpen(self, "Texte")
self.OpenText()
def OnViewData(self, event):
- print self.type
- print self.DataTxt
if self.type == "Data":
if not self.DataPop :
self.Sheet.Populate(self.content)
def OnSubText(self, corpus, parametres = None):
if corpus is None :
corpus = self.tree.getcorpus()
- busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self)
- wx.SafeYield()
builder = SubBuilder(self, corpus, parametres)
- del busy
if builder.res == wx.ID_OK :
+ busy = wx.BusyInfo(_("Please wait...").decode('utf8'), self)
+ wx.SafeYield()
corpus = builder.doanalyse()
- print corpus.parametres['uuid']
self.history.add(corpus.parametres)
self.tree.OnItemAppend(corpus.parametres)
OpenAnalyse(self, corpus.parametres)
+ del busy
def OpenText(self):
dlg = wx.ProgressDialog("Ouverture...",
self.tree.OnItemAppend(corpus.parametres)
OpenAnalyse(self, corpus.parametres)
except :
+ dlg.Destroy()
BugReport(self)
else :
count = 1
keepGoing = dlg.Update(count, u"Lecture du fichier")
- self.ShowMenu(_(u"View").decode('utf8'))
- self.ShowMenu(_(u"Text analysis").decode('utf8'))
- self.ShowMenu(_(u"Matrix analysis").decode('utf8'), False)
+ self.ShowMenu('view')
+ self.ShowMenu('text')
+ self.ShowMenu('matrix', False)
self.type = "Texte"
self.DataTxt = False
self.Text = ''
if 'parametres' in dir(npage) :
self.tree.GiveFocus(uuid=npage.parametres['uuid'])
if npage.parametres.get('matrix', False) :
- self.ShowMenu(_(u"Text analysis").decode('utf8'), False)
- self.ShowMenu(_(u"Matrix analysis").decode('utf8'), True)
+ self.ShowMenu('text', False)
+ self.ShowMenu('matrix', True)
elif npage.parametres.get('corpus', False) :
- self.ShowMenu(_(u"Text analysis").decode('utf8'))
- self.ShowMenu(_(u"Matrix analysis").decode('utf8'), False)
+ self.ShowMenu('text')
+ self.ShowMenu('matrix', False)
def OnCloseTab(self, evt):
#log.info('Closing tab %s' % str(evt.GetEventObject()))
self.history.rmtab(page.parametres)
self.tree.CloseItem(uuid = page.parametres['uuid'])
TabTitle = self.nb.GetPageText(self.nb.GetSelection())
-# if self.DictTab != {} :
-# if TabTitle in self.DictTab :
-# ListFile=self.DictTab[TabTitle]
-# if False in ListFile:
-# msg = u"""
-# Certains résultats ne sont pas enregistrer.
-# Voulez-vous fermer quand même ?"""
-# dlg = wx.MessageDialog(self, msg, "Sauvegarde",wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
-#
-# dlg.CenterOnParent()
-# if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
-# remove = False
-# evt.Veto()
-# dlg.Destroy()
-# else :
-# for f in ListFile[1:] :
-# print 'remove', f
-# os.remove(f)
-# remove = True
-# dlg.Destroy()
-# elif True in ListFile :
-# remove = True
-# if remove:
-# del self.DictTab[TabTitle]
-# else :
-# self.LastTabClose()
-# else :
-# remove = True
+
if self.nb.GetPageCount() == 1 and not notebook :
self.LastTabClose()
else :
self.ShowAPane("Intro_Text")
-# def OnSaveTabAs(self, event):
-# SelectTab = self.nb.GetSelection()
-# TabTitle = self.nb.GetPageText(SelectTab)
-# FileToSave = self.DictTab[TabTitle]
-# NewListFile = []
-# dlg = wx.FileDialog(
-# self, message="Enregistrer sous...", defaultDir=os.getcwd(),
-# defaultFile="resultat.html", wildcard="Tous les fichiers|*", style=wx.SAVE | wx.OVERWRITE_PROMPT
-# )
-# dlg.SetFilterIndex(2)
-# dlg.CenterOnParent()
-#
-# if dlg.ShowModal() == wx.ID_OK:
-# Path = dlg.GetPath()
-# Dirname = os.path.dirname(Path)
-# Filename = dlg.GetFilename()
-# else :
-# Path = False
-# dlg.Destroy()
-# if Path:
-# shutil.copyfile(FileToSave[-1], Path)
-# os.remove(FileToSave[len(FileToSave) - 1])
-# NewListFile.append(True)
-# NewListFile.append(Path)
-# for f in FileToSave[1:-1] :
-# Fileout = os.path.join(Dirname, os.path.basename(f))
-# shutil.copyfile(f, Fileout)
-# NewListFile.append(Fileout)
-# os.remove(f)
-# TabText = Filename
-# self.DictTab[TabText] = NewListFile
-# del self.DictTab[TabTitle]
-# self.nb.SetPageText(SelectTab, TabText)
-
def GetStartPosition(self):
self.x = self.x + 20
################################################################
#debut des analyses
################################################################
- def analyse_matrix(self, analyse, analyse_type = '', matrix = None, dlgnb = 1):
+ def analyse_matrix(self, analyse, analyse_type = '', matrix = None, parametres = None, dlgnb = 1):
if matrix is None :
matrix = self.tree.getmatrix()
- #try :
- analyse(self, matrix, parametres = {'type' : analyse_type}, dlg = progressbar(self, dlgnb))
- #except:
- # BugReport(self)
+ if parametres is not None :
+ parametres['type'] = analyse_type
+ else :
+ parametres = {'type' : analyse_type}
+ try :
+ #print 'plus de bug@@@@@@@@@@@@@@@@@@@@@@'
+ analyse(self, matrix, parametres = parametres, dlg = dlgnb)
+ except:
+ BugReport(self)
def OnFreq(self, event, matrix = None):
self.analyse_matrix(Frequences, analyse_type = 'freq', matrix = matrix, dlgnb = 3)
- #if matrix is None :
- # matrix = self.tree.getmatrix()
- #try:
- # Frequences(self, matrix, parametres = {'type' : 'freq'}, dlg = progressbar(self, 3))
- #except:
- # BugReport(self)
+
+ def OnFreqMulti(self, event, matrix = None):
+ self.analyse_matrix(FreqMultiple, analyse_type = 'freqmulti', matrix = matrix, dlgnb = 3)
def OnChi2(self, event, matrix = None):
- #try:
self.analyse_matrix(ChiSquare, matrix = matrix, analyse_type = 'chi2', dlgnb = 3)
- #except:
- # BugReport(self)
def OnSimiTab(self, event, matrix = None):
- if matrix is None :
- matrix = self.tree.getmatrix()
- try:
- DoSimi(self, matrix, parametres = {'type' : 'simimatrix'}, dlg = progressbar(self, 3))
- except:
- BugReport(self)
+ self.analyse_matrix(DoSimi, matrix = matrix, analyse_type = 'simimatrix', dlgnb = 5)
def OnCHDReinert(self, event, matrix = None):
- if matrix is None :
- matrix = self.tree.getmatrix()
- AnalyseQuest(self, matrix, parametres = {'type' : 'reinertmatrix'}, dlg = progressbar(self, 3))
+ #if matrix is None :
+ # matrix = self.tree.getmatrix()
+ #AnalyseQuest(self, matrix, parametres = {'type' : 'reinertmatrix'}, dlg = 3)
+ self.analyse_matrix(AnalyseQuest, matrix = matrix, analyse_type = 'reinertmatrix', dlgnb = 5)
def OnStudent(self, event):
try:
#Prototypical(self, {'type' : 'proto'})
def OnSplitVar(self, evt, matrix = None):
- self.analyse_matrix(SplitMatrixFromVar, matrix = matrix, analyse_type = 'splitvar', dlgnb = 3)
+ self.analyse_matrix(SplitMatrixFromVar, matrix = matrix, analyse_type = 'splitvar', parametres = {'pathout': matrix.pathout.dirout}, dlgnb = 3)
matrix = self.tree.getmatrix()
except:
BugReport(self)
- def SimiCluster(self, parametres = {}, fromprof = False, pathout = '', listactives = [], actives = [], tableau = None) :
- DoSimi(self, param = parametres, fromprof = fromprof, listactives = listactives, actives = actives, tableau = tableau)
+ def SimiCluster(self, parametres = {}, fromprof = False, tableau = None) :
+ self.analyse_matrix(DoSimi, parametres = parametres, analyse_type = 'simiclustermatrix', matrix = tableau, dlgnb = 5)
# def OnSimi(self,evt):
# try :