...
[iramuteq] / dialog.py
index e063cda..29aa825 100755 (executable)
--- a/dialog.py
+++ b/dialog.py
@@ -375,7 +375,7 @@ releases at startup""").decode('utf8')
         self.m_staticText46.Wrap( -1 )
         fgSizer1.Add( self.m_staticText46, 0, wx.ALL, 5 )
         
-        self.listlangues = [ u"french", u"english", u"spanish", u"portuguese", u"italian" ]
+        self.listlangues = [ u"english",u"french", u"italian", u"portuguese", u"spanish"]
         self.langues = wx.Choice( self, wx.ID_ANY, (200, -1), choices = self.listlangues)
         #self.langues.SetSelection( 0 )
         fgSizer1.Add( self.langues, 0, wx.ALIGN_RIGHT|wx.ALL, 5 )
@@ -1051,34 +1051,34 @@ class StatDialog ( wx.Dialog ):
         
         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Lemmatization").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText1.Wrap( -1 )
-        gSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        gSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL, 1 )
         
         radio_lemChoices = [ _(u"yes").decode('utf8'), _(u"no").decode('utf8') ]
         self.radio_lem = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, radio_lemChoices, 1, wx.RA_SPECIFY_COLS )
         self.radio_lem.SetSelection( 0 )
-        gSizer1.Add( self.radio_lem, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
+        gSizer1.Add( self.radio_lem, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 1 )
         
         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"Keys properties").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText2.Wrap( -1 )
-        gSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        gSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL, 1 )
         
         self.button_5 = wx.Button( self, wx.ID_PREFERENCES, _(u"properties").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
-        gSizer1.Add( self.button_5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
+        gSizer1.Add( self.button_5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 1 )
         
         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"Dictionary").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText3.Wrap( -1 )
-        gSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        gSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL, 1 )
         
         radio_dictchoiceChoices = [ _(u"indexation").decode('utf8'), _(u"other").decode('utf8') ]
         self.radio_dictchoice = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, radio_dictchoiceChoices, 1, wx.RA_SPECIFY_COLS )
         self.radio_dictchoice.SetSelection( 0 )
-        gSizer1.Add( self.radio_dictchoice, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
+        gSizer1.Add( self.radio_dictchoice, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 1 )
         
         
-        bSizer1.Add( gSizer1, 1, wx.EXPAND, 5 )
+        bSizer1.Add( gSizer1, 1, wx.EXPAND, 1 )
         
         self.dictpath = filebrowse.FileBrowseButton(self, -1, size=(350, -1),  labelText = _(u"Path").decode('utf8'), fileMode = 2, fileMask = '*')
-        bSizer1.Add( self.dictpath, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        bSizer1.Add( self.dictpath, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 1 )
         self.dictpath.Enable(False)
 
         m_sdbSizer1 = wx.StdDialogButtonSizer()
@@ -1088,7 +1088,7 @@ class StatDialog ( wx.Dialog ):
         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
         m_sdbSizer1.Realize();
         
-        bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
+        bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 0 )
         
         
         self.SetSizer( bSizer1 )
@@ -2237,8 +2237,10 @@ class ChiDialog(wx.Dialog):
         self.__set_properties()
         self.__do_layout()
 
-        self.Bind(wx.EVT_LISTBOX, self.Select1, self.list_box_1)
+        self.Bind(wx.EVT_LISTBOX, self.selchange, self.list_box_1)
+        self.Bind(wx.EVT_LISTBOX, self.selchange, self.list_box_2)
         self.Bind(wx.EVT_BUTTON, self.onparam, self.button_pref)
+        self.button_1.Enable(False)
         # end wxGlade
 #-------------------------------
     def __set_properties(self):
@@ -2264,8 +2266,11 @@ class ChiDialog(wx.Dialog):
         self.Layout()
         # end wxGlade
 
-    def Select1(self, event): # wxGlade: ConfChi2.<event_handler>
-        event.Skip()
+    def selchange(self, event): # wxGlade: ConfChi2.<event_handler>
+        if (len(self.list_box_1.GetSelections()) == 0) or (len(self.list_box_2.GetSelections()) == 0) :
+            self.button_1.Enable(False)
+        else :
+            self.button_1.Enable(True)
     
     
     def onparam(self,event):
@@ -2676,9 +2681,8 @@ class message(wx.Frame):
         self.Destroy()
     
     def OnSub(self ,evt):
-        parametres = {'fromuceids' : True, 'uceids' : self.uceids}
-        self.ira.OnSubText(None, parametres)
-
+        parametres = {'fromuceids' : True, 'uceids' : self.uceids, 'isempty' : True}
+        self.ira.OnSubText(wx.MenuEvent(), None, parametres)
 
 
 class ExtractDialog ( wx.Dialog ):
@@ -2852,11 +2856,17 @@ class FreqDialog ( wx.Dialog ):
         bSizer1.Fit( self )
         
         self.Centre( wx.BOTH )
+        self.Bind(wx.EVT_LISTBOX, self.selchange, self.m_listBox1)
+        self.m_sdbSizer1OK.Enable(False)
     
     def __del__( self ):
         pass
     
-
+    def selchange(self, evt):
+        if len(self.m_listBox1.GetSelections()) == 0 :
+            self.m_sdbSizer1OK.Enable(False)
+        else :
+            self.m_sdbSizer1OK.Enable(True)
 
 class ProtoDial ( wx.Dialog ):
     
@@ -2974,10 +2984,20 @@ class ProtoDial ( wx.Dialog ):
         # Connect Events
         self.choix_freq.Bind( wx.EVT_CHOICE, self.UpdateText )
         self.choix_rang.Bind( wx.EVT_CHOICE, self.UpdateText )
+        self.Bind(wx.EVT_LISTBOX, self.selchange, self.variables)
+        self.Bind(wx.EVT_LISTBOX, self.selchange, self.rangs)
+        
+        self.m_sdbSizer1OK.Enable(False)
     
     def __del__( self ):
         pass
     
+    def selchange(self, evt):
+        if (len(self.variables.GetSelections()) == 0) or (len(self.rangs.GetSelections()) == 0) or (len(self.variables.GetSelections()) != len(self.rangs.GetSelections())) :
+            self.m_sdbSizer1OK.Enable(False)
+        else :
+            self.m_sdbSizer1OK.Enable(True)
+    
     
     # Virtual event handlers, overide them in your derived class
     def UpdateText( self, event ):
@@ -3029,7 +3049,7 @@ class SimpleDialog ( wx.Dialog ):
 class SubTextFromMetaDial ( wx.Dialog ):
     
     def __init__( self, parent, parametres ):
-        wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Subcorpus from metadata", pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
+        wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Subcorpus").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
         
         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
         
@@ -3039,14 +3059,14 @@ class SubTextFromMetaDial ( wx.Dialog ):
         fgSizer1.SetFlexibleDirection( wx.BOTH )
         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
         
-        self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"SubCorpus Name", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Name").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText1.Wrap( -1 )
         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
         self.subcorpusname = wx.TextCtrl( self, wx.ID_ANY, parametres['corpus_name'], wx.DefaultPosition, wx.Size( 300,-1 ), 0 )
         fgSizer1.Add( self.subcorpusname, 0, wx.ALL, 5 )
         
-        self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, u"Select one or more metadata", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"Select one or more metadata").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText2.Wrap( -1 )
         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
@@ -3075,14 +3095,23 @@ class SubTextFromMetaDial ( wx.Dialog ):
         bSizer1.Fit( self )
         
         self.Centre( wx.BOTH )
+        self.Bind(wx.EVT_LISTBOX, self.onchoose, self.m_listBox1)
+        if not parametres.get('isempty', False) :
+            self.m_sdbSizer1OK.Enable(False)
     
     def __del__( self ):
         pass
+    
+    def onchoose(self, evt):
+        if len(self.m_listBox1.GetSelections()) > 0 :
+            self.m_sdbSizer1OK.Enable(True)
+        else :
+            self.m_sdbSizer1OK.Enable(False)
 
 class BarGraphDialog ( wx.Dialog ):
     
     def __init__( self, parent, width, height ):
-        wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Preferences", pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
+        wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Preferences").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
         
         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
         
@@ -3090,11 +3119,11 @@ class BarGraphDialog ( wx.Dialog ):
         
         bSizer2 = wx.BoxSizer( wx.HORIZONTAL )
         
-        self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"Size", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText1.Wrap( -1 )
         bSizer2.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
-        sizeradioChoices = [ u"automatic", u"manual" ]
+        sizeradioChoices = [ _(u"automatic").decode('utf8'), _(u"manual").decode('utf8') ]
         self.sizeradio = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, sizeradioChoices, 1, wx.RA_SPECIFY_COLS )
         self.sizeradio.SetSelection( 0 )
         bSizer2.Add( self.sizeradio, 0, wx.ALIGN_TOP|wx.ALL, 5 )
@@ -3103,14 +3132,14 @@ class BarGraphDialog ( wx.Dialog ):
         fgSizer1.SetFlexibleDirection( wx.BOTH )
         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
         
-        self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, u"width", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"width").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText2.Wrap( -1 )
         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
         self.widthsp = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 1000000, 600 )
         fgSizer1.Add( self.widthsp, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
-        self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, u"height", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"height").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText3.Wrap( -1 )
         fgSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
@@ -3125,7 +3154,7 @@ class BarGraphDialog ( wx.Dialog ):
         
         bSizer3 = wx.BoxSizer( wx.HORIZONTAL )
         
-        self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, u"Image format", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"Image format").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText4.Wrap( -1 )
         bSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
@@ -3219,7 +3248,7 @@ class MessageImage(wx.Frame):
 
     def OnSaveImage(self, event) :
         dlg = wx.FileDialog(
-            self, message="Enregistrer sous...", defaultDir=os.getcwd(),
+            self, message=_(u"Save as...").decode('utf8'), defaultDir=os.getcwd(),
             defaultFile= self.imagename, wildcard=self.parametres['wildcard'], style=wx.SAVE | wx.OVERWRITE_PROMPT
             )
         dlg.SetFilterIndex(2)
@@ -3263,7 +3292,7 @@ class BarFrame :
             with open(tmpscript,'w') as f :
                 f.write(txt)
             exec_rcode(ira.RPath, tmpscript, wait = True)
-            win = MessageImage(ira, parametres, u"Graphique", size=(700, 500))
+            win = MessageImage(ira, parametres, _(u"Graphic").decode('utf8'), size=(700, 500))
             if svg == 'FALSE' :
                 txt = "<img src='%s'>" % tmpgraph
             else :