/[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.2 by joko, Fri Aug 27 03:13:50 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
21    # U now gets config via self.engine
22    #
23    # Revision 1.4  2004/08/27 21:14:02  xabbu
24    # TopicDetails can now be closed.
25    # GUI change on Preferences Dialog in order to prepare multiple server profiles.
26    # Small bugfixes to get the new topic windows working on posix platform.
27    #
28    # Revision 1.3  2004/08/27 04:47:35  joko
29    # instance of FraggleEngine now available in self.engine
30    # added event handler "OnTopicListBoxListboxDclick" and logic to open "FraggleTopicDetailFrame"s
31    #
32  # Revision 1.2  2004/08/27 03:13:50  joko  # Revision 1.2  2004/08/27 03:13:50  joko
33  # added listbox for topics and button for update/sync  # added listbox for topics and button for update/sync
34  #  #
# Line 12  Line 39 
39  from wxPython.wx import *  from wxPython.wx import *
40  from wxPython.stc import *  from wxPython.stc import *
41    
42  def create(parent, config):  import FraggleItemFrame
43      return FraggleTopicFrame(parent, config)  import FraggleListFrame
44    
45    def create(parent):
46        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(352, 280), size=wxSize(177, 219),                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.SetClientSize(wxSize(169, 192))          self.SetClientSize(wxSize(416, 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 36  class FraggleTopicFrame(wxMDIChildFrame) Line 66  class FraggleTopicFrame(wxMDIChildFrame)
66          self.topicListBox = wxListBox(choices=[],          self.topicListBox = wxListBox(choices=[],
67                id=wxID_FRAGGLETOPICFRAMETOPICLISTBOX, name=u'topicListBox',                id=wxID_FRAGGLETOPICFRAMETOPICLISTBOX, name=u'topicListBox',
68                parent=self, pos=wxPoint(0, 0), size=wxSize(168, 168), style=0)                parent=self, pos=wxPoint(0, 0), size=wxSize(168, 168), style=0)
69            EVT_LISTBOX_DCLICK(self.topicListBox,
70                  wxID_FRAGGLETOPICFRAMETOPICLISTBOX,
71                  self.OnTopicListBoxListboxDclick)
72    
73            self.treeCtrl1 = wxTreeCtrl(id=wxID_FRAGGLETOPICFRAMETREECTRL1,
74                  name='treeCtrl1', parent=self, pos=wxPoint(176, 0),
75                  size=wxSize(160, 168), style=wxTR_HAS_BUTTONS)
76            self.treeCtrl1.Enable(True)
77    
78      def __init__(self, parent, config):      def __init__(self, parent):
79          self.config = config          self.parent = parent
80    
81            # render widgets
82          self._init_ctrls(parent)          self._init_ctrls(parent)
83    
84            # get engine-instance (singleton)
85            import __main__
86            self.engine = __main__.engine
87    
88      def OnUpdateButtonButton(self, event):      def OnUpdateButtonButton(self, event):
89          #event.Skip()          #event.Skip()
90          import __main__          self.engine.syncTopics()
91          engine = __main__.engine          topics = self.engine.getTopics()
92          # todo: make fraggleEngine read config on its own          #print topics
93          engine.fraggleSync(self.config)          self.topicListBox.Clear()
94          topics = engine.getTopics()          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):
133            #event.Skip()
134            #print event
135            
136            # get "ClientData" of current selected entry from widget
137            sel = self.topicListBox.GetSelection()
138            seldata = self.topicListBox.GetClientData(sel)
139            
140            # determine if to activate an existing window or if to create a new one
141            win = self.parent.FindWindowByName(str(seldata))
142            if win:
143                win.Raise()
144                win.SetFocus()
145                return
146    
147            # resolve associated topic entry
148            topics = self.engine.getTopics()
149            title = topics[str(seldata)]
150            #print title
151            print topics
152            
153            frame = FraggleListFrame.create(self.parent)
154            frame.SetName(str(seldata))
155            frame.SetTitle(title)
156            
157            # calculate new position (right beside the TopicFrame (us))
158            pos = self.GetPosition() + wxPoint(self.GetSize().GetWidth() + 5, 0)
159            frame.Move(pos)
160            self.parent.Fit()
161            
162            frame.load_content(topics[str(seldata)])
163            
164            

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

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