From: pierre Date: Sun, 18 Feb 2024 09:44:28 +0000 (+0100) Subject: json for Matrix + fix for windows X-Git-Url: http://iramuteq.org/git?a=commitdiff_plain;h=94690e4dfeb4c923fd4476cc5f4f93cdcc716327;p=iramuteq json for Matrix + fix for windows --- diff --git a/KeyFrame.py b/KeyFrame.py index e570435..f607eaf 100755 --- a/KeyFrame.py +++ b/KeyFrame.py @@ -108,7 +108,7 @@ class AlcOptFrame(wx.Dialog): grid_sizer_1.Add(self.listlabel[i], 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_1.Add(self.listspin[i], 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_1.Add(self.listbutton[i], 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0) - for i in range(13,len(self.listlabel)): + for i in range(14,len(self.listlabel)): grid_sizer_2.Add(self.listlabel[i], 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_2.Add(self.listspin[i], 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0) grid_sizer_2.Add(self.listbutton[i], 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0) diff --git a/chemins.py b/chemins.py index 44f092b..91efc9a 100644 --- a/chemins.py +++ b/chemins.py @@ -290,7 +290,7 @@ ChdTxtPathOut = {'TableUc1': 'TableUc1.csv', 'prof_type' : 'profil_type.csv', 'antiprof_type' : 'antiprof_type.csv', 'type_cl' : 'type_cl.csv', - 'db' : 'analyse'#.db, + 'db' : 'analyse.db', } def StatTxtPathOut(pathout): @@ -314,7 +314,7 @@ def StatTxtPathOut(pathout): 'afct_col_csv': ffr(os.path.join(pathout, 'afct_col.csv')), 'afct_facteur_csv': ffr(os.path.join(pathout, 'afct_facteur.csv')), 'ira' : ffr(os.path.join(pathout, 'Analyse.ira')), - 'db' : os.path.join(pathout, 'analyse'), + 'db' : os.path.join(pathout, 'analyse.db'), 'zipf' : ffr(os.path.join(pathout, 'zipf.png')), } return d @@ -338,7 +338,7 @@ simipath = {'mat01' : 'mat01.csv', 'liste_graph' :'liste_graph.txt', 'ira' : 'Analyse.ira', 'film' : '', - 'db' : 'analyse', + 'db' : 'analyse.db', 'corpus' : 'corpus.db', } diff --git a/iramuteq.py b/iramuteq.py index 3f5183b..042ee0e 100755 --- a/iramuteq.py +++ b/iramuteq.py @@ -585,7 +585,7 @@ class IraFrame(wx.Frame): self._mgr.GetPane("lefttree").Show() self._mgr.GetPane("classif_tb").Hide() # utilisé nulle part ailleurs que sur cette ligne ??? # "commit" all changes made to FrameManager - self._mgr.Update() + #self._mgr.Update() # Attache les événements aux éléments d'interface self.Bind(wx.EVT_MENU, self.OnAcceuil, id=ID_ACCEUIL) @@ -645,7 +645,7 @@ class IraFrame(wx.Frame): self._mgr.SetAGWFlags(self._mgr.GetAGWFlags() ^ (aui.AUI_MGR_RECTANGLE_HINT | aui.AUI_MGR_ALLOW_FLOATING)) self._mgr.GetArtProvider().SetMetric(aui.AUI_DOCKART_GRADIENT_TYPE, aui.AUI_GRADIENT_HORIZONTAL) self.GetDockArt().SetColor(aui.AUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR, "#00FFF9") - self.DoUpdate() + #self.DoUpdate() self._icon = wx.Icon(os.path.join(ImagePath, "iraicone.ico"), wx.BITMAP_TYPE_ICO) self.SetIcon(self._icon) @@ -752,10 +752,11 @@ class IraFrame(wx.Frame): # vu comme elle est écrite, impossible de gérer # l'affichage/masquage des toolbars en fonction du contexte def ShowMenu(self, menu, Show=True): - print("showmenu") if menu == 'text' : menu_pos = 4 if Show : + if self._mgr.GetPane('tb_text').IsShown() : + return self._mgr.GetPane('tb_text').Show() self._mgr.GetPane('tb_mat').Hide() self.mb.EnableTop(menu_pos, Show) @@ -765,6 +766,8 @@ class IraFrame(wx.Frame): elif menu == 'matrix' : menu_pos = 3 if Show : + if self._mgr.GetPane('tb_mat').IsShown(): + return self._mgr.GetPane('tb_mat').Show() self._mgr.GetPane('tb_text').Hide() self.mb.EnableTop(menu_pos, Show) @@ -779,6 +782,7 @@ class IraFrame(wx.Frame): #self.mb.EnableTop(menu_pos, Show) self.mb.Refresh() self._mgr.Update() + self.Refresh() #-------------------------------------------------------------------- # fin de __init__ du wx.Frame @@ -926,22 +930,13 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis.""" # action ou évènement ? def OnPageChanged(self, event) : - print("OnPageChange") new = event.GetSelection() nobject = event.GetEventObject() parent = nobject.GetParent() if isinstance(parent, IraFrame) : npage = self.nb.GetPage(new) if 'parametres' in dir(npage) : - #self.tree.GiveFocus(uuid=npage.parametres['uuid']) - if npage.parametres.get('matrix', False) : - #self.ShowMenu('text', False) - self.ShowMenu('matrix', True) - elif npage.parametres.get('corpus', False) : - self.ShowMenu('text') - #self.ShowMenu('matrix', False) - wx.CallAfter(self.nb.SendSizeEvent) - self.Refresh() + self.tree.GiveFocus(uuid=npage.parametres['uuid']) # action ou évènement ? def OnCloseTab(self, evt): @@ -978,6 +973,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis.""" # action ou évènement ? def ShowAPane(self, panel): + print('ShowAPane') for pane in self._mgr.GetAllPanes() : if not pane.IsToolbar() and pane.name != 'lefttree': pane.Hide() diff --git a/layout.py b/layout.py index 6b186e6..302cbed 100644 --- a/layout.py +++ b/layout.py @@ -407,7 +407,7 @@ class OpenCHDS(): else : corpname = self.corpus.parametres['matrix_name'] if os.path.exists(self.pathout['analyse.db']) : - self.corpus.read_tableau(self.pathout['analyse']) + self.corpus.read_tableau(self.pathout['analyse.db']) clnb = parametres['clnb'] dlg = progressbar(self, maxi = 4 + clnb) self.clnb = clnb @@ -1054,7 +1054,6 @@ class OpenCorpus : ira.nb.SetSelection(ira.nb.GetPageCount() - 1) ira.ShowAPane("Tab_content") - class MatLayout : def __init__(self, ira, matrix): @@ -1347,7 +1346,7 @@ class DefaultMatLayout : self.tableau = tableau self.parametres = parametres if os.path.exists(self.pathout['analyse.db']) : - self.tableau.read_tableau(self.pathout['analyse']) + self.tableau.read_tableau(self.pathout['analyse.db']) self.dolayout() self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1) self.ira.ShowAPane("Tab_content") @@ -1402,7 +1401,7 @@ class ProtoLayout(DefaultMatLayout) : class CateLayout(DefaultMatLayout) : def dolayout(self) : - self.tableau.read_tableau(self.pathout['analyse']) + self.tableau.read_tableau(self.pathout['analyse.db']) TabCate = ElCategorizator(self.ira.nb, self.pathout, self.tableau) self.ira.nb.AddPage(TabCate, ' - '.join([_('ElCaTeGoRiZaToR'), self.parametres['name']])) diff --git a/tabcatego.py b/tabcatego.py index 994a6b6..5f4052e 100644 --- a/tabcatego.py +++ b/tabcatego.py @@ -88,6 +88,6 @@ class Categorisation(AnalyseMatrix): cate['TOCATE'][val] = self.tableau.actives[val][0] with open(self.pathout['cate.json'], 'w', encoding='utf8') as f : f.write(json.dumps(cate)) - self.tableau.save_tableau(self.pathout['analyse']) + self.tableau.save_tableau(self.pathout['analyse.db']) self.dlg.Destroy() diff --git a/tabchdalc.py b/tabchdalc.py index 3322063..e4c8fc5 100644 --- a/tabchdalc.py +++ b/tabchdalc.py @@ -120,7 +120,7 @@ class AnalyseQuest(AnalyseMatrix): self.BuildProfile() temps = time.time() - self.t1 PrintRapport(self, self, {}, istxt = False) - self.tableau.save_tableau(self.pathout['db']) + self.tableau.save_tableau(self.pathout['analyse.db']) #CreateIraFile(self.dictpathout, self.clnb, corpname = os.path.basename(self.parent.filename), section = 'questionnaire') afc_graph_list = [[os.path.basename(self.pathout['AFC2DL_OUT']), 'Variables actives - coordonnées - facteurs 1 / 2'], [os.path.basename(self.pathout['AFC2DSL_OUT']), 'variables illustratives - coordonnées - facteurs 1 / 2'], diff --git a/tableau.py b/tableau.py index a6d09da..204df9c 100644 --- a/tableau.py +++ b/tableau.py @@ -22,7 +22,8 @@ import os from copy import copy import re import html.entities -import shelve +#import shelve +import json from uuid import uuid4 import logging @@ -118,10 +119,8 @@ class Tableau() : #self.parametres = self.parametre def read_tableau(self, fileout) : - d=shelve.open(fileout) - #self.parametres = d['parametres'] - #if 'syscoding' not in self.parametres : - # self.parametres['syscoding'] = sys.getdefaultencoding() + with open(fileout, 'r', encoding='utf8') as f : + d = json.load(f) self.actives = d['actives'] self.sups = d['sups'] self.classes = d['classes'] @@ -136,7 +135,6 @@ class Tableau() : self.lchi = d['lchi'] if 'content' in d : self.content = d['content'] - d.close() def open(self): print('open matrix') @@ -146,7 +144,7 @@ class Tableau() : self.colnb = len(self.linecontent[0]) def save_tableau(self, fileout) : - d=shelve.open(fileout) + d = {} d['parametres'] = self.parametres d['actives'] = self.actives d['sups'] = self.sups @@ -161,7 +159,8 @@ class Tableau() : if 'lchi' in dir(self) : d['lchi'] = self.lchi d['content'] = self.content - d.close() + with open(fileout, 'w', encoding='utf8') as f : + json.dump(d, f) def make_content(self) : self.pathout.createdir(self.parametres['pathout']) diff --git a/tabsimi.py b/tabsimi.py index 2c5ecbc..e822037 100644 --- a/tabsimi.py +++ b/tabsimi.py @@ -173,7 +173,7 @@ class DoSimi(AnalyseMatrix): self.tmpfile = self.script.scriptout self.DoR(self.dlg) self.addgraph() - self.tableau.save_tableau(self.pathout['db']) + self.tableau.save_tableau(self.pathout['analyse.db']) #self.make_ira() #count += 1 #self.dlg.Update(count, u"") diff --git a/tree.py b/tree.py index d8f73a7..6551973 100755 --- a/tree.py +++ b/tree.py @@ -1096,7 +1096,6 @@ class LeftTree(CT.CustomTreeCtrl): event.Skip() def OnSelChanged(self, event = None, pydata = None): - print("OnSelChange") if event is not None : item = event.GetItem() pydata = self.GetPyData(item) @@ -1113,15 +1112,16 @@ class LeftTree(CT.CustomTreeCtrl): self.ira.ShowMenu('matrix', False) self.pydata = pydata if pydata['uuid'] in self.parent.history.opened : + actual = self.parent.nb.GetSelection() for i in range(self.parent.nb.GetPageCount()) : self.page = self.parent.nb.GetPage(i) if 'parametres' in dir(self.page) : if self.page.parametres['uuid'] == pydata['uuid'] : self.parent.nb.SetSelection(i) + wx.CallAfter(self.parent.nb.SendSizeEvent) + #self.parent.Refresh() break #self.parent._mgr.Update() - wx.CallAfter(self.parent.nb.SendSizeEvent) - self.parent.Refresh() #if event is not None : # event.Skip()