From 342d693d835ba1077fe0f31824664a807cafa3bb Mon Sep 17 00:00:00 2001 From: Pierre Date: Sun, 10 Feb 2013 16:56:18 +0100 Subject: [PATCH] scrolling ? --- Liste.py | 140 +++--------------------------------------------------------- ProfList.py | 62 +-------------------------- layout.py | 1 + listlex.py | 46 +------------------- 4 files changed, 10 insertions(+), 239 deletions(-) diff --git a/Liste.py b/Liste.py index 41b5ee8..791ff67 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 #--------------------------------------------------------------------------- -#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(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) @@ -193,14 +174,15 @@ class ListPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorte 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) + rep.sort(key = itemgetter(1), reverse = True) + win = message(self, u"Formes associées", (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) + win = message(self, u"Concordancier", (750, 600)) avap = 60 item = self.getColumnText(self.GetFirstSelected(), 0) listmot = corpus.getlems()[item].formes @@ -215,117 +197,5 @@ class ListPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorte forme = corpus.getforme(forme).forme ucetxt = ucetxt.replace(' '+forme+' ', ' ' + forme + ' ') txt += ucetxt + '

' -# for uce in uce_ok: -# content = ' '+' '.join(corpus.ucis_paras_uces[uce[0]][uce[1]][uce[2]])+' ' -# for form in listmot : -# sp = '' -# i = 0 -# forme = ' ' + form + ' ' -# while i < len(content): -# coordword = content[i:].find(forme) -# if coordword != -1 and i == 0: -# txt += '
' + ' '.join(corpus.ucis[uce[0]][0]) + '
' -# if coordword < avap: -# sp = ' ' * (avap - coordword) -# deb = i -# else: -# deb = i + coordword - avap -# if len(content) < i + coordword + avap: -# fin = len(content) - 1 -# else: -# fin = i + coordword + avap -# txt += '' + sp + content[deb:fin].replace(forme, '' + forme + '') + '
' -# i += coordword + len(forme) -# sp = '' -# elif coordword != -1 and i != 0 : -# if coordword < avap: -# sp = ' ' * (avap - coordword) -# deb = i -# else: -# deb = i + coordword - avap -# if len(content) < i + coordword + avap: -# fin = len(content) - 1 -# else: -# fin = i + coordword + avap -# txt += '' + sp + content[deb:fin].replace(forme, '' + forme + '') + '
' -# i += coordword + len(forme) -# sp = '' -# else: -# i = len(content) -# sp = '' win.HtmlPage.SetPage(txt) win.Show(True) - -# def OnSize(self, event): -# w, h = self.GetClientSizeTuple() -# self.SetDimensions(0, 0, w, h) - -class message(wx.Frame): - def __init__(self, *args, **kwds): - # begin wxGlade: MyFrame.__init__ - kwds["style"] = wx.DEFAULT_FRAME_STYLE - wx.Frame.__init__(self, *args, **kwds) - #self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE) - self.HtmlPage = wx.html.HtmlWindow(self, -1) - if "gtk2" in wx.PlatformInfo: - self.HtmlPage.SetStandardFonts() - self.HtmlPage.SetFonts('Courier', 'Courier') - - - self.button_1 = wx.Button(self, -1, "Fermer") - self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1) - self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) - self.__do_layout() - # end wxGlade - - def __do_layout(self): - # begin wxGlade: MyFrame.__do_layout - sizer_1 = wx.BoxSizer(wx.VERTICAL) - sizer_2 = wx.BoxSizer(wx.VERTICAL) - sizer_2.Add(self.HtmlPage, 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0) - sizer_2.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ADJUST_MINSIZE, 0) - sizer_1.Add(sizer_2, 1, wx.EXPAND, 0) - self.SetAutoLayout(True) - self.SetSizer(sizer_1) - self.Layout() - # end wxGlade - - def OnCloseMe(self, event): - self.Close(True) - - def OnCloseWindow(self, event): - self.Destroy() - - -def getSmallUpArrowData(): - return \ -'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\ -\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\ -\x00\x00C\xb0\x89\ -\xd3.\x10\xd1m\xc3\xe5*\xbc.\x80i\xc2\x17.\x8c\xa3y\x81\x01\x00\xa1\x0e\x04e\ -?\x84B\xef\x00\x00\x00\x00IEND\xaeB`\x82" - -def getSmallDnArrowBitmap(): - return wx.BitmapFromImage(getSmallDnArrowImage()) - -def getSmallDnArrowImage(): - stream = cStringIO.StringIO(getSmallDnArrowData()) - return wx.ImageFromStream(stream) diff --git a/ProfList.py b/ProfList.py index 063a275..7802dd8 100644 --- a/ProfList.py +++ b/ProfList.py @@ -31,6 +31,7 @@ from functions import exec_rcode, MessageImage, progressbar, treat_var_mod from PrintRScript import barplot from textclassechd import ClasseCHD from shutil import copyfile +from operator import itemgetter #--------------------------------------------------------------------------- class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin): @@ -452,13 +453,6 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col 'communities' : 0, 'halo' : 0 } -# self.tableau.actives = {} -# self.tableau.lchi = self.lchi -# self.tableau.chi = {} -# for i, val in enumerate(self.la) : -# self.tableau.actives[val] = [self.lfreq[i]] -# self.tableau.chi[val] = [self.lchi[i]] - act = {} tableau.chi = {} tableau.lchi = self.lchi @@ -496,59 +490,6 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col 'tmpchi' : self.tmpchi} self.parent.SimiFromCluster(self.parent, self.Source.corpus, self.la, self.lfreq, self.lchi, self.cl - 1, parametres = parametres, dlg = progressbar(self, 4)) - #dlg = progressbar(self, 2) - #corpus = self.Source.corpus - #uces = corpus.lc[self.cl-1] - #dlg.Update(1, u'Tableau...') - ##tab = corpus.make_table_with_classe(uces, self.la) - #pathout = ConstructPathOut(self.Source.pathout.dirout+'/', 'simi_classe_%i' %self.cl) - #self.filename = os.path.join(pathout,'mat01.csv') - #dlg.Update(2, u'Ecriture...') - ##corpus.write_tab(tab, self.filename) - ##del tab - #corpus.make_and_write_sparse_matrix_from_classe(self.la, uces, self.filename) - #dlg.Destroy() - #paramsimi = {'coeff' : 0, - # 'layout' : 2, - # 'type' : 1, - # 'arbremax' : 1, - # 'coeff_tv' : 1, - # 'coeff_tv_nb' : 0, - # 'tvprop' : 0, - # 'tvmin' : 5, - # 'tvmax' : 30, - # 'coeff_te' : 1, - # 'coeff_temin' : 1, - # 'coeff_temax' : 10, - # 'label_v': 1, - # 'label_e': 0, - # 'vcex' : 0, - # 'vcexmin' : 10, - # 'vcexmax' : 25, - # 'cex' : 10, - # 'cexfromchi' : True, - # 'sfromchi': False, - # 'seuil_ok' : 0, - # 'seuil' : 1, - # 'cols' : (255,0,0), - # 'cola' : (200,200,200), - # 'width' : 1000, - # 'height' : 1000, - # 'first' : True, - # 'keep_coord' : True, - # 'alpha' : 20, - # 'film': False, - # } - #self.tableau = Tableau(self.parent, '') - #self.tableau.listactives = self.la - #self.tableau.actives = {} - #self.tableau.lchi = self.lchi - #self.tableau.chi = {} - #self.tableau.parametre['fromprof'] = True - #for i, val in enumerate(self.la) : - # self.tableau.actives[val] = [self.lfreq[i]] - # self.tableau.chi[val] = [self.lchi[i]] - #DoSimi(self, param = paramsimi, fromprof = ffr(self.filename), pathout = pathout) def on_segments(self,evt) : dlg = progressbar(self, 2) @@ -788,6 +729,7 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col if ucef != [] : nb = len(ucef) rep.append([corpus.getforme(forme).forme, nb]) + rep.sort(key = itemgetter(1), reverse = True) win = message(self, u"Formes associées", wx.Size(300, 200)) win.html = '\n' + '
'.join([' : '.join([str(val) for val in forme]) for forme in rep]) + '\n' win.HtmlPage.SetPage(win.html) diff --git a/layout.py b/layout.py index 5628059..acf8b49 100644 --- a/layout.py +++ b/layout.py @@ -110,6 +110,7 @@ class GraphPanelAfc(wx.Panel): self.panel_1.EnableScrolling(True,True) #self.panel_1.SetSize((1000,1000)) self.panel_1.SetScrollRate(20, 20) + self.paenl_1.SetFocus() def __do_layout(self): self.sizer_1 = wx.BoxSizer(wx.VERTICAL) diff --git a/listlex.py b/listlex.py index 9ead606..c3a7234 100644 --- a/listlex.py +++ b/listlex.py @@ -22,14 +22,9 @@ from functions import exec_rcode, MessageImage from chemins import ffr from PrintRScript import barplot from dialog import SearchDial, message +from operator import itemgetter #--------------------------------------------------------------------------- -#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 ListForSpec(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin): def __init__(self, parent,gparent, dlist, first, menu = True): wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES) @@ -192,6 +187,7 @@ class ListForSpec(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSor rep = [] for forme in lems[word].formes : rep.append([corpus.getforme(forme).forme, corpus.getforme(forme).freq]) + rep.sort(key = itemgetter(1), reverse = True) win = message(self, u"Formes associées", (300, 200)) win.html = '\n' + '
'.join([' : '.join([str(val) for val in forme]) for forme in rep]) + '\n' win.HtmlPage.SetPage(win.html) @@ -281,41 +277,3 @@ class ListForSpec(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSor txt = "" % tmpgraph win.HtmlPage.SetPage(txt) win.Show(True) - - - -#class message(wx.Frame): -# def __init__(self, *args, **kwds): -# # begin wxGlade: MyFrame.__init__ -# kwds["style"] = wx.DEFAULT_FRAME_STYLE -# wx.Frame.__init__(self, *args, **kwds) -# #self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE) -# self.HtmlPage=wx.html.HtmlWindow(self, -1) -# if "gtk2" in wx.PlatformInfo: -# self.HtmlPage.SetStandardFonts() -# self.HtmlPage.SetFonts('Courier','Courier') -# -# -# self.button_1 = wx.Button(self, -1, "Fermer") -# self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1) -# self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) -# self.__do_layout() -# # end wxGlade -# -# def __do_layout(self): -# # begin wxGlade: MyFrame.__do_layout -# sizer_1 = wx.BoxSizer(wx.VERTICAL) -# sizer_2 = wx.BoxSizer(wx.VERTICAL) -# sizer_2.Add(self.HtmlPage, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) -# sizer_2.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ADJUST_MINSIZE, 0) -# sizer_1.Add(sizer_2, 1, wx.EXPAND, 0) -# self.SetAutoLayout(True) -# self.SetSizer(sizer_1) -# self.Layout() -# # end wxGlade -# -# def OnCloseMe(self, event): -# self.Close(True) -# -# def OnCloseWindow(self, event): -# self.Destroy() -- 2.7.4