1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2011 Pierre Ratinaud
7 from search_list import SearchList
8 from dialog import SearchDial
12 class SearchFrame(wx.Frame):
13 def __init__(self, parent, id, title, corpus, size=(800, 500)):
14 # begin wxGlade: MyFrame.__init__
15 #kwds["style"] = wx.DEFAULT_FRAME_STYLE
16 wx.Frame.__init__(self, parent, id)
18 search_id = wx.NewId()
19 self.Bind(wx.EVT_MENU, self.onsearch, id = search_id)
20 self.accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL, ord('F'), search_id)])
21 self.SetAcceleratorTable(self.accel_tbl)
24 dlg = wx.ProgressDialog(u"Traitements", u"lecture du tableau...", maximum = 4, parent=self, style = wx.PD_APP_MODAL|wx.PD_AUTO_HIDE|wx.PD_ELAPSED_TIME)
27 with codecs.open(corpus.dictpathout['chisqtable'], 'r', parent.SysEncoding) as f :
28 chisqtable = [line.replace('\n','').replace('"','').replace(',','.').split(';') for line in f]
33 self.dchisqtable = dict([[i, [i, line[0]] + [float(val) for val in line[1:]]] for i, line in enumerate(chisqtable)])
34 self.dindex = dict([[line[0], i] for i,line in enumerate(chisqtable)])
35 #self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
36 #nbactives = len(self.corpus.actives)
38 with open(corpus.dictpathout['ContEtOut'], 'r') as f :
39 nbetoiles = len(f.readlines())
40 with open(corpus.dictpathout['Contout'], 'r') as f :
41 nbactives = len(f.readlines())
42 dlg.Update(4, u"Ouverture...")
43 self.liste = SearchList(self, parent, self.dchisqtable, first, nbactives, nbetoiles)
45 #self.HtmlPage = wx.html.HtmlWindow(self, -1)
46 #if "gtk2" in wx.PlatformInfo:
47 # self.HtmlPage.SetStandardFonts()
48 #self.HtmlPage.SetFonts('Courier', 'Courier')
50 self.button_1 = wx.Button(self, -1, "Fermer")
51 self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1)
52 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
53 self.SetTitle(u'Navigation')
54 self.SetSize(wx.Size(400,700))
58 def __do_layout(self):
59 # begin wxGlade: MyFrame.__do_layout
60 sizer_1 = wx.BoxSizer(wx.VERTICAL)
61 sizer_2 = wx.BoxSizer(wx.VERTICAL)
62 sizer_2.Add(self.liste, 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0)
63 #sizer_2.Add(self.HtmlPage, 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0)
64 sizer_2.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ADJUST_MINSIZE, 0)
65 sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
66 self.SetAutoLayout(True)
67 self.SetSizer(sizer_1)
71 def OnCloseMe(self, event):
74 def OnCloseWindow(self, event):
77 def onsearch(self, evt) :
79 self.dial = SearchDial(self, self.liste, 1, True)
83 self.dial = SearchDial(self, self.liste, 1, False)