...
[iramuteq] / guifunct.py
index f3e952b..44d239c 100644 (file)
@@ -58,6 +58,7 @@ def get_table_param(self, filename) :
             if self.tableau.parametres['colsep'] == 'tabulation' :
                 self.tableau.parametres['colsep'] = '\t'
             self.tableau.parametres['filetype'] = 'csv'
+            self.tableau.parametres['encodage'] = dlg.le[dlg.list_encodages.GetSelection()]
     elif  getfileextension(filename) == '.xls' :
         dlg = dialog.FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=False, sheet = True, size=(350, 200),
                      style=wx.DEFAULT_DIALOG_STYLE)
@@ -169,7 +170,16 @@ class PrefSimi ( wx.Dialog ):
         if wordlist is not None :
             self.listcol = ListForSpec(self, self, wordlist, ['eff'])
             self.listcol.SetMinSize( wx.Size( 270,-1 ) )
-            bSizer16.Add( self.listcol, 0, wx.ALL|wx.EXPAND, 5 )
+            listsizer = wx.BoxSizer( wx.VERTICAL )
+            countsizer = wx.BoxSizer( wx.HORIZONTAL )
+            self.butcount = wx.Button(self, -1, "count")
+            self.textcount = wx.TextCtrl(self, -1, "", wx.DefaultPosition, wx.Size( 100,-1 ), wx.TE_READONLY )
+            countsizer.Add(self.butcount, 0, wx.ALL, 5)
+            countsizer.Add(self.textcount, 0, wx.ALL, 5 )
+            listsizer.Add(countsizer, 0, wx.ALL, 5)
+            listsizer.Add(self.listcol, 2, wx.ALL|wx.EXPAND, 5 )
+            #bSizer16.Add( self.listcol, 0, wx.ALL|wx.EXPAND, 5 )
+            bSizer16.Add( listsizer, 0, wx.ALL|wx.EXPAND, 5)
             if selected is None :
                 for row in xrange(self.listcol.GetItemCount()):
                     self.listcol.Select(row)
