...
[iramuteq] / guifunct.py
index 47f49db..6280e94 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)
@@ -236,7 +246,7 @@ class PrefSimi ( wx.Dialog ):
         self.m_staticline295 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer3.Add( self.m_staticline295, 0, wx.EXPAND, 5 )
         
-        self.m_staticText5 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Graphical type").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText5 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Graphic type").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText5.Wrap( -1 )
         fgSizer3.Add( self.m_staticText5, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
@@ -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"), 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 )
         
@@ -725,6 +748,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 +800,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() :
@@ -945,12 +977,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 +1086,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 +1132,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 +1167,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 +1185,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 +1213,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()