def save(self) :
with open(self.pathout['cate.json'], 'w', encoding='utf8') as f :
f.write(json.dumps(self.cate, indent=4))
- print("json saved!")
def exportdict(self):
pass
del(self.cate['TOCATE'][word])
def addwordinwords(self, categorie, word, eff) :
- print(categorie, word, eff)
self.cate['TOCATE'][word] = eff
self.cate['CATE'][categorie][0] -= eff
del(self.cate['CATE'][categorie][1][word])
def loadcate(self, infile) :
if self.cate['CATE'] != {} :
- print("Categories should be empty")
return False
with open(infile, 'r', encoding='utf8') as f :
newcate = json.load(f)
#sizer.Add(splitter, 1, wx.EXPAND)
#self.SetSizer(sizer)
W,H = wx.GetTopLevelParent(self).GetSize()
- print(W)
W = W - 200
if W < 300 :
W = 300
newtab.append(newline)
def OnAddCate(self, evt) :
- print('add a category')
- print(self.m_listCate.GetItemCount())
self.cate.addcatefromscratch()
self.m_listCate.dlist = self.cate.getcate()
self.m_listCate.RefreshData(self.m_listCate.dlist)
s="self.%s= self.il.Add(wx.ArtProvider.GetBitmap(wx.ART_%s,wx.ART_TOOLBAR,(20,20)))" % (k,v)
exec(s)
self.SetImageList(self.il, wx.IMAGE_LIST_SMALL)
- self.attr1 = wx.ListItemAttr()
+ self.attr1 = wx.ItemAttr()
self.attr1.SetBackgroundColour((230, 230, 230))
- self.attr2 = wx.ListItemAttr()
+ self.attr2 = wx.ItemAttr()
self.attr2.SetBackgroundColour("light blue")
#self.attrselected = wx.ListItemAttr()
#self.attrselected.SetBackgroundColour("red")
self.SetDropTarget(dt)
def OnSortColumn(self, evt) :
- print(self.currentItem)
+ #print(self.currentItem)
evt.Skip()
def SetListFont(self) :
try :
select = self.currentItem
word = self.GetItemData(select)[0]
- except Exception as e: print('word',e)
+ except:
+ print("no item selected")
+ #Exception as e: print('execption SortItems ListForCate :',e)
listTemp = sorted(self.itemDataMap.items(),
key=lambda x:x[1][self._col], reverse= (self._colSortFlag[self._col]!=True))
idx = [i for i, val in enumerate(formes) if val == word][0]
self.SetSelection(idx)
self.Focus(idx)
- except Exception as e: print(e)
+ except Exception as e: print('execption SortItems2 : ',e)
def OnGetItemText(self, item, col):
index=self.itemIndexMap[item]
return self.getselectedwords()
def getColumnText(self, index, col):
- item = self.GetItem(index, col)
- return item.GetText()
+ try:
+ item = self.GetItem(index, col)
+ return item.GetText()
+ except:
+ message = wx.MessageDialog(self, _("You have to select a category first"), _("Information"), wx.OK|wx.ICON_INFORMATION)
+ message.ShowModal()
+ message.Destroy()
def GetItemData(self, item) :
index=self.itemIndexMap[item]
word, eff = val[1]
if word not in self.cate.cate['CATE'][self.GetItemData(index)[0]][1] :
self.cate.changewordcate(self.GetItemData(index)[0], word, eff)
- self.parent.butsave.SetbackgroundColour((255,0,0,255))
+ self.parent.butsave.SetBackgroundColour((255,0,0,255))
self.parent.Refresh()
else :
index = self.GetItemCount()
s="self.%s= self.il.Add(wx.ArtProvider.GetBitmap(wx.ART_%s,wx.ART_TOOLBAR,(16,16)))" % (k,v)
exec(s)
self.SetImageList(self.il, wx.IMAGE_LIST_SMALL)
- self.attr1 = wx.ListItemAttr()
+ self.attr1 = wx.ItemAttr()
self.attr1.SetBackgroundColour((230, 230, 230))
- self.attr2 = wx.ListItemAttr()
+ self.attr2 = wx.ItemAttr()
self.attr2.SetBackgroundColour("light blue")
#self.attrselected = wx.ListItemAttr()
#self.attrselected.SetBackgroundColour("red")
l.reverse() # Delete all the items, starting with the last item.
for i in l:
pos = self.FindItem(i[0], i[2])
- print('detruit : ',pos)
+ #print('detruit : ',pos)
self.DeleteItem(pos)
s="self.%s= self.il.Add(wx.ArtProvider.GetBitmap(wx.ART_%s,wx.ART_TOOLBAR,(16,16)))" % (k,v)
exec(s)
self.SetImageList(self.il, wx.IMAGE_LIST_SMALL)
- self.attr1 = wx.ListItemAttr()
+ self.attr1 = wx.ItemAttr()
self.attr1.SetBackgroundColour((230, 230, 230))
- self.attr2 = wx.ListItemAttr()
+ self.attr2 = wx.ItemAttr()
self.attr2.SetBackgroundColour("light blue")
#self.attrselected = wx.ListItemAttr()
#self.attrselected.SetBackgroundColour("red")
dropSource = wx.DropSource(self)
dropSource.SetData(data)
res = dropSource.DoDragDrop(flags=wx.Drag_DefaultMove)
- print('current')
- print(self.parent.m_listCate.currentItem)
+ #print('current')
+ #print(self.parent.m_listCate.currentItem)
# If move, we want to remove the item from this list.
#if res == wx.DragMove:
# # Correct for the fact that there may be a heading involved.
# if y > rect.y - self.GetItemRect(0).y + rect.height/2:
# index += 1
- print('Insert de ListForCateWords', index,flags)
- if seq[0][-1] == 'words' :
- for val in seq :
- word, eff = val[1]
- categorie = self.parent.m_listCate.getColumnText(self.parent.m_listCate.GetFirstSelected(),0)
- self.cate.addwordincate(categorie, word, eff)
- self.dlist = self.cate.getwordstocate()
- self.RefreshData(self.cate.getcatewords(categorie))
- self.parent.m_listCate.RefreshData(self.cate.getcate())
- self.parent.m_listToCate.RefreshData(self.dlist)
- self.parent.butsave.SetBackgroundColour((255,0,0,255))
- self.parent.Refresh()
+ #print('Insert de ListForCateWords', index,flags)
+
+ categorie = self.parent.m_listCate.getColumnText(self.parent.m_listCate.GetFirstSelected(),0)
+ if categorie is not None :
+ if seq[0][-1] == 'words' :
+ for val in seq :
+ word, eff = val[1]
+ self.cate.addwordincate(categorie, word, eff)
+ self.dlist = self.cate.getwordstocate()
+ self.RefreshData(self.cate.getcatewords(categorie))
+ self.parent.m_listCate.RefreshData(self.cate.getcate())
+ self.parent.m_listToCate.RefreshData(self.dlist)
+ self.parent.butsave.SetBackgroundColour((255,0,0,255))
+ self.parent.Refresh()