X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=dialog.py;h=2e4759824606767647f49feaea3c4ba7caba18e0;hp=d9185387530a9b046bef8efb1d9670eca1642d73;hb=e033f9e84abb3c12d92f1580425877aa58e9af30;hpb=12b4b71c8c8feb6154abc04dfa9bb93a521ef789 diff --git a/dialog.py b/dialog.py index d918538..2e47598 100755 --- a/dialog.py +++ b/dialog.py @@ -8,11 +8,10 @@ import wx.lib.colourselect as csel import wx.lib.sized_controls as sc import wx.lib.filebrowsebutton as filebrowse import locale +from functions import DoConf import os import sys -#from listlex import * from KeyFrame import AlcOptFrame -#from listlex import ListForSpec #--------------------------------------------------------------------------- provider = wx.SimpleHelpProvider() wx.HelpProvider_Set(provider) @@ -84,7 +83,10 @@ class FileOptionDialog(wx.Dialog): if locale.getpreferredencoding().lower() == 'mac-roman' : enc = self.le.index('macroman') else : - enc = self.le.index(locale.getpreferredencoding().lower()) + try : + enc = self.le.index(sys.getdefaultencoding().lower()) + except ValueError: + enc = self.le.index('utf-8') self.list_encodages.SetSelection(enc) grid_sizer.Add(self.list_encodages, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5) elif sheet : @@ -152,7 +154,6 @@ class ClusterNbDialog(wx.Dialog): LIST_CLASSE_OK.append(str(i)) else : LIST_CLASSE_OK.append(str(LIST_CLASSE)) - print str(LIST_CLASSE_OK) self.list_box_1 = wx.ListBox(self, -1, choices=LIST_CLASSE_OK, style=wx.LB_SINGLE | wx.LB_HSCROLL) self.list_box_1.SetHelpText("Here's some help text for field #1") box.Add(self.list_box_1, 1, wx.ALIGN_CENTRE | wx.ALL, 5) @@ -410,6 +411,20 @@ nouvelle version est disponible""" self.m_radioBox2 = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, m_radioBox2Choices, 1, wx.RA_SPECIFY_COLS ) self.m_radioBox2.SetSelection( 0 ) fgSizer1.Add( self.m_radioBox2, 0, wx.ALIGN_RIGHT|wx.ALL, 5 ) + + msg = u"""Langue de l'interface""" + self.m_staticText45 = wx.StaticText( self, wx.ID_ANY, msg, wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText45.Wrap( -1 ) + fgSizer1.Add( self.m_staticText45, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + + self.m_staticText46 = wx.StaticText( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText46.Wrap( -1 ) + fgSizer1.Add( self.m_staticText46, 0, wx.ALL, 5 ) + + self.listlangues = [ u"french", u"english" ] + 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 ) msg = u"""Vérifier l'installation des bibliothèques de R""" @@ -504,6 +519,7 @@ bibliothèques de R""" if self.parent.pref.getboolean('iramuteq', 'checkupdate') : val2 = 0 else : val2 = 1 self.m_radioBox2.SetSelection(val2) + self.langues.SetSelection(self.listlangues.index(self.parent.pref.get('iramuteq', 'guilanguage'))) if sys.platform == 'win32' : if self.parent.pref.getboolean('iramuteq', 'R_mem') : self.m_checkBox1.SetValue(True) @@ -542,6 +558,7 @@ bibliothèques de R""" if self.m_radioBox2.GetSelection() == 0 : valcheck = 'true' else : valcheck = 'false' parent.pref.set('iramuteq', 'checkupdate', valcheck) + parent.pref.set('iramuteq', 'guilanguage', self.listlangues[self.langues.GetSelection()]) if sys.platform == 'win32' : if self.m_checkBox1.GetValue() : parent.pref.set('iramuteq', 'R_mem', 'true') @@ -1076,18 +1093,8 @@ class StatDialog(wx.Dialog): wx.Dialog.__init__(self, *args, **kwds) self.fileout = "" self.parent = parent - #box = wx.BoxSizer(wx.HORIZONTAL) self.label_lem = wx.StaticText(self, -1, u"Lemmatisation") self.radio_lem = wx.RadioBox(self, -1, u"", choices=['oui', 'non'], majorDimension=0, style=wx.RA_SPECIFY_ROWS) - #sizer.Add(box, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, 5) - #box2 = wx.BoxSizer(wx.HORIZONTAL) - #self.txt_exp = wx.StaticText(self, -1, u"Utiliser le Dict. des expressions") - #self.exp = wx.RadioBox(self, -1, u"", choices=['oui', 'non'], majorDimension=0, style=wx.RA_SPECIFY_ROWS) - #self.label_uce = wx.StaticText(self, -1, u"Construire des UCE") - #self.check_uce = wx.CheckBox(self, -1) - #txt = """Nombre d'occurrences par uce""" - #self.label_occuce = wx.StaticText(self, -1, txt) - #self.spin_ctrl_4 = wx.SpinCtrl(self, -1, "",size = (100,30), min=10, max=1000, initial = 35) #txt = u"""Fréquence minimum d'une forme #analysée (0 = non utilisé)""" #self.label_8 = wx.StaticText(self, -1, txt) @@ -1139,33 +1146,15 @@ class StatDialog(wx.Dialog): def __set_properties(self) : self.SetTitle(u'Préférences') - #self.spin_ctrl_4.Enable(False) - #self.spin_ctrl_5.Enable(False) - #self.spin_max_actives.Enable(False) - -# def OnCheckUce(self, evt) : -# if self.check_uce.GetValue() : -# self.spin_ctrl_4.Enable(True) -# self.spin_ctrl_5.Enable(True) -# if self.spin_ctrl_5.GetValue() > 0 : -# self.spin_max_actives.Enable(False) -# else : -# self.spin_max_actives.Enable(True) -# else : -# self.spin_ctrl_4.Enable(False) -# self.spin_ctrl_5.Enable(False) -# self.spin_max_actives.Enable(False) - -# def OnSpin(self, evt) : -# if self.spin_ctrl_5.GetValue() > 0 : -# self.spin_max_actives.Enable(False) -# else : -# self.spin_max_actives.Enable(True) def OnKeys(self, evt): - dial = AlcOptFrame(self.parent, self) + dial = AlcOptFrame(self, self.parent.parent) dial.CenterOnParent() - val = dial.ShowModal() + dial.ShowModal() + for i in range(0,len(dial.listlabel)): + dial.keys[dial.listcle[i]] = dial.listspin[i].GetValue() + DoConf().makeoptions(['KEY'], [dial.keys], outfile = self.parent.parent.ConfigPath['key']) + dial.Destroy() class LexDialog( wx.Dialog ): @@ -1216,18 +1205,19 @@ class LexDialog( wx.Dialog ): class PrefUCECarac(wx.Dialog): def __init__(self, parent, *args, **kwds): kwds['style'] = wx.DEFAULT_DIALOG_STYLE - kwds['title'] = u"UCE caractéristiques" + kwds['title'] = u"Segments de texte caractéristiques" wx.Dialog.__init__(self, *args, **kwds) self.parent = parent first = wx.BoxSizer(wx.VERTICAL) sizer = wx.FlexGridSizer(0,2,0,0) self.label_type = wx.StaticText(self, -1, u"Score de classement") sizer.Add(self.label_type, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5) - self.radio_type = wx.RadioBox(self, -1, u"", choices=[u'absolu (somme des chi2 des formes marquées de l\'UCE)', u'relatif (moyenne des chi2 des formes marquées de l\'UCE)'], majorDimension=0, style=wx.RA_SPECIFY_ROWS) + self.radio_type = wx.RadioBox(self, -1, u"", choices=[u'absolu (somme des chi2 des formes marquées du segment)', u'relatif (moyenne des chi2 des formes marquées du segment)'], majorDimension=0, style=wx.RA_SPECIFY_ROWS) sizer.Add(self.radio_type, 0, wx.ALIGN_RIGHT, 5) - self.txt_eff = wx.StaticText(self, -1, u"Nombre d\'UCE maximum") + self.txt_eff = wx.StaticText(self, -1, u"Nombre maximum de segments de texte") sizer.Add(self.txt_eff, 0, wx.ALIGN_CENTRE, 5) self.spin_eff = wx.SpinCtrl(self, -1, '', size = (100, 30), min = 1, max = 100000, initial = 50) + self.spin_eff.SetValue(50) sizer.Add(self.spin_eff, 0, wx.ALIGN_CENTRE|wx.ALL, 5) first.Add(sizer, 0, wx.ALL, 5) btnsizer = wx.StdDialogButtonSizer() @@ -1478,7 +1468,7 @@ class FindInCluster(wx.Frame): # begin wxGlade: MyFrame.__init__ wx.Frame.__init__(self, parent, id) self.spanel = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL) - self.sizer1 = wx.FlexGridSizer(len(result)+1,4,0,0) + self.sizer1 = wx.FlexGridSizer(0,4,0,0) self.parent = parent self.formes = {} txt = [u'forme',u'classe',u'chi2',u'voir'] @@ -1564,10 +1554,10 @@ class FindInCluster(wx.Frame): def OnCloseWindow(self, evt): self.Destroy() -class SearchDial ( wx.Dialog ): +class SearchDial ( wx.Frame ): def __init__( self, parent, listctrl, col, shown): - wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE ) + wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE ) self.parent = parent self.listctrl = listctrl self.col = col @@ -1702,7 +1692,6 @@ class SearchDial ( wx.Dialog ): self.search.Clear() def UnSelectList(liste) : - print liste if liste.GetFirstSelected() != -1 : last = liste.GetFirstSelected() liste.Select(liste.GetFirstSelected(), False) @@ -1712,12 +1701,13 @@ def UnSelectList(liste) : class OptLexi(wx.Dialog): - def __init__(self, *args, **kwds): + def __init__(self, parent, force_chi = False): # begin wxGlade: MyDialog.__init__ - kwds["style"] = wx.DEFAULT_DIALOG_STYLE - wx.Dialog.__init__(self, *args, **kwds) + #kwds["style"] = wx.DEFAULT_DIALOG_STYLE + wx.Dialog.__init__(self, parent, style = wx.DEFAULT_DIALOG_STYLE) self.listet = None self.variables = None + self.force_chi = force_chi #self.labellem = wx.StaticText(self, -1, u"Lemmatisation : ") #self.checklem = wx.CheckBox(self, -1) self.label_var = wx.StaticText(self, -1, u"Sélection par :") @@ -1726,10 +1716,15 @@ class OptLexi(wx.Dialog): self.list_box_1 = wx.ListBox(self, -1, choices=[], size = wx.Size( 150,200 ), style=wx.LB_EXTENDED | wx.LB_HSCROLL) self.button_2 = wx.Button(self, wx.ID_CANCEL, "") self.button_1 = wx.Button(self, wx.ID_OK, "") + if not self.force_chi : + indices = [u'loi hypergéométique', u'chi2'] + else : + indices = [u'chi2'] self.label_indice = wx.StaticText(self, -1, u"indice") - self.choice_indice = wx.Choice(self, -1, (100,50), choices = [u'loi hypergéométique', u'chi2']) - self.label = wx.StaticText(self, -1, u"effectif minimum") - self.spin = wx.SpinCtrl(self, -1, min = 1, max = 10000) + self.choice_indice = wx.Choice(self, -1, (100,50), choices = indices) + if not self.force_chi : + self.label = wx.StaticText(self, -1, u"effectif minimum") + self.spin = wx.SpinCtrl(self, -1, min = 1, max = 10000, initial = 10) self.Bind(wx.EVT_CHOICE, self.onselect, self.choice) self.__set_properties() self.__do_layout() @@ -1738,8 +1733,10 @@ class OptLexi(wx.Dialog): def __set_properties(self): # begin wxGlade: MyDialog.__set_properties self.SetTitle("Choix des variables") - self.spin.SetValue(10) + if not self.force_chi : + self.spin.SetValue(10) self.choice.SetSelection(0) + self.choice_indice.SetSelection(0) #self.SetMinSize(wx.Size(300, 400)) # end wxGlade @@ -1758,8 +1755,9 @@ class OptLexi(wx.Dialog): sizer_3.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3) sizer_2.Add(self.label_indice, 0, wx.ALIGN_CENTER_VERTICAL, 3) sizer_2.Add(self.choice_indice, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3) - sizer_2.Add(self.label, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3) - sizer_2.Add(self.spin, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 3) + if not self.force_chi : + sizer_2.Add(self.label, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3) + sizer_2.Add(self.spin, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 3) sizer_1.Add(sizer_2, 0, wx.ALIGN_CENTER_HORIZONTAL, 3) sizer_1.Add(sizer_3, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_RIGHT, 3) self.SetSizer(sizer_1) @@ -1938,6 +1936,7 @@ class PrefWordCloud ( wx.Dialog ): bSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 ) self.spin_H = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 100,30 ), wx.SP_ARROW_KEYS, 0, 10000, 600 ) + self.spin_H.SetValue( 800 ) bSizer1.Add( self.spin_H, 0, wx.ALL, 5 ) fgSizer1.Add( bSizer1, 1, wx.EXPAND, 5 ) @@ -1949,6 +1948,7 @@ class PrefWordCloud ( wx.Dialog ): bSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 ) self.spin_L = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 100,30 ), wx.SP_ARROW_KEYS, 0, 10000, 600 ) + self.spin_L.SetValue( 800 ) bSizer3.Add( self.spin_L, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) fgSizer1.Add( bSizer3, 1, wx.EXPAND, 5 ) @@ -1959,11 +1959,27 @@ class PrefWordCloud ( wx.Dialog ): self.m_staticline4 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) fgSizer1.Add( self.m_staticline4, 0, wx.EXPAND |wx.ALL, 5 ) + self.m_staticText11 = wx.StaticText( self, wx.ID_ANY, u"Format de l'image", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText11.Wrap( -1 ) + fgSizer1.Add( self.m_staticText11, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + + formatChoices = [ u"png", u"svg" ] + self.format = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, formatChoices, 0 ) + self.format.SetSelection( 0 ) + fgSizer1.Add( self.format, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + + self.m_staticline13 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) + fgSizer1.Add( self.m_staticline13, 0, wx.EXPAND |wx.ALL, 5 ) + + self.m_staticline14 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) + fgSizer1.Add( self.m_staticline14, 0, wx.EXPAND |wx.ALL, 5 ) + self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, u"Nombre maximum de formes", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText5.Wrap( -1 ) fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 ) self.spin_maxword = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 10000, 600 ) + self.spin_maxword.SetValue( 600 ) fgSizer1.Add( self.spin_maxword, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) self.m_staticline5 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) @@ -2000,6 +2016,7 @@ class PrefWordCloud ( wx.Dialog ): bSizer5.Add( self.m_staticText7, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) self.spin_mincex = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 1000, 5 ) + self.spin_mincex.SetValue( 5 ) bSizer5.Add( self.spin_mincex, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) bSizer4.Add( bSizer5, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 ) @@ -2011,6 +2028,7 @@ class PrefWordCloud ( wx.Dialog ): bSizer6.Add( self.m_staticText8, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) self.spin_maxcex = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 1000, 50 ) + self.spin_maxcex.SetValue( 50 ) bSizer6.Add( self.spin_maxcex, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 ) bSizer4.Add( bSizer6, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 ) @@ -2204,12 +2222,12 @@ class CorpusPref ( wx.Dialog ): def __init__( self, parent, parametres ): wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Préférences", pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE ) self.parent = parent - langues_n = [u'français', u'english', u'german (expérimentale)', u'italian (expérimentale)', u'swedish (exp.)', u'portuguese (exp.)', 'greek', 'other...'] + langues_n = [u'français', u'english', u'german (expérimentale)', u'italian', u'swedish (expérimentale)', u'portuguese (expérimentale)', u'greek (expériementale)', u'autre...'] self.langues = [u'french', u'english', u'german', 'italian', 'swedish', u'portuguese', 'greek', 'other'] self.encodages = [enc[0].lower() for enc in encodages] ucimark = [u'****', u'0000'] - ucemethod = [u'charactères', u'occurrences', u'paragraphe'] + ucemethod = [u'charactères', u'occurrences', u'paragraphes'] self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) @@ -2412,7 +2430,10 @@ class CorpusPref ( wx.Dialog ): if locale.getpreferredencoding().lower() == 'mac-roman' : enc = self.encodages.index('macroman') else : - enc = self.encodages.index(locale.getpreferredencoding().lower()) + try : + enc = self.encodages.index(locale.getpreferredencoding().lower()) + except ValueError : + enc = self.encodages.index('utf-8') self.encodage_choices.SetSelection(enc) self.lang_choices.SetSelection(0) self.repout_choices.SetValue(parametres['pathout']) @@ -2603,7 +2624,6 @@ class ExtractDialog ( wx.Dialog ): else : parametres['onefile'] = False parametres['encodeout'] = locale.getpreferredencoding() - print parametres return parametres def __del__( self ):