# listmix.ListCtrlAutoWidthMixin.__init__(self)
class ListForSpec(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
- def __init__(self, parent,gparent, dlist,first):
+ 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)
self.parent=parent
self.gparent=gparent
self.dlist=dlist
self.first = first
+ self.menu = menu
search_id = wx.NewId()
self.parent.Bind(wx.EVT_MENU, self.onsearch, id = search_id)
self.SetColumnWidth(0, 180)
for i in range(1,len(first)-1):
- self.SetColumnWidth(i, len(first[i]) * 10)
+ self.SetColumnWidth(i, self.checkcolumnwidth(len(first[i]) * 10))
self.itemDataMap = dlist
self.itemIndexMap = dlist.keys()
#-----------------------------------------------------------------------------------------
+ def checkcolumnwidth(self, width) :
+ if width < 80 :
+ return 80
+ else :
+ return width
+
def OnGetItemText(self, item, col):
index=self.itemIndexMap[item]
s = self.itemDataMap[index][col]
self.dial.Destroy()
def OnRightClick(self, event):
-
- # only do this part the first time so the events are only bound once
- if not hasattr(self, "popupID1"):
- self.popupID1 = wx.NewId()
- self.popupID2 = wx.NewId()
- self.popupID3 = wx.NewId()
- self.popup_Tgen_glob = wx.NewId()
-
- self.Bind(wx.EVT_MENU, self.OnPopupOne, id=self.popupID1)
- self.Bind(wx.EVT_MENU, self.OnPopupTwo, id=self.popupID2)
- self.Bind(wx.EVT_MENU, self.OnPopupThree, id=self.popupID3)
- self.Bind(wx.EVT_MENU, self.OnTgen_glob, id=self.popup_Tgen_glob)
- # 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.popupID3, "Graphique")
- #menu.Append(self.popup_Tgen_glob, "Tgen global")
-
- self.PopupMenu(menu)
- menu.Destroy()
+ if self.menu :
+ # only do this part the first time so the events are only bound once
+ if not hasattr(self, "popupID1"):
+ self.popupID1 = wx.NewId()
+ self.popupID2 = wx.NewId()
+ self.popupID3 = wx.NewId()
+ self.popup_Tgen_glob = wx.NewId()
+
+ self.Bind(wx.EVT_MENU, self.OnPopupOne, id=self.popupID1)
+ self.Bind(wx.EVT_MENU, self.OnPopupTwo, id=self.popupID2)
+ self.Bind(wx.EVT_MENU, self.OnPopupThree, id=self.popupID3)
+ self.Bind(wx.EVT_MENU, self.OnTgen_glob, id=self.popup_Tgen_glob)
+ # 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.popupID3, "Graphique")
+ #menu.Append(self.popup_Tgen_glob, "Tgen global")
+
+ self.PopupMenu(menu)
+ menu.Destroy()
def getselectedwords(self) :
- words = [self.getColumnText(self.GetFirstSelected(), 6)]
+ words = [self.getColumnText(self.GetFirstSelected(), 0)]
last = self.GetFirstSelected()
while self.GetNextSelected(last) != -1:
last = self.GetNextSelected(last)
win.HtmlPage.SetPage(txt)
win.Show(True)
+ def getinf(self, txt) :
+ if txt == float('Inf') :
+ return 'Inf'
+ elif txt == float('-Inf') :
+ return '-Inf'
+ else :
+ return `txt`
+
def OnPopupThree(self, event) :
- print self.GetFirstSelected()
datas = [self.GetItemData(self.GetFirstSelected())]
- print datas
last = self.GetFirstSelected()
while self.GetNextSelected(last) != -1:
last = self.GetNextSelected(last)
data = self.GetItemData(last)
datas += [data]
colnames = self.first[1:]
- table = [[str(val) for val in line[1:]] for line in datas]
+ table = [[self.getinf(val) for val in line[1:]] for line in datas]
rownames = [val[0] for val in datas]
tmpgraph = tempfile.mktemp(dir=self.parent.TEMPDIR)
-
txt = barplot(table, rownames, colnames, self.parent.RscriptsPath['Rgraph'], tmpgraph)
-
tmpscript = tempfile.mktemp(dir=self.parent.TEMPDIR)
- file = open(tmpscript,'w')
- file.write(txt)
- file.close()
+ with open(tmpscript,'w') as f :
+ f.write(txt)
exec_rcode(self.parent.RPath, tmpscript, wait = True)
- win = MessageImage(self, -1, u"Graphique", size=(700, 500),style = wx.DEFAULT_FRAME_STYLE)
+ win = MessageImage(self, u"Graphique", size=(700, 500))
win.addsaveimage(tmpgraph)
txt = "<img src='%s'>" % tmpgraph
win.HtmlPage.SetPage(txt)