X-Git-Url: http://iramuteq.org/git?a=blobdiff_plain;f=Liste.py;h=daf58f5f698148d62137f065916ac00fdb53f37d;hb=7cc2905d5f514220c771dbd6661e3242681db706;hp=1b283f6a785fbb454975d733559c3c35022d9126;hpb=a503f041dc4947ee21c1d353ddd05ddb13a5e322;p=iramuteq
diff --git a/Liste.py b/Liste.py
index 1b283f6..daf58f5 100644
--- a/Liste.py
+++ b/Liste.py
@@ -16,19 +16,12 @@
import os
import sys
import wx
-from dialog import SearchDial
+from dialog import SearchDial, message
import wx.lib.mixins.listctrl as listmix
-import cStringIO
-
+from operator import itemgetter
+from functions import doconcorde
#---------------------------------------------------------------------------
-#class List(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin):
-# def __init__(self, parent, ID, pos=wx.DefaultPosition,
-# size=wx.DefaultSize, style=0):
-# wx.ListCtrl.__init__(self, parent, ID, pos, size, style)
-# listmix.ListCtrlAutoWidthMixin.__init__(self)
-
-
class ListPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
def __init__(self, parent, gparent, dlist):
wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES)
@@ -59,24 +52,12 @@ class ListPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorte
self.attr2 = wx.ListItemAttr()
self.attr2.SetBackgroundColour("light blue")
- #def PopulateList(self, dlist):
- #self.InsertColumn(0,'id', wx.LIST_FORMAT_LEFT)
-# i=1
- self.InsertColumn(0, 'forme', wx.LIST_FORMAT_RIGHT)
- self.InsertColumn(1, 'nb', wx.LIST_FORMAT_RIGHT)
- self.InsertColumn(2, 'type', wx.LIST_FORMAT_RIGHT)
+ self.InsertColumn(0, _(u'Form').decode('utf8'), wx.LIST_FORMAT_RIGHT)
+ self.InsertColumn(1, _(u'Freq.').decode('utf8'), wx.LIST_FORMAT_RIGHT)
+ self.InsertColumn(2, _(u'POS').decode('utf8'), wx.LIST_FORMAT_RIGHT)
#self.InsertColumn(3, '', wx.LIST_FORMAT_RIGHT)
- #ct = 0
-# for key, data in dlist.iteritems():
-# ct += 1
-# index = self.InsertStringItem(sys.maxint, data[0])
-# self.SetStringItem(index, 1, `data[1]`)
-# self.SetStringItem(index, 2, data[2])
-# self.SetStringItem(index, 3, '')
-# self.SetItemData(index, key)
-
self.SetColumnWidth(0, 150)
self.SetColumnWidth(1, 100)
self.SetColumnWidth(2, 100)
@@ -90,6 +71,7 @@ class ListPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorte
self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self)
self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, self)
+ self.Bind(wx.EVT_LIST_ITEM_ACTIVATED , self.OnPopupTwo, self)
# for wxMSW
self.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightClick)
@@ -116,13 +98,6 @@ class ListPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorte
else :
return self.attr2
-# def do_greyline(self):
-# for row in xrange(self.GetItemCount()):
-# if row % 2 :
-# self.SetItemBackgroundColour(row, (230, 230, 230))
-# else :
-# self.SetItemBackgroundColour(row, wx.WHITE)
-
def OnColClick(self, event):
pass
#self.do_greyline()
@@ -167,8 +142,8 @@ class ListPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorte
def onsearch(self, evt) :
self.dial = SearchDial(self, self, 0, True)
self.dial.CenterOnParent()
- self.dial.ShowModal()
- self.dial.Destroy()
+ self.dial.Show()
+ #self.dial.Destroy()
def OnRightClick(self, event):
@@ -185,8 +160,8 @@ class ListPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorte
# make a menu
menu = wx.Menu()
# add some items
- menu.Append(self.popupID1, u"Formes associées")
- menu.Append(self.popupID2, u"Concordancier")
+ menu.Append(self.popupID1, _(u"Associated forms").decode('utf8'))
+ menu.Append(self.popupID2, _(u"Concordance").decode('utf8'))
# menu.Append(self.popupID3, "recharger")
self.PopupMenu(menu)
@@ -199,140 +174,22 @@ class ListPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorte
lems = corpus.getlems()
rep = []
for forme in lems[word].formes :
- rep.append([corpus.getforme(forme).forme, corpus.getforme(forme).freq])
- win = message(self, -1, u"Formes associées", size=(300, 200), style=wx.DEFAULT_FRAME_STYLE)
- win.html = '\n' + '
'.join([' : '.join([str(val) for val in forme]) for forme in rep]) + '\n'
- win.HtmlPage.SetPage(win.html)
+ rep.append([corpus.getforme(forme).forme, corpus.getforme(forme).freq])
+ rep.sort(key = itemgetter(1), reverse = True)
+ items = dict([[i, '' + '\t:\t'.join([str(val) for val in forme]) + ''] for i, forme in enumerate(rep)])
+ win = message(self, items, _(u"Associated forms").decode('utf8'), (300, 200))
+ #win.html = '\n' + '
'.join([' : '.join([str(val) for val in forme]) for forme in rep]) + '\n'
+ #win.HtmlPage.SetPage(win.html)
win.Show(True)
def OnPopupTwo(self, event):
corpus = self.gparent.corpus
- win = message(self, -1, u"Concordancier", size=(600, 200), style=wx.DEFAULT_FRAME_STYLE)
- avap = 60
item = self.getColumnText(self.GetFirstSelected(), 0)
- listmot = corpus.getlems()[item].formes
- #uce_ok = [corpus.formes[corpus.idformes[forme].forme][1] for forme in listmot]
- uce_ok = corpus.getlemuces(item)#list(set([tuple(val) for line in uce_ok for val in line]))
- txt = '