1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2008 Pierre Ratinaud
7 from functions import sortedby, DoConf
9 # begin wxGlade: extracode
12 class AlcOptFrame(wx.Dialog):
13 def __init__(self,parent, *args, **kwds):
14 # begin wxGlade: AlcOptFrame.__init__
15 kwds["style"] = wx.DEFAULT_DIALOG_STYLE
16 wx.Dialog.__init__(self, *args, **kwds)
18 'adj_sup': [wx.NewId(),wx.NewId(),u"Adjectif supplémentaire"],
19 'art_ind': [wx.NewId(),wx.NewId(),u"Article indéfini"],
20 'adj_pos': [wx.NewId(),wx.NewId(),u"Adjectif possessif"],
21 'adv_sup': [wx.NewId(),wx.NewId(),u"Adverbe supplémentaire"],
22 'pro_dem': [wx.NewId(),wx.NewId(),u"Pronom démonstratif"],
23 'art_def': [wx.NewId(),wx.NewId(),u"Article défini"],
24 'con': [wx.NewId(),wx.NewId(),u"Conjonction"],
25 'pre': [wx.NewId(),wx.NewId(),u"Préposition"],
26 'ono': [wx.NewId(),wx.NewId(),u"Onomatopée"],
27 'adj_dem': [wx.NewId(),wx.NewId(),u"Adjectif démonstratif"],
28 'nom_sup': [wx.NewId(),wx.NewId(),u"Nom supplémentaire"],
29 'adv': [wx.NewId(),wx.NewId(),u"Adverbe"],
30 'pro_per': [wx.NewId(),wx.NewId(),u"Pronom personnel"],
31 'ver': [wx.NewId(),wx.NewId(),u"Verbe"],
32 'adj_num': [wx.NewId(),wx.NewId(),u"Adjectif numérique"],
33 'pro_rel': [wx.NewId(),wx.NewId(),u"Pronom relatif"],
34 'adj_ind': [wx.NewId(),wx.NewId(),u"Adjectif indéfini"],
35 'pro_ind': [wx.NewId(),wx.NewId(),u"Pronom indéfini"],
36 'pro_pos': [wx.NewId(),wx.NewId(),u"Pronom possessif"],
37 'aux': [wx.NewId(),wx.NewId(),u"Auxiliaire"],
38 'ver_sup': [wx.NewId(),wx.NewId(),u"Verbe supplémentaire"],
39 'adj': [wx.NewId(),wx.NewId(),u"Adjectif"],
40 'adj_int': [wx.NewId(),wx.NewId(),u"Adjectif interrogatif"],
41 'nom': [wx.NewId(),wx.NewId(),u"Nom commun"],
42 'num' : [wx.NewId(),wx.NewId(),u"Chiffre"],
43 'nr' : [wx.NewId(),wx.NewId(),u"Formes non reconnues"],
46 self.keys=self.parent.keys
54 self.label_1 = wx.StaticText(self, -1, u" Choix des clés d'analyse\n0=éliminé ; 1=active ; 2=supplémentaire\n")
55 self.listcleori=[[cle]+self.cle[cle] for cle in self.cle]
56 self.listcleori=sortedby(self.listcleori,1,3)
58 for line in self.listcleori:
59 cle,ids,idb,label=line
60 self.listlabel.append(wx.StaticText(self, -1, label))
61 self.listspin.append(wx.SpinCtrl(self, ids,`self.keys[cle]`, min=0, max=2))
62 #if cle != 'nr' and cle!= 'num' :
63 self.listbutton.append(wx.Button(self, idb, u"voir liste"))
64 self.listids.append(ids)
65 self.listidb.append(idb)
66 self.listcle.append(cle)
69 self.button_val = wx.Button(self, wx.ID_OK)
71 for button in self.listbutton :
72 self.Bind(wx.EVT_BUTTON,self.OnShowList,button)
74 #self.Bind(wx.EVT_BUTTON, self.OnApply, self.button_val)
76 self.dico=self.parent.parent.lexique#'dictionnaires/lexique.txt')
78 self.__set_properties()
82 def __set_properties(self):
83 # begin wxGlade: AlcOptFrame.__set_properties
84 self.SetTitle(u"Clés d'analyse")
87 def __do_layout(self):
88 # begin wxGlade: AlcOptFrame.__do_layout
89 sizer_1 = wx.BoxSizer(wx.VERTICAL)
90 sizer_2 = wx.BoxSizer(wx.VERTICAL)
91 sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
92 grid_sizer_1 = wx.GridSizer(14, 3, 0, 0)
93 grid_sizer_2 = wx.GridSizer(14, 3, 0, 0)
94 sizer_2.Add(self.label_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0)
96 grid_sizer_1.Add(self.listlabel[i], 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0)
97 grid_sizer_1.Add(self.listspin[i], 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0)
98 grid_sizer_1.Add(self.listbutton[i], 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0)
99 for i in range(13,len(self.listlabel)):
100 grid_sizer_2.Add(self.listlabel[i], 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0)
101 grid_sizer_2.Add(self.listspin[i], 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0)
102 grid_sizer_2.Add(self.listbutton[i], 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0)
103 sizer_3.Add(grid_sizer_1, 1, wx.EXPAND, 0)
104 sizer_3.Add(grid_sizer_2, 1, wx.EXPAND, 0)
105 sizer_2.Add(sizer_3, 1, wx.EXPAND, 8)
106 sizer_2.Add(self.button_val,0, wx.ALIGN_CENTER_HORIZONTAL, 0)
107 sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
108 self.SetSizer(sizer_1)
113 def OnShowList(self,evt):
114 id=evt.GetEventObject().GetId()
115 pos=self.listidb.index(id)
116 type=self.listcle[pos]
117 self.CreateList(type)
119 def CreateList(self,type):
120 if type=='ver_sup' or type=='ver':
121 #liste=[descr[0] for item,descr in self.dico.iteritems() if descr[1]==type]
122 liste = [forme for forme in self.corpus.formes if self.corpus.formes[forme].gram==type]
123 liste=list(set(liste))
125 #liste=[item for item,descr in self.dico.iteritems() if descr[1]==type]
126 liste = [forme for forme in self.corpus.formes if self.corpus.formes[forme].gram==type]
128 txt=('\n').join(liste)
129 ListViewFrame=ListView(self.parent)
130 ListViewFrame.text_ctrl_1.WriteText(txt)
131 ListViewFrame.text_ctrl_1.SetSelection(0,0)
132 ListViewFrame.text_ctrl_1.SetInsertionPoint(0)
133 ListViewFrame.CenterOnParent()
134 val=ListViewFrame.ShowModal()
136 class ListView(wx.Dialog):
137 def __init__(self, parent):
138 wx.Dialog.__init__(self, parent, size=wx.Size(200, 400),style=wx.DEFAULT_DIALOG_STYLE)
139 self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_RICH2)
140 self.text_ctrl_1.SetMinSize(wx.Size(200, 400))
141 self.btn = wx.Button(self, wx.ID_OK)
142 self.SetMinSize(wx.Size(200, 400))
143 self.__set_properties()
146 def __set_properties(self):
147 self.SetTitle("Liste")
149 def __do_layout(self):
150 sizer_1 = wx.BoxSizer(wx.VERTICAL)
151 sizer_1.Add(self.text_ctrl_1, 1, wx.EXPAND, 0)
152 sizer_1.Add(self.btn,0,wx.EXPAND,0)
153 self.SetSizer(sizer_1)