X-Git-Url: http://iramuteq.org/git?a=blobdiff_plain;ds=inline;f=search_list.py;h=74859842b6635a48361ace8edc7162e4970b4990;hb=4553527ce669f04461155f188a35df01000844e9;hp=65b83c473e92af332ad08344c2c375cb53298fac;hpb=ab23968410d4e2eff482fd16a639801b457d5063;p=iramuteq
diff --git a/search_list.py b/search_list.py
index 65b83c4..7485984 100644
--- a/search_list.py
+++ b/search_list.py
@@ -18,17 +18,11 @@ import wx
import wx.lib.mixins.listctrl as listmix
import cStringIO
import tempfile
-from functions import exec_rcode, MessageImage
+from functions import exec_rcode
+from dialog import message, BarFrame
from chemins import ffr
-from PrintRScript import barplot, dendroandbarplot
#---------------------------------------------------------------------------
-#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 SearchList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin): #wx.Panel, listmix.ColumnSorterMixin):
def __init__(self, parent,gparent, dlist,first, nbactives, nbetoiles, add_dendro=True):
wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES)
@@ -80,7 +74,6 @@ class SearchList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSort
self.SetItemCount(len(dlist))
listmix.ColumnSorterMixin.__init__(self, len(first)+2)
- self.SortListItems(0, True)
#-----------------------------------------------------------------------------------------
@@ -92,6 +85,8 @@ class SearchList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSort
for i in range(1,len(first)-1):
self.SetColumnWidth(i, 130)
+ self.SortListItems(0, True)
+
# Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
def GetListCtrl(self):
return self
@@ -201,8 +196,8 @@ class SearchList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSort
lems = corpus.lems
rep = []
for forme in lems[word] :
- rep.append([forme, corpus.formes[forme][0]])
- win = message(self, -1, u"Formes associées", size=(300, 200), style=wx.DEFAULT_FRAME_STYLE)
+ rep.append([forme, corpus.formes[forme][0]])
+ win = message(self, u"Formes associées", size=(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)
@@ -212,7 +207,7 @@ class SearchList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSort
page = self.parent.nb.GetPage(activenotebook)
item=self.getColumnText(self.GetFirstSelected(), 0)
corpus = page.corpus
- win = message(self, -1, u"Concordancier", size=(600, 200),style = wx.DEFAULT_FRAME_STYLE)
+ win = message(self, u"Concordancier", size=(600, 200))
avap=60
listmot = corpus.lems[item]
uce_ok = [corpus.formes[forme][1] for forme in listmot]
@@ -269,17 +264,18 @@ class SearchList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSort
colnames = self.first[2:]
rownames = [val[1] for val in datas]
table = [[str(val) for val in line[2:]] for line in datas]
- tmpgraph = tempfile.mktemp(dir=self.parent.parent.TEMPDIR)
- txt = barplot(table, rownames, colnames, self.parent.parent.RscriptsPath['Rgraph'], tmpgraph)
- tmpscript = tempfile.mktemp(dir=self.parent.parent.TEMPDIR)
- with open(tmpscript,'w') as f :
- f.write(txt)
- exec_rcode(self.parent.parent.RPath, tmpscript, wait = True)
- win = MessageImage(self, -1, u"Graphique", size=(700, 500),style = wx.DEFAULT_FRAME_STYLE)
- win.addsaveimage(tmpgraph)
- txt = "" % tmpgraph
- win.HtmlPage.SetPage(txt)
- win.Show(True)
+ BarFrame(self.parent.parent, table, colnames, rownames)
+# tmpgraph = tempfile.mktemp(dir=self.parent.parent.TEMPDIR)
+# txt = barplot(table, rownames, colnames, self.parent.parent.RscriptsPath['Rgraph'], tmpgraph)
+# tmpscript = tempfile.mktemp(dir=self.parent.parent.TEMPDIR)
+# with open(tmpscript,'w') as f :
+# f.write(txt)
+# exec_rcode(self.parent.parent.RPath, tmpscript, wait = True)
+# win = MessageImage(self, u"Graphique", size=(700, 500))
+# win.addsaveimage(tmpgraph)
+# txt = "" % tmpgraph
+# win.HtmlPage.SetPage(txt)
+# win.Show(True)
def ongraphdendro(self, evt) :
corpus = self.parent.corpus
@@ -293,82 +289,14 @@ class SearchList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSort
rownames = [val[1] for val in datas]
table = [[str(val) for val in line[2:]] for line in datas]
tmpgraph = tempfile.mktemp(dir=self.parent.parent.TEMPDIR)
- txt = dendroandbarplot(table, rownames, colnames, self.parent.parent.RscriptsPath['Rgraph'], tmpgraph, dendro=corpus.dictpathout['Rdendro'])
- tmpscript = tempfile.mktemp(dir=self.parent.parent.TEMPDIR)
- with open(tmpscript,'w') as f :
- f.write(txt)
- exec_rcode(self.parent.parent.RPath, tmpscript, wait = True)
- win = MessageImage(self, -1, u"Graphique", size=(700, 500),style = wx.DEFAULT_FRAME_STYLE)
- win.addsaveimage(tmpgraph)
- 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.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)
+ BarFrame(self.parent.parent, table, colnames, rownames, tree = corpus.dictpathout['Rdendro'])
+# txt = dendroandbarplot(table, rownames, colnames, self.parent.parent.RscriptsPath['Rgraph'], tmpgraph, dendro=corpus.dictpathout['Rdendro'])
+# tmpscript = tempfile.mktemp(dir=self.parent.parent.TEMPDIR)
+# with open(tmpscript,'w') as f :
+# f.write(txt)
+# exec_rcode(self.parent.parent.RPath, tmpscript, wait = True)
+# win = MessageImage(self, u"Graphique", size=(700, 500))
+# win.addsaveimage(tmpgraph)
+# txt = "" % tmpgraph
+# win.HtmlPage.SetPage(txt)
+# win.Show(True)