--- nfo/projects/netfraggle/bin/FraggleTopicFrame.py 2004/08/27 21:14:02 1.4 +++ nfo/projects/netfraggle/bin/FraggleTopicFrame.py 2004/09/21 18:11:05 1.10 @@ -1,7 +1,28 @@ #Boa:MDIChild:FraggleTopicFrame -# $Id: FraggleTopicFrame.py,v 1.4 2004/08/27 21:14:02 xabbu Exp $ +# $Id: FraggleTopicFrame.py,v 1.10 2004/09/21 18:11:05 xabbu Exp $ # $Log: FraggleTopicFrame.py,v $ +# Revision 1.10 2004/09/21 18:11:05 xabbu +# + started work on the final tree Controll to display contenttypes and their items +# +# Revision 1.9 2004/09/17 20:51:24 xabbu +# + function initTreeList() will init a TreeList +# + function loadContent(contentkey) moved from FraggleListFrame +# +# Revision 1.8 2004/09/17 09:46:30 xabbu +# U function OnUpdateButtonButton items will be added in the correct order now +# +# Revision 1.7 2004/09/15 22:31:27 xabbu +# + in function OnUpdateButtonButton call to fraggleSync replaced with syncTopics +# + topics are being recieved from the server now +# +# Revision 1.6 2004/08/31 02:25:34 joko +# U removed FraggleTopicDetailFrame in favor of FraggleItemFrame and FraggleListFrame +# U now clearing topicListBox before updating it +# +# Revision 1.5 2004/08/30 13:06:16 joko +# U now gets config via self.engine +# # Revision 1.4 2004/08/27 21:14:02 xabbu # TopicDetails can now be closed. # GUI change on Preferences Dialog in order to prepare multiple server profiles. @@ -21,23 +42,23 @@ from wxPython.wx import * from wxPython.stc import * -import FraggleTopicDetailFrame +import FraggleItemFrame +import FraggleListFrame -def create(parent, config): - return FraggleTopicFrame(parent, config) +def create(parent): + return FraggleTopicFrame(parent) [wxID_FRAGGLETOPICFRAME, wxID_FRAGGLETOPICFRAMETOPICLISTBOX, - wxID_FRAGGLETOPICFRAMEUPDATEBUTTON, -] = map(lambda _init_ctrls: wxNewId(), range(3)) + wxID_FRAGGLETOPICFRAMETREECTRL1, wxID_FRAGGLETOPICFRAMEUPDATEBUTTON, +] = map(lambda _init_ctrls: wxNewId(), range(4)) class FraggleTopicFrame(wxMDIChildFrame): def _init_ctrls(self, prnt): # generated method, don't edit wxMDIChildFrame.__init__(self, id=wxID_FRAGGLETOPICFRAME, name='', - parent=prnt, pos=wxPoint(494, 328), size=wxSize(169, 192), + parent=prnt, pos=wxPoint(494, 328), size=wxSize(424, 219), style=wxSIMPLE_BORDER | wxDEFAULT_FRAME_STYLE, title='Topics') - self._init_utils() - self.SetClientSize(wxSize(169, 192)) + self.SetClientSize(wxSize(416, 192)) self.updateButton = wxButton(id=wxID_FRAGGLETOPICFRAMEUPDATEBUTTON, label=u'&Update', name=u'updateButton', parent=self, @@ -52,27 +73,76 @@ wxID_FRAGGLETOPICFRAMETOPICLISTBOX, self.OnTopicListBoxListboxDclick) - def _init_utils(self): - # generated method, don't edit - pass + self.treeCtrl1 = wxTreeCtrl(id=wxID_FRAGGLETOPICFRAMETREECTRL1, + name='treeCtrl1', parent=self, pos=wxPoint(176, 0), + size=wxSize(160, 168), style=wxTR_HAS_BUTTONS) + self.treeCtrl1.Enable(True) + EVT_LEFT_DCLICK(self.treeCtrl1, self.OnTreeCtrl1LeftDclick) - def __init__(self, parent, config): + def __init__(self, parent): self.parent = parent - self.config = config + + # render widgets self._init_ctrls(parent) + + # get engine-instance (singleton) import __main__ self.engine = __main__.engine def OnUpdateButtonButton(self, event): #event.Skip() - # todo: make fraggleEngine read config on its own - self.engine.fraggleSync(self.config) + self.engine.syncTopics() topics = self.engine.getTopics() + #print topics + self.topicListBox.Clear() + self.treeCtrl1.Clear() i = 0 for topic in topics: - self.topicListBox.Append(topic['name'], i) + self.topicListBox.Append(topics[str(i)], i) i = i + 1 - + self.initTreeList() + + def initTreeList(self): + topics = self.engine.getTopics() + i = 0 + self.treeItems = {} + self.rootItem = self.treeCtrl1.AddRoot('Root') + self.treeItems[topics[str(i)]] = {} + for topic in topics: + self.treeItems[topics[str(i)]] = self.treeCtrl1.AppendItem(self.rootItem, topics[str(i)]) + self.load_content(topics[str(i)]) + i = i + 1 + + + def load_content(self,contentkey): + self.payload = self.engine.listItems(contentkey) + self.columns = self.payload['2'] + topics = self.engine.getTopics() + + entries = self.payload['1'] + itemid = 0 + columnlist = self.columns + for entry in entries: + data = entries[entry] + itemData = wxTreeItemData() + itemData.SetData(data) + #print columnlist + #columnlist.pop() + if entries[entry]['1'] == '1': + self.treeCtrl1.AppendItem(self.treeItems[contentkey], + str(entries[entry]['2']+' - English'), + -1, + -1, + itemData) + elif entries[entry]['1'] == '2': + self.treeCtrl1.AppendItem(self.treeItems[contentkey], + str(entries[entry]['2']+' - Deutsch'), + -1, + -1, + itemData) + #print self.treeItems + itemid += 1 + def OnTopicListBoxListboxDclick(self, event): #event.Skip() #print event @@ -90,9 +160,11 @@ # resolve associated topic entry topics = self.engine.getTopics() - title = topics[seldata]['name'] - - frame = FraggleTopicDetailFrame.create(self.parent) + title = topics[str(seldata)] + #print title + print topics + + frame = FraggleListFrame.create(self.parent) frame.SetName(str(seldata)) frame.SetTitle(title) @@ -101,5 +173,15 @@ frame.Move(pos) self.parent.Fit() + frame.load_content(topics[str(seldata)]) + + def OnTreeCtrl1LeftDclick(self, event): + sel = self.treeCtrl1.GetSelection() + selitem = self.treeCtrl1.GetItemData(sel) + seldata = selitem.GetData() + selparent = self.treeCtrl1.GetItemParent(sel) + seltype = self.treeCtrl1.GetItemText(selparent) + self.engine.modules.Dispatch(seldata,seltype) + event.Skip() + - \ No newline at end of file