...
[iramuteq] / iramuteq.py
index d0bfb72..8d507dc 100755 (executable)
@@ -219,7 +219,7 @@ images_analyses = {
         'preferences' : 'preferences.png',
         'exportmetatable' : 'exportmetatable.png',
         'importdmi' : 'twitter.png',
-        'labbe' : 'spec.png',
+        'labbe' : 'labbe.png',
         'categorisation' : 'spec.png',
          }
 
@@ -239,8 +239,7 @@ class IraFrame(wx.Frame):
         log.info('Starting Iramuteq... ' )
         log.info('version : %s' % ConfigGlob.get('DEFAULT', 'version'))
         wx.Frame.__init__(self, parent, id, title, pos, size, style)
-        #Font
-        self.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
+
         # configuration
         self.AppliPath = AppliPath
         self.images_path = os.path.join(AppliPath,'images')
@@ -259,6 +258,15 @@ class IraFrame(wx.Frame):
         self._mgr = aui.AuiManager()
         self._mgr.SetManagedWindow(self)
         self.x = 0
+        #Font
+        try :
+            self.pref.read(self.ConfigPath['preferences'])
+            self.fontsize = self.pref.getint('iramuteq','fontsize')
+        except :
+            print('no pref : setting fontsize to 12')
+            self.fontsize = 12
+        self.SetFont(wx.Font(self.fontsize, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
+
         #--------------------------------------------------------------------------------
         # creation menu
         #--------------------------------------------------------------------------------
@@ -290,7 +298,7 @@ class IraFrame(wx.Frame):
         item.SetBitmap(self.images_analyses['importdmi'])
         file_menu.Append(item)
         item = wx.MenuItem(file_menu, ID_merge, _('Merge graphs'), _('Merge graphs'))
-        file_menu.Append(item)
+        #file_menu.Append(item)
         item = wx.MenuItem(file_menu, ID_merge_clusters, _('Corpus from merge clusters'), _('Corpus from merge clusters'))
         file_menu.Append(item)
 
@@ -432,7 +440,7 @@ class IraFrame(wx.Frame):
         # min size for the frame itself isn't completely done.
         # see the end up FrameManager::Update() for the test
         # code. For now, just hard code a frame minimum size
-        self.SetMinSize(wx.Size(400, 400))
+        self.SetMinSize(wx.Size(800, 600))
 
         #--------------------------------------------------------------------
         # barre d'outils : le menu de petits icones en haut de la fenetre
@@ -495,7 +503,7 @@ class IraFrame(wx.Frame):
         # fichier d'historique de Iramuteq
         #------------------------------------------------------------------------------------------------
         if not os.path.exists(os.path.join(UserConfigPath, 'history.db')) :
-            with open(os.path.join(UserConfigPath, 'history.db'), 'w') as f :
+            with open(os.path.join(UserConfigPath, 'history.db'), 'w', encoding='utf8') as f :
                 f.write('{}')
         self.history = History(os.path.join(UserConfigPath, 'history.db'))
         # l'extension ".db" est ajoutée automatiquement par le module
@@ -510,7 +518,8 @@ class IraFrame(wx.Frame):
             Name("lefttree").
             Caption(_("Historic")).
             Left().
-            MinSize(wx.Size(300,400)).
+            MinSize(wx.Size(200,400)).
+            BestSize(wx.Size(300,-1)).
             Layer(1).
             Position(1).
             CloseButton(False).
@@ -527,6 +536,7 @@ class IraFrame(wx.Frame):
         # | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_FLOAT| wx.NO_BORDER
         self.nb.SetAGWWindowStyleFlag(notebook_flags)
         self.nb.SetArtProvider(aui.ChromeTabArt())
+        self.nb.SetFont(wx.Font(self.fontsize, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
         #self.nb.SetArtProvider(aui.VC8TabArt())
         #self.nb.parent = self
         #self._notebook_style = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | wx.NO_BORDER
@@ -538,6 +548,7 @@ class IraFrame(wx.Frame):
             aui.AuiPaneInfo().
             Name("Tab_content").
             CenterPane())
+
         #self._mgr.AddPane(self.Sheet, wx.aui.AuiPaneInfo().Name("Data").CenterPane())
         #self._mgr.AddPane(self.Sheet, aui.AuiPaneInfo().Name("Data").CenterPane())
         self.nb.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnCloseTab)
@@ -584,7 +595,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)
@@ -644,7 +655,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)
 
@@ -683,6 +694,7 @@ class IraFrame(wx.Frame):
         self.Text = ''
         self.lexique = None
         self.corpus = None
+        
 
     def finish_init(self) :
         try :
@@ -707,15 +719,19 @@ class IraFrame(wx.Frame):
         BestRPath = False
         if not CheckRPath(self.PathPath) :
             if sys.platform == 'win32':
-                if os.path.exists(self.AppliPath + '\\R\\R') :
+                if os.path.exists(self.AppliPath + '\\R\\R\\x64\\R.exe') :
                     BestRPath = self.AppliPath + '\\R\\R\\bin\\x64\\R.exe'
+                elif os.path.exists(self.AppliPath + '\\R\\R\\i386\\R.exe') :
+                    BestRPath = self.AppliPath + '\\R\\R\\bin\\i386\\R.exe'
                 else :
                     BestRPath = FindRPAthWin32()
+            elif os.path.exists(self.AppliPath + '/R/R') :
+                BestRPath = self.AppliPath + '/R/R'
             else:
                 BestRPath = FindRPathNix()
             if BestRPath:
                 self.PathPath.set('PATHS', 'rpath', BestRPath)
-                with open(ConfigPath['path'], 'w') as f :
+                with open(ConfigPath['path'], 'w', encoding='utf8') as f :
                     self.PathPath.write(f)
         else:
             BestRPath = True
