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, 900)):
14 # begin wxGlade: MyFrame.__init__
15 #kwds["style"] = wx.DEFAULT_FRAME_STYLE
16 wx.Frame.__init__(self, parent, id, size = size, style = wx.CLOSE_BOX|wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL)
18 self.ira = wx.GetApp().GetTopWindow()
19 self.SetIcon(self.ira._icon)
20 search_id = wx.NewId()
21 self.Bind(wx.EVT_MENU, self.onsearch, id = search_id)
22 self.accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL, ord('F'), search_id)])
23 self.SetAcceleratorTable(self.accel_tbl)
26 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)
29 with codecs.open(corpus.dictpathout['chisqtable'], 'r', parent.SysEncoding) as f :
30 chisqtable = [line.replace('\n','').replace('"','').replace(',','.').split(';') for line in f]
35 self.dchisqtable = dict([[i, [i, line[0]] + [float(val) for val in line[1:]]] for i, line in enumerate(chisqtable)])
36 self.dindex = dict([[line[0], i] for i,line in enumerate(chisqtable)])
37 #self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
38 #nbactives = len(self.corpus.actives)
40 with open(corpus.dictpathout['ContEtOut'], 'r') as f :
41 nbetoiles = len(f.readlines())
42 with open(corpus.dictpathout['Contout'], 'r') as f :
43 nbactives = len(f.readlines())
44 dlg.Update(4, u"Ouverture...")
45 self.liste = SearchList(self, parent, self.dchisqtable, first, nbactives, nbetoiles)
47 #self.HtmlPage = wx.html.HtmlWindow(self, -1)
48 #if "gtk2" in wx.PlatformInfo:
49 # self.HtmlPage.SetStandardFonts()
50 #self.HtmlPage.SetFonts('Courier', 'Courier')
52 self.button_1 = wx.Button(self, -1, "Fermer")
53 self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1)
54 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
55 self.SetTitle(u'Navigation')
56 self.SetSize(wx.Size(900,700))
60 def __do_layout(self):
61 # begin wxGlade: MyFrame.__do_layout
62 sizer_1 = wx.BoxSizer(wx.VERTICAL)
63 sizer_2 = wx.BoxSizer(wx.VERTICAL)
64 sizer_2.Add(self.liste, 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0)
65 #sizer_2.Add(self.HtmlPage, 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0)
66 sizer_2.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ADJUST_MINSIZE, 0)
67 sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
68 self.SetAutoLayout(True)
69 self.SetSizer(sizer_1)
73 def OnCloseMe(self, event):
76 def OnCloseWindow(self, event):
79 def onsearch(self, evt) :
81 self.dial = SearchDial(self, self.liste, 1, True)
85 self.dial = SearchDial(self, self.liste, 1, False)