/[cvs]/nfo/projects/netfraggle/bin/FraggleTopicFrame.py
ViewVC logotype

Diff of /nfo/projects/netfraggle/bin/FraggleTopicFrame.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by xabbu, Wed Sep 15 22:31:27 2004 UTC revision 1.10 by xabbu, Tue Sep 21 18:11:05 2004 UTC
# Line 2  Line 2 
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
13    # U function OnUpdateButtonButton items will be added in the correct order now
14    #
15  # Revision 1.7  2004/09/15 22:31:27  xabbu  # Revision 1.7  2004/09/15 22:31:27  xabbu
16  # + in function OnUpdateButtonButton call to fraggleSync replaced with syncTopics  # + in function OnUpdateButtonButton call to fraggleSync replaced with syncTopics
17  # + topics are being recieved from the server now  # + topics are being recieved from the server now
# Line 39  def create(parent): Line 49  def create(parent):
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,
# Line 64  class FraggleTopicFrame(wxMDIChildFrame) Line 73  class FraggleTopicFrame(wxMDIChildFrame)
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
# Line 84  class FraggleTopicFrame(wxMDIChildFrame) Line 95  class FraggleTopicFrame(wxMDIChildFrame)
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[topic], 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
# Line 108  class FraggleTopicFrame(wxMDIChildFrame) Line 162  class FraggleTopicFrame(wxMDIChildFrame)
162          topics = self.engine.getTopics()          topics = self.engine.getTopics()
163          title = topics[str(seldata)]          title = topics[str(seldata)]
164          #print title          #print title
165            print topics
166            
167          frame = FraggleListFrame.create(self.parent)          frame = FraggleListFrame.create(self.parent)
168          frame.SetName(str(seldata))          frame.SetName(str(seldata))
169          frame.SetTitle(title)          frame.SetTitle(title)
# Line 118  class FraggleTopicFrame(wxMDIChildFrame) Line 173  class FraggleTopicFrame(wxMDIChildFrame)
173          frame.Move(pos)          frame.Move(pos)
174          self.parent.Fit()          self.parent.Fit()
175                    
176          frame.load_content()          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                    
           

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.10

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed