/[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.4 by xabbu, Fri Aug 27 21:14:02 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
16    # + in function OnUpdateButtonButton call to fraggleSync replaced with syncTopics
17    # + topics are being recieved from the server now
18    #
19    # Revision 1.6  2004/08/31 02:25:34  joko
20    # U removed FraggleTopicDetailFrame in favor of FraggleItemFrame and FraggleListFrame
21    # U now clearing topicListBox before updating it
22    #
23    # Revision 1.5  2004/08/30 13:06:16  joko
24    # U now gets config via self.engine
25    #
26  # Revision 1.4  2004/08/27 21:14:02  xabbu  # Revision 1.4  2004/08/27 21:14:02  xabbu
27  # TopicDetails can now be closed.  # TopicDetails can now be closed.
28  # GUI change on Preferences Dialog in order to prepare multiple server profiles.  # GUI change on Preferences Dialog in order to prepare multiple server profiles.
# Line 21  Line 42 
42  from wxPython.wx import *  from wxPython.wx import *
43  from wxPython.stc import *  from wxPython.stc import *
44    
45  import FraggleTopicDetailFrame  import FraggleItemFrame
46    import FraggleListFrame
47    
48  def create(parent, config):  def create(parent):
49      return FraggleTopicFrame(parent, config)      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 52  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, config):      def __init__(self, parent):
83          self.parent = parent          self.parent = parent
84          self.config = config  
85            # render widgets
86          self._init_ctrls(parent)          self._init_ctrls(parent)
87    
88            # get engine-instance (singleton)
89          import __main__          import __main__
90          self.engine = __main__.engine          self.engine = __main__.engine
91    
92      def OnUpdateButtonButton(self, event):      def OnUpdateButtonButton(self, event):
93          #event.Skip()          #event.Skip()
94          # todo: make fraggleEngine read config on its own          self.engine.syncTopics()
         self.engine.fraggleSync(self.config)  
95          topics = self.engine.getTopics()          topics = self.engine.getTopics()
96            #print topics
97            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(topic['name'], 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 90  class FraggleTopicFrame(wxMDIChildFrame) Line 160  class FraggleTopicFrame(wxMDIChildFrame)
160    
161          # resolve associated topic entry          # resolve associated topic entry
162          topics = self.engine.getTopics()          topics = self.engine.getTopics()
163          title = topics[seldata]['name']          title = topics[str(seldata)]
164            #print title
165          frame = FraggleTopicDetailFrame.create(self.parent)          print topics
166            
167            frame = FraggleListFrame.create(self.parent)
168          frame.SetName(str(seldata))          frame.SetName(str(seldata))
169          frame.SetTitle(title)          frame.SetTitle(title)
170                    
# Line 101  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(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.4  
changed lines
  Added in v.1.10

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