X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=dialog.py;h=82dc089cdc1ffc4e5a42a1b7e0fe32739a7678bd;hp=64b993a107082c1b104b39f1c9d93fb0d853f72c;hb=e1fab13fcb5acc145a53301b5a7f9a4ab496f3c1;hpb=238d461ff111b1bc3302494de4d9b630f9e9f623 diff --git a/dialog.py b/dialog.py index 64b993a..82dc089 100755 --- a/dialog.py +++ b/dialog.py @@ -15,6 +15,7 @@ from PrintRScript import barplot import tempfile import sys from KeyFrame import AlcOptFrame +import wx.lib.hyperlink as hl #--------------------------------------------------------------------------- provider = wx.SimpleHelpProvider() wx.HelpProvider_Set(provider) @@ -375,7 +376,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 ) @@ -543,9 +544,9 @@ class PrefGraph(wx.Dialog): self.paramgraph=paramgraph self.labeltype = wx.StaticText(self, -1, _(u"Graphic type").decode('utf8')) if self.paramgraph['clnb'] <= 3 : - choix = [u'2D', 'web 2D'] + choix = [u'2D']#, 'web 2D'] else : - choix=[u'2D' ,u'3D', 'web 2D', 'web 3D'] + choix=[u'2D' ,u'3D']#, 'web 2D', 'web 3D'] self.choicetype = wx.Choice(self, -1, (100,50), choices=choix) self.label_format = wx.StaticText(self, -1, _(u"Picture format").decode('utf8')) self.choix_format = wx.Choice(self, -1, (100,50), choices = ['png', 'svg']) @@ -1038,7 +1039,7 @@ class PrefSimpleFile(wx.Dialog): class StatDialog ( wx.Dialog ): def __init__( self, parent, keys ): - wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Settings", pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.DEFAULT_DIALOG_STYLE ) + wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Settings").decode('utf8'), pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.DEFAULT_DIALOG_STYLE ) self.fileout = "" self.parent = parent @@ -1049,36 +1050,36 @@ class StatDialog ( wx.Dialog ): gSizer1 = wx.GridSizer( 0, 2, 0, 0 ) - self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"Lemmatization", wx.DefaultPosition, wx.DefaultSize, 0 ) + 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", u"no" ] + 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", wx.DefaultPosition, wx.DefaultSize, 0 ) + 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", wx.DefaultPosition, wx.DefaultSize, 0 ) - gSizer1.Add( self.button_5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 ) + 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, 1 ) - self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, u"Dictionary", wx.DefaultPosition, wx.DefaultSize, 0 ) + 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", u"other" ] + 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 +1089,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 ) @@ -1564,7 +1565,7 @@ class FindInCluster(wx.Frame): class SearchDial ( wx.Frame ): def __init__( self, parent, listctrl, col, shown): - wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE ) + wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP ) self.parent = parent self.listctrl = listctrl self.col = col @@ -1739,6 +1740,7 @@ class OptLexi(wx.Dialog): self.label = wx.StaticText(self, -1, _(u"Minimum frequency").decode('utf8')) self.spin = wx.SpinCtrl(self, -1, min = 1, max = 10000, initial = 10) self.Bind(wx.EVT_CHOICE, self.onselect, self.choice) + self.Bind(wx.EVT_LISTBOX, self.onchoose, self.list_box_1) self.__set_properties() self.__do_layout() # end wxGlade @@ -1750,6 +1752,7 @@ class OptLexi(wx.Dialog): self.spin.SetValue(10) self.choice.SetSelection(0) self.choice_indice.SetSelection(0) + self.button_1.Enable(False) #self.SetMinSize(wx.Size(300, 400)) # end wxGlade @@ -1789,7 +1792,18 @@ class OptLexi(wx.Dialog): else : for et in self.listet : self.list_box_1.Append(et) - + + def onchoose(self, evt): + if self.choice.GetSelection()== 0 : + if len(self.list_box_1.GetSelections()) > 0 : + self.button_1.Enable(True) + else : + self.button_1.Enable(False) + elif self.choice.GetSelection() == 1 : + if len(self.list_box_1.GetSelections()) > 1 : + self.button_1.Enable(True) + else : + self.button_1.Enable(False) class PrefDendro ( wx.Dialog ): @@ -1852,38 +1866,53 @@ class PrefDendro ( 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.text_format_image = wx.StaticText( self, wx.ID_ANY, _(u"Image format").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 ) + self.text_format_image.Wrap( -1 ) + fgSizer1.Add( self.text_format_image, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Color or black and white").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_staticText5.Wrap( -1 ) - fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + self.choice_format = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, ['png', 'svg'], 0 ) + self.choice_format.SetSelection( 0 ) + fgSizer1.Add( self.choice_format, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) - m_radioBox1Choices = [ _(u"color").decode('utf8'), _(u"black and white").decode('utf8') ] - self.m_radioBox1 = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, m_radioBox1Choices, 1, wx.RA_SPECIFY_COLS ) - self.m_radioBox1.SetSelection( 0 ) - fgSizer1.Add( self.m_radioBox1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) + self.m_staticline31 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) + fgSizer1.Add( self.m_staticline31, 0, wx.EXPAND |wx.ALL, 5 ) - self.m_staticline5 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) - fgSizer1.Add( self.m_staticline5, 0, wx.EXPAND |wx.ALL, 5 ) + self.m_staticline41 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) + fgSizer1.Add( self.m_staticline41, 0, wx.EXPAND |wx.ALL, 5 ) - self.m_staticline6 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) - fgSizer1.Add( self.m_staticline6, 0, wx.EXPAND |wx.ALL, 5 ) + if self.param['typedendro'] == 'classique' : + self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Color or black and white").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText5.Wrap( -1 ) + fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - bSizer4 = wx.BoxSizer( wx.HORIZONTAL ) + m_radioBox1Choices = [ _(u"color").decode('utf8'), _(u"black and white").decode('utf8') ] + self.m_radioBox1 = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, m_radioBox1Choices, 1, wx.RA_SPECIFY_COLS ) + self.m_radioBox1.SetSelection( 0 ) + fgSizer1.Add( self.m_radioBox1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) - self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, _(u"Add cluster size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_staticText6.Wrap( -1 ) - bSizer4.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + self.m_staticline5 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) + fgSizer1.Add( self.m_staticline5, 0, wx.EXPAND |wx.ALL, 5 ) - self.m_checkBox1 = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_checkBox1.SetValue(True) - bSizer4.Add( self.m_checkBox1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + self.m_staticline6 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) + fgSizer1.Add( self.m_staticline6, 0, wx.EXPAND |wx.ALL, 5 ) - fgSizer1.Add( bSizer4, 1, wx.EXPAND, 5 ) + bSizer4 = wx.BoxSizer( wx.HORIZONTAL ) - m_radioBox2Choices = [ _(u"circular diagram").decode('utf8'), _(u"bar").decode('utf8') ] - 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_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) + self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, _(u"Add cluster size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText6.Wrap( -1 ) + bSizer4.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + + self.m_checkBox1 = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_checkBox1.SetValue(True) + bSizer4.Add( self.m_checkBox1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + + fgSizer1.Add( bSizer4, 1, wx.EXPAND, 5 ) + + m_radioBox2Choices = [ _(u"circular diagram").decode('utf8'), _(u"bar").decode('utf8') ] + 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_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) self.m_staticline7 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) fgSizer1.Add( self.m_staticline7, 0, wx.EXPAND |wx.ALL, 5 ) @@ -1913,9 +1942,11 @@ class PrefDendro ( wx.Dialog ): self.m_spinCtrl2.SetValue(self.param['width']) self.m_spinCtrl1.SetValue(self.param['height']) self.m_choice1.SetSelection(self.param['type_dendro']) - self.m_radioBox1.SetSelection(self.param['color_nb']) - self.m_checkBox1.SetValue(self.param['taille_classe']) - self.m_radioBox2.SetSelection(self.param['type_tclasse']) + self.choice_format.SetSelection(self.param['svg']) + if self.param['typedendro'] == 'classique' : + self.m_radioBox1.SetSelection(self.param['color_nb']) + self.m_checkBox1.SetValue(self.param['taille_classe']) + self.m_radioBox2.SetSelection(self.param['type_tclasse']) def __del__( self ): pass @@ -2208,8 +2239,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): @@ -2235,8 +2268,11 @@ class ChiDialog(wx.Dialog): self.Layout() # end wxGlade - def Select1(self, event): # wxGlade: ConfChi2. - event.Skip() + def selchange(self, event): # wxGlade: ConfChi2. + 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): @@ -2247,9 +2283,9 @@ class ChiDialog(wx.Dialog): class CorpusPref ( wx.Dialog ): def __init__( self, parent, parametres ): - wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Settings").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE ) + wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Settings").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE | wx.STAY_ON_TOP ) self.parent = parent - langues_n = [u'français', u'english', u'german (expérimentale)', u'italian', u'swedish (expérimentale)', u'portuguese (expérimentale)', u'spanish (expérimentale)', u'greek (expériementale)', u'galician (expérimentale)', u'autre...'] + langues_n = [u'français', u'english', u'german (expérimentale)', u'italian', u'swedish (expérimentale)', u'portuguese', u'spanish', u'greek (expériementale)', u'galician (expérimentale)', u'autre...'] self.langues = [u'french', u'english', u'german', u'italian', u'swedish', u'portuguese', u'spanish', u'greek', u'galician', u'other'] self.encodages = [enc[0].lower() for enc in encodages] @@ -2321,7 +2357,9 @@ class CorpusPref ( wx.Dialog ): fgSizer5.Add( self.radio_other_dict, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) self.otherdictpath = wx.FilePickerCtrl( self.m_panel1, wx.ID_ANY, wx.EmptyString, _(u"Select a file").decode('utf8'), u"*.*", wx.DefaultPosition, wx.Size( 300,-1 ), wx.FLP_DEFAULT_STYLE ) + self.otherdictpath.SetMinSize(wx.Size(300, -1)) fgSizer5.Add( self.otherdictpath, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + self.otherdictpath.Enable( False ) bSizer2.Add( fgSizer5, 1, wx.EXPAND, 5 ) @@ -2477,7 +2515,9 @@ class CorpusPref ( wx.Dialog ): # Connect Events self.Bind(wx.EVT_BUTTON, self.OnChangeDir, self.m_button1) self.lang_choices.Bind( wx.EVT_CHOICE, self.OnChangeLangage ) - self.radio_other_dict.Bind( wx.EVT_RADIOBUTTON, self.changedictchoice ) + self.radio_other_dict.Bind( wx.EVT_RADIOBUTTON, self.changedictchoice ) + self.radio_default_dict.Bind( wx.EVT_RADIOBUTTON, self.changedictchoice ) + self.otherdictpath.Bind( wx.EVT_FILEPICKER_CHANGED, self.selectdict) self.setparametres(parametres) self.SetSizer( bSizer1 ) @@ -2518,6 +2558,7 @@ class CorpusPref ( wx.Dialog ): self.check_tirets.SetValue(parametres['tiret']) self.check_tolist.SetValue(parametres['tolist']) self.check_ponct.SetValue(parametres['keep_ponct']) + self.defaultdictpath.SetValue(self.langues[0]) def doparametres(self) : parametres = {} @@ -2537,6 +2578,8 @@ class CorpusPref ( wx.Dialog ): parametres['tiret'] = self.check_tirets.GetValue() parametres['tolist'] = self.check_tolist.GetValue() parametres['keep_ponct'] = self.check_ponct.GetValue() + if self.radio_other_dict.GetValue() : + parametres['dictionary'] = self.otherdictpath.GetPath() for val in parametres : if isinstance(parametres[val], bool) : if parametres[val] : @@ -2546,10 +2589,21 @@ class CorpusPref ( wx.Dialog ): return parametres def OnChangeLangage(self, evt): - pass + self.defaultdictpath.SetValue(self.langues[self.lang_choices.GetSelection()]) def changedictchoice(self, evt): - pass + if self.radio_default_dict.GetValue() : + self.otherdictpath.Enable( False ) + self.m_sdbSizer1OK.Enable( True ) + else : + self.otherdictpath.Enable( True ) + if self.otherdictpath.GetPath() == '' : + self.m_sdbSizer1OK.Enable( False ) + + def selectdict(self, evt): + if self.otherdictpath.GetPath() != '' : + self.m_sdbSizer1OK.Enable( True ) + class ConcordList(wx.HtmlListBox): @@ -2566,28 +2620,30 @@ class ConcordList(wx.HtmlListBox): class message(wx.Frame): def __init__(self, parent, items, title, size, save = True, uceids = None): - wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = title, pos = wx.DefaultPosition, size = size, style = wx.DEFAULT_FRAME_STYLE ) + wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = title, pos = wx.DefaultPosition, size = size, style = wx.CLOSE_BOX|wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.TAB_TRAVERSAL ) self.save = save self.uceids = uceids - self.ira = wx.GetApp().GetTopWindow() - self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) - + self.ira = wx.GetApp().GetTopWindow() + self.SetIcon(self.ira._icon) + #self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) + self.items = items self.html = "" #self.HtmlPage=wx.html.HtmlWindow(self, -1) - self.HtmlPage = ConcordList(self, items) + self.panel = wx.Panel(self, wx.ID_ANY) + self.HtmlPage = ConcordList(self.panel, items) #self.HtmlPage.SetMinSize( size ) #if "gtk2" in wx.PlatformInfo: # self.HtmlPage.SetStandardFonts() #self.HtmlPage.SetFonts('Courier','Courier') - self.button_1 = wx.Button(self, wx.ID_CANCEL) + self.button_1 = wx.Button(self.panel, wx.ID_CANCEL) self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1) if self.save : - self.button_2 = wx.Button(self, wx.ID_SAVE) + self.button_2 = wx.Button(self.panel, wx.ID_SAVE) self.Bind(wx.EVT_BUTTON, self.OnSavePage, self.button_2) if self.uceids is not None : - self.butsub = wx.Button(self, -1, _(u"Build sub corpus").decode('utf8')) + self.butsub = wx.Button(self.panel, -1, _(u"Build sub corpus").decode('utf8')) self.Bind(wx.EVT_BUTTON, self.OnSub, self.butsub) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) self.__do_layout() @@ -2597,15 +2653,16 @@ class message(wx.Frame): sizer_2.Add(self.HtmlPage, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) #m_sdbSizer1 = wx.StdDialogButtonSizer() m_sdbSizer1 = wx.BoxSizer(wx.HORIZONTAL) - m_sdbSizer1.Add( self.button_1 , 0, wx.RIGHT | wx.EXPAND) + m_sdbSizer1.Add( self.button_1 , 0, wx.ALIGN_RIGHT | wx.EXPAND) if self.save : - m_sdbSizer1.Add( self.button_2 , 0, wx.RIGHT | wx.EXPAND) + m_sdbSizer1.Add( self.button_2 , 0, wx.ALIGN_RIGHT | wx.EXPAND) if self.uceids is not None : - m_sdbSizer1.Add( self.butsub , 0, wx.RIGHT | wx.EXPAND) + m_sdbSizer1.Add( self.butsub , 0, wx.ALIGN_RIGHT | wx.EXPAND) #m_sdbSizer1.Realize() - sizer_2.Add(m_sdbSizer1, 0, wx.RIGHT | wx.EXPAND, 5) - self.SetSizer(sizer_2) - self.Layout() + #self.panel.SetSizer( m_sdbSizer1 ) + sizer_2.Add( m_sdbSizer1, 0, wx.ALIGN_RIGHT, 5) + self.panel.SetSizer(sizer_2) + self.panel.Layout() sizer_2.Fit( self ) def OnSavePage(self, evt) : @@ -2613,8 +2670,9 @@ class message(wx.Frame): self, message=_(u"Save as ...").decode('utf8'), defaultDir=os.getcwd(), defaultFile="concordancier.html", wildcard="html|*.html", style=wx.SAVE | wx.OVERWRITE_PROMPT ) - dlg.SetFilterIndex(2) + #dlg.SetFilterIndex(2) dlg.CenterOnParent() + self.html = '
'.join([self.items[i] for i in range(0,len(self.items))]) if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() with open(path, 'w') as f : @@ -2627,9 +2685,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 ): @@ -2758,44 +2815,6 @@ class ExtractDialog ( wx.Dialog ): def __del__( self ): pass -# class FreqDialog(wx.Dialog): -# def __init__(self, parent, ID, listcol, title, size) : -# wx.Dialog.__init__(self, parent, ID, title, size=size, pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE | wx.CANCEL | wx.OK ) -# pre = wx.PreDialog() -# pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) -# pre.Create(parent, ID, title, wx.DefaultPosition, size, wx.DEFAULT_DIALOG_STYLE | wx.CANCEL | wx.OK) -# self.PostCreate(pre) -# self.parent = parent -# sizer = wx.BoxSizer(wx.VERTICAL) -# #self.content = parent.content -# self.header = listcol -# #LABELLIST = [] -# #for i in self.header: -# # forme = i -# # if len(forme) > 60 : -# # LABELLIST.append(i[0:60]) -# # else: -# # LABELLIST.append(i) -# self.list_box_1 = wx.ListBox(self, -1, choices=self.header, style=wx.LB_EXTENDED | wx.LB_HSCROLL) -# sizer.Add(self.list_box_1, 0, 5) -# -# btnsizer = wx.BoxSizer(wx.HORIZONTAL) -# -# btn = wx.Button(self, wx.ID_CANCEL) -# btnsizer.Add(btn) -# -# btn = wx.Button(self, wx.ID_OK) -# btn.SetDefault() -# btnsizer.Add(btn) -# -# sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 5) -# self.SetSizer(sizer) -# sizer.Fit(self) -# self.SetTitle(_(u"Selection").decode('utf8')) -# - # end wxGlade - - class FreqDialog ( wx.Dialog ): def __init__( self, parent, listcol, title, size = wx.Size( -1,-1 ), showNA = True): @@ -2808,7 +2827,7 @@ class FreqDialog ( wx.Dialog ): bSizer1 = wx.BoxSizer( wx.VERTICAL ) m_listBox1Choices = self.header - self.m_listBox1 = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_listBox1Choices, wx.LB_EXTENDED|wx.LB_HSCROLL|wx.LB_MULTIPLE ) + self.m_listBox1 = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_listBox1Choices, wx.LB_EXTENDED|wx.LB_HSCROLL ) self.m_listBox1.SetMinSize( wx.Size( 500,-1 ) ) bSizer1.Add( self.m_listBox1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) @@ -2841,11 +2860,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 ): @@ -2963,10 +2988,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 ): @@ -3018,7 +3053,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 ) @@ -3028,14 +3063,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 ) @@ -3064,14 +3099,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 ) @@ -3079,11 +3123,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 ) @@ -3092,14 +3136,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 ) @@ -3114,7 +3158,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 ) @@ -3165,48 +3209,81 @@ class BarGraphDialog ( wx.Dialog ): self.heightsp.Enable(True) event.Skip() -class MessageImage(wx.Frame): - def __init__(self, parent, parametres, title, size): - wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = title, pos = wx.DefaultPosition, size = size, style = wx.DEFAULT_FRAME_STYLE ) - self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) +class ImageViewer ( wx.Frame ): + + def __init__( self, parent, parametres, title, size ): + wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = title, pos = wx.DefaultPosition, size = size, style = wx.DEFAULT_FRAME_STYLE|wx.MAXIMIZE_BOX|wx.MINIMIZE_BOX|wx.STAY_ON_TOP|wx.TAB_TRAVERSAL ) + + self.ira = wx.GetApp().GetTopWindow() + self.SetIcon(self.ira._icon) self.parametres = parametres self.imageFile = self.parametres['tmpgraph'] if parametres['svg'] == 'TRUE' : self.imagename = u"image.svg" else : - self.imagename = u"iamge.png" - self.HtmlPage = wx.html.HtmlWindow(self, -1) - self.HtmlPage.SetMinSize(size) - if "gtk2" in wx.PlatformInfo: - self.HtmlPage.SetStandardFonts() - self.HtmlPage.SetFonts('Courier', 'Courier') - - self.button_1 = wx.Button(self, wx.ID_CANCEL) - self.button_2 = wx.Button(self, wx.ID_SAVE) - self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1) - self.Bind(wx.EVT_BUTTON, self.OnSaveImage, self.button_2) - self.do_layout() - - def do_layout(self): - self.sizer_1 = wx.BoxSizer(wx.VERTICAL) - self.sizer_2 = wx.BoxSizer(wx.HORIZONTAL) - self.sizer_1.Add(self.HtmlPage, 2, wx.EXPAND, 0) - - self.m_sdbSizer1 = wx.StdDialogButtonSizer() - self.m_sdbSizer1.AddButton( self.button_2 ) - self.m_sdbSizer1.AddButton( self.button_1 ) - self.m_sdbSizer1.Realize() - self.sizer_1.Add(self.m_sdbSizer1, 0, wx.EXPAND, 5) - self.SetSizer(self.sizer_1) + self.imagename = u"image.png" + + self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) + + bSizer1 = wx.BoxSizer( wx.VERTICAL ) + + self.m_panel1 = wx.ScrolledWindow(self, -1)# wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL|wx.TAB_TRAVERSAL|wx.VSCROLL ) + self.m_panel1.SetScrollbars(1, 1, 200, 300) + bSizer2 = wx.BoxSizer( wx.VERTICAL ) + + if parametres['svg'] == 'FALSE' : + image = wx.Image(self.imageFile, wx.BITMAP_TYPE_PNG) + W = image.GetWidth() + H = image.GetHeight() + if W > 1000 : + W = 1000 + if H > 800 : + H = 800 + image = image.ConvertToBitmap() + self.m_bitmap1 = wx.StaticBitmap( self.m_panel1, wx.ID_ANY, image, wx.DefaultPosition, wx.DefaultSize, 0 ) + bSizer2.Add( self.m_bitmap1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + else : + link = hl.HyperLinkCtrl(self.m_panel1, wx.ID_ANY, u"Click on this link", URL=self.imageFile ) + bSizer2.Add( link, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + + self.m_panel1.SetSizer( bSizer2 ) + self.m_panel1.Layout() + bSizer2.Fit( self.m_panel1 ) + bSizer1.Add( self.m_panel1, 1, wx.EXPAND |wx.ALL, 5 ) + + panel = wx.Panel(self, -1) + m_sdbSizer1 = wx.StdDialogButtonSizer() + self.m_sdbSizer1Save = wx.Button( panel, wx.ID_SAVE ) + m_sdbSizer1.AddButton( self.m_sdbSizer1Save ) + self.m_sdbSizer1Cancel = wx.Button( panel, wx.ID_CANCEL ) + m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel ) + m_sdbSizer1.Realize(); + + panel.SetSizer( m_sdbSizer1 ) + + bSizer1.Add( panel, 0, wx.EXPAND, 5 ) + + + self.SetSizer( bSizer1 ) self.Layout() - self.sizer_1.Fit( self ) - + + self.Centre( wx.BOTH ) + + if parametres['svg'] == 'FALSE' : + self.SetSize((W + 30,H + 30)) + + self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.m_sdbSizer1Cancel) + self.Bind(wx.EVT_BUTTON, self.OnSaveImage, self.m_sdbSizer1Save) + + def __del__( self ): + pass + def OnCloseMe(self, event): - self.Destroy() + self.Destroy() 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) @@ -3250,12 +3327,6 @@ 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)) - if svg == 'FALSE' : - txt = "" % tmpgraph - else : - txt = """Copiez ce lien dans votre navigateur :
- %s""" % (tmpgraph, tmpgraph) - win.HtmlPage.SetPage(txt) + win = ImageViewer(ira, parametres, _(u"Graphic").decode('utf8'), size=(700, 500)) win.Show(True) dial.Destroy() \ No newline at end of file