/[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.5 by joko, Mon Aug 30 13:06:16 2004 UTC revision 1.9 by xabbu, Fri Sep 17 20:51:24 2004 UTC
# Line 2  Line 2 
2    
3  # $Id$  # $Id$
4  # $Log$  # $Log$
5    # Revision 1.9  2004/09/17 20:51:24  xabbu
6    # + function initTreeList() will init a TreeList
7    # + function loadContent(contentkey) moved from FraggleListFrame
8    #
9    # Revision 1.8  2004/09/17 09:46:30  xabbu
10    # U function OnUpdateButtonButton items will be added in the correct order now
11    #
12    # Revision 1.7  2004/09/15 22:31:27  xabbu
13    # + in function OnUpdateButtonButton call to fraggleSync replaced with syncTopics
14    # + topics are being recieved from the server now
15    #
16    # Revision 1.6  2004/08/31 02:25:34  joko
17    # U removed FraggleTopicDetailFrame in favor of FraggleItemFrame and FraggleListFrame
18    # U now clearing topicListBox before updating it
19    #
20  # Revision 1.5  2004/08/30 13:06:16  joko  # Revision 1.5  2004/08/30 13:06:16  joko
21  # U now gets config via self.engine  # U now gets config via self.engine
22  #  #
# Line 24  Line 39 
39  from wxPython.wx import *  from wxPython.wx import *
40  from wxPython.stc import *  from wxPython.stc import *
41    
42  import FraggleTopicDetailFrame  import FraggleItemFrame
43    import FraggleListFrame
44    
45  def create(parent):  def create(parent):
46      return FraggleTopicFrame(parent)      return FraggleTopicFrame(parent)
47    
48  [wxID_FRAGGLETOPICFRAME, wxID_FRAGGLETOPICFRAMETOPICLISTBOX,  [wxID_FRAGGLETOPICFRAME, wxID_FRAGGLETOPICFRAMETOPICLISTBOX,
49   wxID_FRAGGLETOPICFRAMEUPDATEBUTTON,   wxID_FRAGGLETOPICFRAMETREECTRL1, wxID_FRAGGLETOPICFRAMEUPDATEBUTTON,
50  ] = map(lambda _init_ctrls: wxNewId(), range(3))  ] = map(lambda _init_ctrls: wxNewId(), range(4))
51    
52  class FraggleTopicFrame(wxMDIChildFrame):  class FraggleTopicFrame(wxMDIChildFrame):
53      def _init_ctrls(self, prnt):      def _init_ctrls(self, prnt):
54          # generated method, don't edit          # generated method, don't edit
55          wxMDIChildFrame.__init__(self, id=wxID_FRAGGLETOPICFRAME, name='',          wxMDIChildFrame.__init__(self, id=wxID_FRAGGLETOPICFRAME, name='',
56                parent=prnt, pos=wxPoint(494, 328), size=wxSize(169, 192),                parent=prnt, pos=wxPoint(494, 328), size=wxSize(424, 219),
57                style=wxSIMPLE_BORDER | wxDEFAULT_FRAME_STYLE, title='Topics')                style=wxSIMPLE_BORDER | wxDEFAULT_FRAME_STYLE, title='Topics')
58          self._init_utils()          self.SetClientSize(wxSize(416, 192))
         self.SetClientSize(wxSize(169, 192))  
59    
60          self.updateButton = wxButton(id=wxID_FRAGGLETOPICFRAMEUPDATEBUTTON,          self.updateButton = wxButton(id=wxID_FRAGGLETOPICFRAMEUPDATEBUTTON,
61                label=u'&Update', name=u'updateButton', parent=self,                label=u'&Update', name=u'updateButton', parent=self,
# Line 55  class FraggleTopicFrame(wxMDIChildFrame) Line 70  class FraggleTopicFrame(wxMDIChildFrame)
70                wxID_FRAGGLETOPICFRAMETOPICLISTBOX,                wxID_FRAGGLETOPICFRAMETOPICLISTBOX,
71                self.OnTopicListBoxListboxDclick)                self.OnTopicListBoxListboxDclick)
72    
73      def _init_utils(self):          self.treeCtrl1 = wxTreeCtrl(id=wxID_FRAGGLETOPICFRAMETREECTRL1,
74          # generated method, don't edit                name='treeCtrl1', parent=self, pos=wxPoint(176, 0),
75          pass                size=wxSize(160, 168), style=wxTR_HAS_BUTTONS)
76            self.treeCtrl1.Enable(True)
77    
78      def __init__(self, parent):      def __init__(self, parent):
79          self.parent = parent          self.parent = parent
# Line 71  class FraggleTopicFrame(wxMDIChildFrame) Line 87  class FraggleTopicFrame(wxMDIChildFrame)
87    
88      def OnUpdateButtonButton(self, event):      def OnUpdateButtonButton(self, event):
89          #event.Skip()          #event.Skip()
90          self.engine.fraggleSync()          self.engine.syncTopics()
91          topics = self.engine.getTopics()          topics = self.engine.getTopics()
92            #print topics
93            self.topicListBox.Clear()
94            self.treeCtrl1.Clear()
95          i = 0          i = 0
96          for topic in topics:          for topic in topics:
97              self.topicListBox.Append(topic['name'], i)              self.topicListBox.Append(topics[str(i)], i)
98              i = i + 1              i = i + 1
99            self.initTreeList()
100            
101        def initTreeList(self):
102            topics = self.engine.getTopics()
103            i = 0
104            self.treeItems = {}
105            self.rootItem = self.treeCtrl1.AddRoot('Root')
106            self.treeItems[topics[str(i)]] = {}
107            for topic in topics:
108                self.treeItems[topics[str(i)]] = self.treeCtrl1.AppendItem(self.rootItem, topics[str(i)])
109                self.load_content(topics[str(i)])
110                i = i + 1
111                
112                
113        def load_content(self,contentkey):
114                self.payload = self.engine.listItems(contentkey)
115                self.columns = self.payload['2']
116                topics = self.engine.getTopics()
117                
118                entries = self.payload['1']
119                itemid = 0
120                columnlist = self.columns
121                for entry in entries:
122              
123                    #print columnlist
124                    #columnlist.pop()
125                        if entries[entry]['1'] == '1':
126                         self.treeCtrl1.AppendItem(self.treeItems[contentkey],str(entries[entry]['2']+' - English'))
127                        elif entries[entry]['1'] == '2':
128                         self.treeCtrl1.AppendItem(self.treeItems[contentkey],str(entries[entry]['2']+' - Deutsch'))
129                #print self.treeItems
130                itemid += 1  
131        
132      def OnTopicListBoxListboxDclick(self, event):      def OnTopicListBoxListboxDclick(self, event):
133          #event.Skip()          #event.Skip()
134          #print event          #print event
# Line 95  class FraggleTopicFrame(wxMDIChildFrame) Line 146  class FraggleTopicFrame(wxMDIChildFrame)
146    
147          # resolve associated topic entry          # resolve associated topic entry
148          topics = self.engine.getTopics()          topics = self.engine.getTopics()
149          title = topics[seldata]['name']          title = topics[str(seldata)]
150            #print title
151          frame = FraggleTopicDetailFrame.create(self.parent)          print topics
152            
153            frame = FraggleListFrame.create(self.parent)
154          frame.SetName(str(seldata))          frame.SetName(str(seldata))
155          frame.SetTitle(title)          frame.SetTitle(title)
156                    
# Line 106  class FraggleTopicFrame(wxMDIChildFrame) Line 159  class FraggleTopicFrame(wxMDIChildFrame)
159          frame.Move(pos)          frame.Move(pos)
160          self.parent.Fit()          self.parent.Fit()
161                    
162          frame.load_content()          frame.load_content(topics[str(seldata)])
163            
164                    
           

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.9

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