X-Git-Url: http://iramuteq.org/git?a=blobdiff_plain;f=layout.py;h=302cbed0b7762343702ab5002fa68b86ed9f8060;hb=refs%2Fheads%2F3.0;hp=19a53aff606acca28b0840dc4182e9beeaf044ab;hpb=14ef9adbd80ca7e8ed9ee3f108858fa7d7c24d5b;p=iramuteq diff --git a/layout.py b/layout.py index 19a53af..67411fc 100644 --- a/layout.py +++ b/layout.py @@ -46,6 +46,7 @@ from webexport import WebExport from corpus import Corpus from sheet import MySheet from graph_to_json import GraphToJson +#from listlex2 import LexPanel import langue @@ -251,7 +252,7 @@ class GraphPanelAfc(wx.Panel): """ txt += write_afc_graph(self) filetmp = tempfile.mktemp() - with open(filetmp, 'w') as f : + with open(filetmp, 'w', encoding='utf8') as f : f.write(txt) pid = exec_rcode(self.ira.RPath, filetmp) check_Rresult(self.ira, pid) @@ -420,7 +421,7 @@ class OpenCHDS(): for i in range(0, clnb) : clusternames[i] = ' '.join(['%i' % (i + 1), _('Cluster'), '%i' % (i + 1)]) if os.path.exists(self.pathout['classes_names.txt']) : - with codecs.open(self.pathout['classes_names.txt'], 'r', self.parent.syscoding) as f : + with open(self.pathout['classes_names.txt'], 'r', encoding='utf8') as f : clusternames_ = f.read() clusternames_ = dict([[i, ' '.join([repr(i + 1), line])] for i, line in enumerate(clusternames_.splitlines())]) clusternames.update(clusternames_) @@ -431,7 +432,7 @@ class OpenCHDS(): panel = wx.Panel(parent, -1) sizer1 = wx.BoxSizer(wx.VERTICAL) if os.path.exists(DictPathOut['pre_rapport']): - with codecs.open(DictPathOut['pre_rapport'], 'r') as f : + with open(DictPathOut['pre_rapport'], 'r', encoding='utf8') as f : txt = f.read() self.debtext = txt else : @@ -459,9 +460,12 @@ class OpenCHDS(): # self.TabChdSim = wx.aui.AuiNotebook(self.parent.nb, -1, wx.DefaultPosition) 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 panel.TabChdSim = aui.AuiNotebook(panel, -1, wx.DefaultPosition) - #panel.TabChdSim = LB.LabelBook(panel, -1, agwStyle = INB_TOP|INB_SHOW_ONLY_TEXT|INB_FIT_LABELTEXT) + + #panel.TabChdSim = LB.LabelBook(panel, -1, agwStyle = INB_TOP|INB_SHOW_ONLY_TEXT|INB_FIT_LABELTEXT) panel.TabChdSim.SetAGWWindowStyleFlag(notebook_flags) panel.TabChdSim.SetArtProvider(aui.ChromeTabArt()) + font = wx.Font(self.parent.fontsize, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) + panel.TabChdSim.SetFont(font) sizer1.Add(panel.TabChdSim,10, wx.EXPAND, 5) panel.SetSizer(sizer1) sizer1.Fit(panel) @@ -507,6 +511,7 @@ class OpenCHDS(): self.tab_prof_seg = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1) self.prof_seg_nb.AddPage(self.tab_prof_seg, _("Cluster") + ' %i' % (i + 1)) panel.ProfNB.SetSelection(0) + panel.ProfNB.SetFont(font) if clnb > 2 : self.TabAFC = aui.AuiNotebook(panel.TabChdSim, -1, wx.DefaultPosition) log.info('read AFC') @@ -544,7 +549,7 @@ class OpenCHDS(): self.parametres['tgenspec'] = os.path.join(self.parametres['pathout'], 'tgenchi2.csv') TgenLayout(panel) if os.path.exists(self.dictpathout['translations.txt']) : - with codecs.open(self.dictpathout['translations.txt'], 'r', 'utf8') as f: + with open(self.dictpathout['translations.txt'], 'r', encoding='utf8') as f: translist = f.read() translist = [line.split('\t') for line in translist.splitlines()] for line in translist : @@ -563,7 +568,7 @@ class OpenCHDS(): def opentrans(self, trans) : prof = ReadProfileAsDico(self.dictpathout[trans[0]], False) - with codecs.open(self.dictpathout[trans[1]], 'r') as f : + with open(self.dictpathout[trans[1]], 'r', encoding='utf8') as f : lems = f.read() lems = [line.split('\t') for line in lems.splitlines()] lems = dict(lems) @@ -634,7 +639,7 @@ def PrintRapport(self, corpus, parametres, istxt = True): txt += ''.join([sep, '###########################', sep, _('time'), ' : %s' % parametres.get('time', ''), sep, '###########################', sep]) # ecriture du resultat dans le fichier - with open(self.pathout['pre_rapport'], 'w') as f : + with open(self.pathout['pre_rapport'], 'w', encoding='utf8') as f : f.write(txt) @@ -736,6 +741,7 @@ class dolexlayout : self.dictpathout = StatTxtPathOut(parametres['pathout']) #self.corpus.read_corpus_from_shelves(self.corpus.dictpathout['db']) self.parent = ira + self.corpus.parametres['syscoding'] = 'UTF8' self.encoding = self.corpus.parametres['syscoding'] self.parametres = parametres self.DictSpec, first = ReadList(self.dictpathout['tablespecf'], self.corpus.parametres['syscoding']) @@ -750,15 +756,22 @@ class dolexlayout : #sash = SashList(ira.nb) self.TabStat = aui.AuiNotebook(ira.nb, -1, wx.DefaultPosition) self.TabStat.parametres = parametres + #self.ListPan = LexPanel(self, ira, self.DictSpec, self.etoiles) self.ListPan = ListForSpec(ira, self, self.DictSpec, self.etoiles) + self.ListPan.pathout = self.pathout if os.path.exists(self.pathout['banalites.csv']) : self.listban = ListForSpec(ira, self, self.dictban, ['eff'] + self.etoiles, usefirst = True) #self.ListPan2 = ListForSpec(sash.rightwin1, self, self.DictSpec, first) self.ListPant = ListForSpec(ira, self, self.DictType, self.etoiles) + self.ListPant.pathout = self.pathout self.ListPanEff = ListForSpec(ira, self, self.DictEff, self.etoiles) + self.ListPanEff.pathout = self.pathout self.ListPanEffType = ListForSpec(ira, self, self.DictEffType, self.etoiles) + self.ListPanEffType.pathout = self.pathout self.ListPanEffRelForme = ListForSpec(ira, self, self.DictEffRelForme, self.etoiles) + self.ListPanEffRelForme.pathout = self.pathout self.ListPanEffRelType = ListForSpec(ira, self, self.DictEffRelType, self.etoiles) + self.ListPanEffRelType.pathout = self.pathout self.TabStat.AddPage(self.ListPan, _('Forms')) if os.path.exists(self.pathout['banalites.csv']) : self.TabStat.AddPage(self.listban, _('Banal forms')) @@ -780,6 +793,7 @@ class dolexlayout : self.ira = ira self.TabStat.corpus = self.corpus self.TabStat.etoiles = self.etoiles + self.TabStat.pathout = self.pathout if os.path.exists(os.path.join(self.parametres['pathout'], 'tgenspec.csv')) : self.parametres['tgenspec'] = os.path.join(self.parametres['pathout'], 'tgenspec.csv') TgenLayout(self.TabStat) @@ -824,10 +838,10 @@ class StatLayout: lcle = {'total' :'total.csv', 'formes_actives':'formes_actives.csv', 'formes_supplémentaires':'formes_supplémentaires.csv', 'hapax': 'hapax.csv'} self.result = {} for key in lcle : - with codecs.open(self.pathout[lcle[key]], 'r', sys.getdefaultencoding()) as f : + with open(self.pathout[lcle[key]], 'r', encoding='utf-8') as f : self.result[key] = [line.split(';') for line in f.read().splitlines()] self.result[key] = dict([[i,[line[0],int(line[1]), line[2]]] for i, line in enumerate(self.result[key])]) - with open(self.pathout['glob.txt'], 'r') as f : + with open(self.pathout['glob.txt'], 'r', encoding='utf-8') as f : self.result['glob'] = f.read() @@ -990,7 +1004,7 @@ class GraphPanelDendro(wx.Panel): """ % (ffr(self.dictpathout['RData.RData']), ffr(self.ira.RscriptsPath['Rgraph']), ffr(fileout), width, height, svg, type_dendro, bw) tmpfile = tempfile.mktemp() # ecriture du fichier de script à éxécuter - with open(tmpfile, 'w') as f : + with open(tmpfile, 'w', encoding='utf8') as f : f.write(txt) # dialogue d'attente busy = wx.BusyInfo(_("Please wait..."), self.parent) @@ -1053,7 +1067,6 @@ class OpenCorpus : ira.nb.SetSelection(ira.nb.GetPageCount() - 1) ira.ShowAPane("Tab_content") - class MatLayout : def __init__(self, ira, matrix): @@ -1205,7 +1218,7 @@ def blender(self): """ # ecriture du fichier de script à éxécuter filetmp = tempfile.mktemp() - with open(filetmp, 'w') as f : + with open(filetmp, 'w', encoding='utf8') as f : f.write(txt) exec_rcode(self.ira.RPath, filetmp) GraphToJson(nodesfile, edgesfile, jsonout) @@ -1325,7 +1338,7 @@ class SimiLayout(DefaultTextLayout) : #saveAsGEXF(graph, filepath = fileout) """ % (ffr(self.pathout['RData.RData']), ffr(self.parent.RscriptsPath['simi']), fileout) filetmp = tempfile.mktemp() - with open(filetmp, 'w') as f : + with open(filetmp, 'w', encoding='utf8') as f : f.write(txt) exec_rcode(self.ira.RPath, filetmp) mss = wx.MessageDialog(self.ira, fileout, _('File exported'), wx.OK) @@ -1361,7 +1374,8 @@ class FreqLayout(DefaultMatLayout) : self.tab = wx.html.HtmlWindow(self.ira.nb, -1) #self.tab = wx.html2.WebView.New(self) res = normpath_win32(self.pathout['resultats.html']).replace('\\','/') - self.tab.LoadPage(res) + #self.tab.LoadPage(res) + self.tab.LoadFile(res) #self.tab.LoadURL(res) self.tab.parametres = self.parametres self.ira.nb.AddPage(self.tab, ' - '.join([_("Frequency"), self.parametres['name']])) @@ -1374,7 +1388,7 @@ class Chi2Layout(DefaultMatLayout) : if "gtk2" in wx.PlatformInfo: self.tab.SetStandardFonts() res = normpath_win32(self.pathout['resultats-chi2.html']).replace('\\','/') - self.tab.LoadPage(res) + self.tab.LoadFile(res) self.tab.parametres = self.parametres self.ira.nb.AddPage(self.tab, ' - '.join(["Chi2", self.parametres['name']])) #self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1) @@ -1401,7 +1415,9 @@ class ProtoLayout(DefaultMatLayout) : class CateLayout(DefaultMatLayout) : def dolayout(self) : + self.tableau.read_tableau(self.pathout['analyse.db']) TabCate = ElCategorizator(self.ira.nb, self.pathout, self.tableau) + TabCate.parametres = self.parametres self.ira.nb.AddPage(TabCate, ' - '.join([_('ElCaTeGoRiZaToR'), self.parametres['name']])) class SimiMatLayout(DefaultMatLayout) : @@ -1428,7 +1444,7 @@ class SimiMatLayout(DefaultMatLayout) : #self.parent.nb.SetSelection(self.parent.nb.GetPageCount() - 1) def redosimi(self,evt) : - with open(self.pathout['selected.csv'],'r') as f : + with open(self.pathout['selected.csv'],'r', encoding='utf8') as f : selected = f.read() selected = [int(val) for val in selected.splitlines()] #if self.actives is None : @@ -1441,6 +1457,7 @@ class SimiMatLayout(DefaultMatLayout) : actives = [[val, self.tableau.actives[val]] for val in self.tableau.actives] #self.tableau.make_listactives() actives = dict([[i, val] for i, val in enumerate(actives)]) + print(actives) #dictcol = dict([[i, [act, self.corpus.getlemeff(act)]] for i, act in enumerate(self.actives)]) self.dial = PrefSimi(self.parent, -1, self.parametres, self.indices, wordlist = actives, selected = selected, actives = self.tableau.listactives) self.dial.CenterOnParent() @@ -1455,7 +1472,7 @@ class SimiMatLayout(DefaultMatLayout) : indexes.append(self.dial.listcol.getColumnText(last,0)) self.column = [self.tableau.listactives.index(val) for val in indexes] self.column.sort() - with open(self.pathout['selected.csv'], 'w') as f : + with open(self.pathout['selected.csv'], 'w', encoding='utf8') as f : f.write('\n'.join([repr(val) for val in self.column])) self.make_param() self.dial.Destroy() @@ -1583,7 +1600,7 @@ class SimiMatLayout(DefaultMatLayout) : #saveAsGEXF(graph, filepath = fileout) """ % (ffr(self.pathout['RData.RData']), ffr(self.parent.RscriptsPath['simi']), fileout) filetmp = tempfile.mktemp() - with open(filetmp, 'w') as f : + with open(filetmp, 'w', encoding='utf8') as f : f.write(txt) exec_rcode(self.ira.RPath, filetmp) mss = wx.MessageDialog(self.ira, fileout, _('File exported'), wx.OK)