@@ -240,7 +250,7 @@ class PrefSimi ( wx.Dialog ):
         self.m_staticText5.Wrap( -1 )
         fgSizer3.Add( self.m_staticText5, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
-        choice3Choices = [ u"dynamique", u"statique", u"3D", u'web2D', u"web3D" ]
+        choice3Choices = [ u"dynamique", u"statique", u"3D"]#, u'web2D', u"web3D" ]
         self.choice3 = wx.Choice( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choice3Choices, 0 )
         self.choice3.SetSelection( 0 )
 
@@ -313,6 +323,19 @@ class PrefSimi ( wx.Dialog ):
         self.check_elab = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
         fgSizer3.Add( self.check_elab, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
+        self.m_staticline39 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
+        fgSizer3.Add( self.m_staticline39, 0, wx.EXPAND |wx.ALL, 5 )
+        
+        self.m_staticline40 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
+        fgSizer3.Add( self.m_staticline40, 0, wx.EXPAND |wx.ALL, 5 )
+        
+        self.m_staticText321 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Edge curved").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText321.Wrap( -1 )
+        fgSizer3.Add( self.m_staticText321, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        
+        self.check_curved = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
+        fgSizer3.Add( self.check_curved, 0, wx.ALL, 5 )        
+        
         self.m_staticline2914 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer3.Add( self.m_staticline2914, 0, wx.EXPAND, 5 )
         
@@ -599,7 +622,7 @@ class PrefSimi ( wx.Dialog ):
         self.m_staticText21.Wrap( -1 )
         bSizer5.Add( self.m_staticText21, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
-        self.cols = wx.ColourPickerCtrl( self.m_panel3, wx.ID_ANY, wx.Colour( 255, 0, 0 ), wx.DefaultPosition, wx.Size( 10,10 ), wx.CLRP_DEFAULT_STYLE )
+        self.cols = wx.ColourPickerCtrl( self.m_panel3, wx.ID_ANY, wx.Colour( 255, 0, 0 ), wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE )
         bSizer5.Add( self.cols, 0, wx.ALL, 5 )
         
         
@@ -705,16 +728,6 @@ class PrefSimi ( wx.Dialog ):
         self.__set_properties()
  
         # Connect Events
-       # if not self.paramsimi['first'] :
-       #     self.check_coord.Bind( wx.EVT_CHECKBOX, self.OnKeepCoords )
-       # self.choice3.Bind( wx.EVT_CHOICE, self.OnChangeType )
-       # self.check2.Bind( wx.EVT_CHECKBOX, self.OnCheck2 )
-       # self.checki.Bind( wx.EVT_CHECKBOX, self.OnChecki )
-       # self.check_vcex.Bind( wx.EVT_CHECKBOX, self.OnCheck_vcex )
-       # self.checkit.Bind( wx.EVT_CHECKBOX, self.OnCheckit )
-       # self.check_s_size.Bind( wx.EVT_CHECKBOX, self.OnCheck_s_size )
-        
-        # Connect Events
         if not self.paramsimi['first'] :
             self.check_coord.Bind( wx.EVT_CHECKBOX, self.OnKeepCoords )
         self.choice3.Bind( wx.EVT_CHOICE, self.OnChangeType )
@@ -725,6 +738,11 @@ class PrefSimi ( wx.Dialog ):
             self.checki.Bind( wx.EVT_CHECKBOX, self.OnChecki )
         self.check_vcex.Bind( wx.EVT_CHECKBOX, self.OnCheck_vcex )
         self.check_s_size.Bind( wx.EVT_CHECKBOX, self.OnCheck_s_size )
+        self.listcol.Bind( wx.EVT_LIST_ITEM_SELECTED, self.ChangeCount)
+        self.listcol.Bind( wx.EVT_LIST_ITEM_DESELECTED, self.ChangeCount)
+        self.butcount.Bind( wx.EVT_BUTTON, self.ChangeCount)
+        self.ChangeCount(wx.EVT_BUTTON)
+        
 
     def __set_properties(self):
         self.choice1.SetSelection(self.paramsimi['coeff'])
@@ -772,6 +790,10 @@ class PrefSimi ( wx.Dialog ):
         self.comcheck.SetValue(self.paramsimi['com'])
         self.choix_com.SetSelection(self.paramsimi['communities'])
         self.halo.SetValue(self.paramsimi['halo'])
+        self.check_curved.SetValue(self.paramsimi.get('edgecurved', True))
+    
+    def ChangeCount(self, evt) :
+        self.textcount.SetValue('%i' % self.listcol.GetSelectedItemCount())
 
     def OnCheck_s_size(self, evt):
         if self.check_s_size.GetValue() :
@@ -891,19 +913,22 @@ class PrepSimi :
                         self.parametres['listet'] = self.etline
                     else:
                         vardial.Destroy()
-            last = self.dial.listcol.GetFirstSelected()
-            lastl = [self.dial.listcol.GetFirstSelected()]
-            indexes = [self.dial.listcol.getColumnText(self.dial.listcol.GetFirstSelected(),0)]
-            while self.dial.listcol.GetNextSelected(last) != -1:
-                last = self.dial.listcol.GetNextSelected(last)
-                lastl.append(last)
-                indexes.append(self.dial.listcol.getColumnText(last,0))
-            column = [actives.index(val) for val in indexes]
-            column.sort()
-            with open(pathout, 'w') as f :
-                f.write('\n'.join([`val` for val in column]))
-            self.make_param()
-            self.dial.Destroy()
+                        self.val = False
+                        self.dial.Destroy()
+            if self.val :
+                last = self.dial.listcol.GetFirstSelected()
+                lastl = [self.dial.listcol.GetFirstSelected()]
+                indexes = [self.dial.listcol.getColumnText(self.dial.listcol.GetFirstSelected(),0)]
+                while self.dial.listcol.GetNextSelected(last) != -1:
+                    last = self.dial.listcol.GetNextSelected(last)
+                    lastl.append(last)
+                    indexes.append(self.dial.listcol.getColumnText(last,0))
+                column = [actives.index(val) for val in indexes]
+                column.sort()
+                with open(pathout, 'w') as f :
+                    f.write('\n'.join([`val` for val in column]))
+                self.make_param()
+                self.dial.Destroy()
         else :
             self.dial.Destroy()
 
@@ -945,12 +970,12 @@ class PrepSimi :
                           'com'  :self.dial.comcheck.GetValue(),
                           'communities' : self.dial.choix_com.GetSelection(),
                           'halo' : self.dial.halo.GetValue(),
+                          'edgecurved' : self.dial.check_curved.GetValue(),
                           }
         if 'cexfromchi' in self.parametres :
             param['cexfromchi'] = self.dial.checkit.GetValue()
         if 'sfromchi' in self.parametres :
             param['sfromchi'] = self.dial.checki.GetValue()
-            print param
         if 'vlabcolor' in self.parametres :
             param['vlabcolor'] = self.parametres['vlabcolor']
         if 'check_bystar' in dir(self.dial) :
@@ -1054,7 +1079,7 @@ class CreateTgenDialog ( wx.Frame ):
 class TGenFrame ( wx.Frame ):
     
     def __init__( self, parent, corpus, Tgen ):
-        wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Tgen", pos = wx.DefaultPosition, size = wx.Size( 473,434 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP )
+        wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Tgen", pos = wx.DefaultPosition, size = wx.Size( 600,434 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP )
         
         self.Tgen = Tgen
         self.parent = parent
@@ -1100,12 +1125,19 @@ class TGenFrame ( wx.Frame ):
         fgSizer2.Add( self.but_del, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
         
-        fgSizer1.Add( fgSizer2, 1, wx.EXPAND, 5 )
+        fgSizer1.Add( fgSizer2, 0, wx.EXPAND, 5 )
         
+        fgSizer3 = wx.FlexGridSizer( 0, 2, 0, 0 )
+        fgSizer3.SetFlexibleDirection( wx.BOTH )
+        fgSizer3.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
         self.but_edit = wx.Button( self, wx.ID_ANY, u"Edit", wx.DefaultPosition, wx.DefaultSize, 0 )
-        fgSizer1.Add( self.but_edit, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
-        
+        fgSizer3.Add( self.but_edit, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
+        self.but_compute = wx.Button( self, wx.ID_ANY, u"Compute", wx.DefaultPosition, wx.DefaultSize, 0 )
+        fgSizer3.Add( self.but_compute, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )      
+
+        fgSizer1.Add( fgSizer3, 0, wx.EXPAND, 5 )
+
         bSizer1.Add( fgSizer1, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
         m_sdbSizer2 = wx.StdDialogButtonSizer()
@@ -1128,6 +1160,7 @@ class TGenFrame ( wx.Frame ):
         self.but_new.Bind( wx.EVT_BUTTON, self.OnNewTgen )
         self.but_del.Bind( wx.EVT_BUTTON, self.OnDeleteTgen )
         self.but_edit.Bind( wx.EVT_BUTTON, self.OnEditTgen )
+        self.but_compute.Bind(wx.EVT_BUTTON, self.OnCompute)
         self.m_sdbSizer2OK.Bind( wx.EVT_BUTTON, self.OnOK )
         
     def __del__( self ):
@@ -1145,6 +1178,7 @@ class TGenFrame ( wx.Frame ):
             self.dial = CreateTgenDialog(self, dict([[i, [lem, self.corpus.lems[lem].freq]] for i, lem in enumerate(self.corpus.lems.keys())]), tgens = self.Tgen.tgen)
         else :
             self.dial = CreateTgenDialog(self, dict([[i, [lem, self.corpus.lems[lem].freq]] for i, lem in enumerate(self.corpus.lems.keys())]), tgen = tgen, tgens = self.Tgen.tgen)
+            self.dial.ip._source.selected = dict(zip(self.Tgen.tgen[tgen], self.Tgen.tgen[tgen]))
             self.activetgen = tgen
         self.dial.Show()
         self.dial.Bind(wx.EVT_CLOSE, self.OnDialClose)
@@ -1172,6 +1206,10 @@ class TGenFrame ( wx.Frame ):
             self.dial.Show()
         event.Skip()
     
+    def OnCompute(self, evt):
+        ira = wx.GetApp().GetTopWindow()
+        ira.tree.OnTgenCompute(evt)
+    
     def OnOK(self, evt):
         self.Destroy()