| 2 |
|
|
| 3 |
# $Id$ |
# $Id$ |
| 4 |
# $Log$ |
# $Log$ |
| 5 |
|
# Revision 1.10 2004/09/21 18:11:05 xabbu |
| 6 |
|
# + started work on the final tree Controll to display contenttypes and their items |
| 7 |
|
# |
| 8 |
|
# Revision 1.9 2004/09/17 20:51:24 xabbu |
| 9 |
|
# + function initTreeList() will init a TreeList |
| 10 |
|
# + function loadContent(contentkey) moved from FraggleListFrame |
| 11 |
|
# |
| 12 |
# Revision 1.8 2004/09/17 09:46:30 xabbu |
# Revision 1.8 2004/09/17 09:46:30 xabbu |
| 13 |
# U function OnUpdateButtonButton items will be added in the correct order now |
# U function OnUpdateButtonButton items will be added in the correct order now |
| 14 |
# |
# |
| 49 |
return FraggleTopicFrame(parent) |
return FraggleTopicFrame(parent) |
| 50 |
|
|
| 51 |
[wxID_FRAGGLETOPICFRAME, wxID_FRAGGLETOPICFRAMETOPICLISTBOX, |
[wxID_FRAGGLETOPICFRAME, wxID_FRAGGLETOPICFRAMETOPICLISTBOX, |
| 52 |
wxID_FRAGGLETOPICFRAMEUPDATEBUTTON, |
wxID_FRAGGLETOPICFRAMETREECTRL1, wxID_FRAGGLETOPICFRAMEUPDATEBUTTON, |
| 53 |
] = map(lambda _init_ctrls: wxNewId(), range(3)) |
] = map(lambda _init_ctrls: wxNewId(), range(4)) |
| 54 |
|
|
| 55 |
class FraggleTopicFrame(wxMDIChildFrame): |
class FraggleTopicFrame(wxMDIChildFrame): |
| 56 |
def _init_ctrls(self, prnt): |
def _init_ctrls(self, prnt): |
| 57 |
# generated method, don't edit |
# generated method, don't edit |
| 58 |
wxMDIChildFrame.__init__(self, id=wxID_FRAGGLETOPICFRAME, name='', |
wxMDIChildFrame.__init__(self, id=wxID_FRAGGLETOPICFRAME, name='', |
| 59 |
parent=prnt, pos=wxPoint(494, 328), size=wxSize(169, 192), |
parent=prnt, pos=wxPoint(494, 328), size=wxSize(424, 219), |
| 60 |
style=wxSIMPLE_BORDER | wxDEFAULT_FRAME_STYLE, title='Topics') |
style=wxSIMPLE_BORDER | wxDEFAULT_FRAME_STYLE, title='Topics') |
| 61 |
self._init_utils() |
self.SetClientSize(wxSize(416, 192)) |
|
self.SetClientSize(wxSize(169, 192)) |
|
| 62 |
|
|
| 63 |
self.updateButton = wxButton(id=wxID_FRAGGLETOPICFRAMEUPDATEBUTTON, |
self.updateButton = wxButton(id=wxID_FRAGGLETOPICFRAMEUPDATEBUTTON, |
| 64 |
label=u'&Update', name=u'updateButton', parent=self, |
label=u'&Update', name=u'updateButton', parent=self, |
| 73 |
wxID_FRAGGLETOPICFRAMETOPICLISTBOX, |
wxID_FRAGGLETOPICFRAMETOPICLISTBOX, |
| 74 |
self.OnTopicListBoxListboxDclick) |
self.OnTopicListBoxListboxDclick) |
| 75 |
|
|
| 76 |
def _init_utils(self): |
self.treeCtrl1 = wxTreeCtrl(id=wxID_FRAGGLETOPICFRAMETREECTRL1, |
| 77 |
# generated method, don't edit |
name='treeCtrl1', parent=self, pos=wxPoint(176, 0), |
| 78 |
pass |
size=wxSize(160, 168), style=wxTR_HAS_BUTTONS) |
| 79 |
|
self.treeCtrl1.Enable(True) |
| 80 |
|
EVT_LEFT_DCLICK(self.treeCtrl1, self.OnTreeCtrl1LeftDclick) |
| 81 |
|
|
| 82 |
def __init__(self, parent): |
def __init__(self, parent): |
| 83 |
self.parent = parent |
self.parent = parent |
| 95 |
topics = self.engine.getTopics() |
topics = self.engine.getTopics() |
| 96 |
#print topics |
#print topics |
| 97 |
self.topicListBox.Clear() |
self.topicListBox.Clear() |
| 98 |
|
self.treeCtrl1.Clear() |
| 99 |
i = 0 |
i = 0 |
| 100 |
for topic in topics: |
for topic in topics: |
| 101 |
self.topicListBox.Append(topics[str(i)], i) |
self.topicListBox.Append(topics[str(i)], i) |
| 102 |
i = i + 1 |
i = i + 1 |
| 103 |
|
self.initTreeList() |
| 104 |
|
|
| 105 |
|
def initTreeList(self): |
| 106 |
|
topics = self.engine.getTopics() |
| 107 |
|
i = 0 |
| 108 |
|
self.treeItems = {} |
| 109 |
|
self.rootItem = self.treeCtrl1.AddRoot('Root') |
| 110 |
|
self.treeItems[topics[str(i)]] = {} |
| 111 |
|
for topic in topics: |
| 112 |
|
self.treeItems[topics[str(i)]] = self.treeCtrl1.AppendItem(self.rootItem, topics[str(i)]) |
| 113 |
|
self.load_content(topics[str(i)]) |
| 114 |
|
i = i + 1 |
| 115 |
|
|
| 116 |
|
|
| 117 |
|
def load_content(self,contentkey): |
| 118 |
|
self.payload = self.engine.listItems(contentkey) |
| 119 |
|
self.columns = self.payload['2'] |
| 120 |
|
topics = self.engine.getTopics() |
| 121 |
|
|
| 122 |
|
entries = self.payload['1'] |
| 123 |
|
itemid = 0 |
| 124 |
|
columnlist = self.columns |
| 125 |
|
for entry in entries: |
| 126 |
|
data = entries[entry] |
| 127 |
|
itemData = wxTreeItemData() |
| 128 |
|
itemData.SetData(data) |
| 129 |
|
#print columnlist |
| 130 |
|
#columnlist.pop() |
| 131 |
|
if entries[entry]['1'] == '1': |
| 132 |
|
self.treeCtrl1.AppendItem(self.treeItems[contentkey], |
| 133 |
|
str(entries[entry]['2']+' - English'), |
| 134 |
|
-1, |
| 135 |
|
-1, |
| 136 |
|
itemData) |
| 137 |
|
elif entries[entry]['1'] == '2': |
| 138 |
|
self.treeCtrl1.AppendItem(self.treeItems[contentkey], |
| 139 |
|
str(entries[entry]['2']+' - Deutsch'), |
| 140 |
|
-1, |
| 141 |
|
-1, |
| 142 |
|
itemData) |
| 143 |
|
#print self.treeItems |
| 144 |
|
itemid += 1 |
| 145 |
|
|
| 146 |
def OnTopicListBoxListboxDclick(self, event): |
def OnTopicListBoxListboxDclick(self, event): |
| 147 |
#event.Skip() |
#event.Skip() |
| 148 |
#print event |
#print event |
| 174 |
self.parent.Fit() |
self.parent.Fit() |
| 175 |
|
|
| 176 |
frame.load_content(topics[str(seldata)]) |
frame.load_content(topics[str(seldata)]) |
| 177 |
|
|
| 178 |
|
def OnTreeCtrl1LeftDclick(self, event): |
| 179 |
|
sel = self.treeCtrl1.GetSelection() |
| 180 |
|
selitem = self.treeCtrl1.GetItemData(sel) |
| 181 |
|
seldata = selitem.GetData() |
| 182 |
|
selparent = self.treeCtrl1.GetItemParent(sel) |
| 183 |
|
seltype = self.treeCtrl1.GetItemText(selparent) |
| 184 |
|
self.engine.modules.Dispatch(seldata,seltype) |
| 185 |
|
event.Skip() |
| 186 |
|
|
| 187 |
|
|
|
|
|