@@ -750,13 +766,23 @@ class IraFrame(wx.Frame):
         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)
+                self.mb.EnableTop(3, False)
             else :
                 self._mgr.GetPane('tb_text').Hide()
         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)
+                self.mb.EnableTop(4, False)
             else :
                 self._mgr.GetPane('tb_mat').Hide()
         elif menu == 'view' :
@@ -764,9 +790,10 @@ class IraFrame(wx.Frame):
         else :
             menu_pos = None
         if not menu_pos is None :
-            self.mb.EnableTop(menu_pos, Show)
+            #self.mb.EnableTop(menu_pos, Show)
             self.mb.Refresh()
-        #self._mgr.Update()
+        self._mgr.Update()
+        self.Refresh()
 
     #--------------------------------------------------------------------
     # fin de __init__ du wx.Frame
@@ -775,7 +802,7 @@ class IraFrame(wx.Frame):
     # evenement attaché au bouton de fermeture des fenetres ou onglets ?
     def OnClose(self, event):
         print('onclose Iramuteq')
-        with open(self.ConfigPath['path'], 'w') as f :
+        with open(self.ConfigPath['path'], 'w', encoding='utf8') as f :
             self.PathPath.write(f)
         self._mgr.UnInit()
         del self._mgr
@@ -920,16 +947,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis."""
         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)
-        #self._mgr.Update()
-        #wx.CallAfter(self.nb.SendSizeEvent)
-        #self.Refresh()
+                self.tree.GiveFocus(uuid=npage.parametres['uuid'])
 
     # action ou évènement ?
     def OnCloseTab(self, evt):
@@ -966,12 +984,12 @@ 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()
         self._mgr.GetPane(panel).Show()
         self._mgr.Update()
-        print('show a pane refresh')
         wx.CallAfter(self.nb.SendSizeEvent)
         self.Refresh()
 
@@ -1342,13 +1360,13 @@ class IntroPanel(wx.Panel):
         label2 = wx.StaticText(PanelPres, -1 , '\nVersion ' + ConfigGlob.get('DEFAULT', 'version') + '\n')
         label2.SetForegroundColour(txtcolour)
         label2.SetBackgroundColour(bckgrdcolor)
-        self.hyper2 = hl.HyperLinkCtrl(PanelPres, wx.ID_ANY, "REPERE", URL="http://repere.no-ip.org/")
-        self.hyper2.SetColours(linkcolor, linkcolor, "RED")
-        self.hyper2.SetBackgroundColour(bckgrdcolor)
-        self.hyper2.EnableRollover(True)
-        self.hyper2.SetUnderlines(False, False, True)
-        self.hyper2.SetBold(True)
-        self.hyper2.UpdateLink()
+        #self.hyper2 = hl.HyperLinkCtrl(PanelPres, wx.ID_ANY, "REPERE", URL="http://repere.no-ip.org/")
+        #self.hyper2.SetColours(linkcolor, linkcolor, "RED")
+        #self.hyper2.SetBackgroundColour(bckgrdcolor)
+        #self.hyper2.EnableRollover(True)
+        #self.hyper2.SetUnderlines(False, False, True)
+        #self.hyper2.SetBold(True)
+        #self.hyper2.UpdateLink()
         label_lerass = wx.StaticText(PanelPres, -1, 'Laboratoire ')
         label_lerass.SetForegroundColour(txtcolour)
         label_lerass.SetBackgroundColour(bckgrdcolor)
@@ -1370,13 +1388,16 @@ class IntroPanel(wx.Panel):
         python_img = wx.Image(os.path.join(ImagePath,'python-logo.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
         r_img = wx.Image(os.path.join(ImagePath,'Rlogo.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
         lexique_img = wx.Image(os.path.join(ImagePath,'LexTexte4.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
+        sms_img = wx.Image(os.path.join(ImagePath,'logo_sms.jpg'), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
         but_python = wx.BitmapButton(self, -1, python_img)
         but_lexique = wx.BitmapButton(self, -1, lexique_img)
         but_r = wx.BitmapButton(self, -1, r_img)
+        but_sms = wx.BitmapButton(self, -1, sms_img)
         self.Bind(wx.EVT_BUTTON, self.OnPython, but_python)
         self.Bind(wx.EVT_BUTTON, self.OnLexique, but_lexique)
         self.Bind(wx.EVT_BUTTON, self.OnR, but_r)
-        grid_sizer_1.Add(self.hyper2, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
+        self.Bind(wx.EVT_BUTTON, self.OnSMS, but_sms)
+        #grid_sizer_1.Add(self.hyper2, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
         grid_sizer_3.Add(label_lerass, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
         grid_sizer_3.Add(self.hyper_lerass, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, 0)
         sizer4.Add(label_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5)
@@ -1396,6 +1417,7 @@ class IntroPanel(wx.Panel):
         grid_sizer_2.Add(but_python, 1, wx.ALIGN_BOTTOM)
         grid_sizer_2.Add(but_lexique, 1, wx.ALIGN_BOTTOM)
         grid_sizer_2.Add(but_r, 1,  wx.ALIGN_BOTTOM)
+        grid_sizer_2.Add(but_sms, 1,  wx.ALIGN_BOTTOM)
         sizer1.Add(PanelPres, 0, wx.EXPAND |wx.ALL, 10)
         sizer1.Add(grid_sizer_2, 2, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 1)
         self.SetSizer(sizer1)
@@ -1410,6 +1432,9 @@ class IntroPanel(wx.Panel):
     def OnR(self,evt):
         webbrowser.open('http://www.r-project.org')
 
+    def OnSMS(self, evt):
+        webbrowser.open('https://sms.univ-tlse2.fr')
+
 
 #--------------------------------------------------------------------
 # ecran d'accueil