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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations)
Fri Sep 17 20:51:24 2004 UTC (19 years, 9 months ago) by xabbu
Branch: MAIN
Changes since 1.8: +47 -11 lines
File MIME type: text/x-python
+ function initTreeList() will init a TreeList
+ function loadContent(contentkey) moved from FraggleListFrame

1 #Boa:MDIChild:FraggleTopicFrame
2
3 # $Id: FraggleTopicFrame.py,v 1.8 2004/09/17 09:46:30 xabbu Exp $
4 # $Log: FraggleTopicFrame.py,v $
5 # Revision 1.8 2004/09/17 09:46:30 xabbu
6 # U function OnUpdateButtonButton items will be added in the correct order now
7 #
8 # Revision 1.7 2004/09/15 22:31:27 xabbu
9 # + in function OnUpdateButtonButton call to fraggleSync replaced with syncTopics
10 # + topics are being recieved from the server now
11 #
12 # Revision 1.6 2004/08/31 02:25:34 joko
13 # U removed FraggleTopicDetailFrame in favor of FraggleItemFrame and FraggleListFrame
14 # U now clearing topicListBox before updating it
15 #
16 # Revision 1.5 2004/08/30 13:06:16 joko
17 # U now gets config via self.engine
18 #
19 # Revision 1.4 2004/08/27 21:14:02 xabbu
20 # TopicDetails can now be closed.
21 # GUI change on Preferences Dialog in order to prepare multiple server profiles.
22 # Small bugfixes to get the new topic windows working on posix platform.
23 #
24 # Revision 1.3 2004/08/27 04:47:35 joko
25 # instance of FraggleEngine now available in self.engine
26 # added event handler "OnTopicListBoxListboxDclick" and logic to open "FraggleTopicDetailFrame"s
27 #
28 # Revision 1.2 2004/08/27 03:13:50 joko
29 # added listbox for topics and button for update/sync
30 #
31 # Revision 1.1 2004/08/26 17:23:30 joko
32 # initial commit
33 #
34
35 from wxPython.wx import *
36 from wxPython.stc import *
37
38 import FraggleItemFrame
39 import FraggleListFrame
40
41 def create(parent):
42 return FraggleTopicFrame(parent)
43
44 [wxID_FRAGGLETOPICFRAME, wxID_FRAGGLETOPICFRAMETOPICLISTBOX,
45 wxID_FRAGGLETOPICFRAMETREECTRL1, wxID_FRAGGLETOPICFRAMEUPDATEBUTTON,
46 ] = map(lambda _init_ctrls: wxNewId(), range(4))
47
48 class FraggleTopicFrame(wxMDIChildFrame):
49 def _init_ctrls(self, prnt):
50 # generated method, don't edit
51 wxMDIChildFrame.__init__(self, id=wxID_FRAGGLETOPICFRAME, name='',
52 parent=prnt, pos=wxPoint(494, 328), size=wxSize(424, 219),
53 style=wxSIMPLE_BORDER | wxDEFAULT_FRAME_STYLE, title='Topics')
54 self.SetClientSize(wxSize(416, 192))
55
56 self.updateButton = wxButton(id=wxID_FRAGGLETOPICFRAMEUPDATEBUTTON,
57 label=u'&Update', name=u'updateButton', parent=self,
58 pos=wxPoint(0, 168), size=wxSize(168, 23), style=0)
59 EVT_BUTTON(self.updateButton, wxID_FRAGGLETOPICFRAMEUPDATEBUTTON,
60 self.OnUpdateButtonButton)
61
62 self.topicListBox = wxListBox(choices=[],
63 id=wxID_FRAGGLETOPICFRAMETOPICLISTBOX, name=u'topicListBox',
64 parent=self, pos=wxPoint(0, 0), size=wxSize(168, 168), style=0)
65 EVT_LISTBOX_DCLICK(self.topicListBox,
66 wxID_FRAGGLETOPICFRAMETOPICLISTBOX,
67 self.OnTopicListBoxListboxDclick)
68
69 self.treeCtrl1 = wxTreeCtrl(id=wxID_FRAGGLETOPICFRAMETREECTRL1,
70 name='treeCtrl1', parent=self, pos=wxPoint(176, 0),
71 size=wxSize(160, 168), style=wxTR_HAS_BUTTONS)
72 self.treeCtrl1.Enable(True)
73
74 def __init__(self, parent):
75 self.parent = parent
76
77 # render widgets
78 self._init_ctrls(parent)
79
80 # get engine-instance (singleton)
81 import __main__
82 self.engine = __main__.engine
83
84 def OnUpdateButtonButton(self, event):
85 #event.Skip()
86 self.engine.syncTopics()
87 topics = self.engine.getTopics()
88 #print topics
89 self.topicListBox.Clear()
90 self.treeCtrl1.Clear()
91 i = 0
92 for topic in topics:
93 self.topicListBox.Append(topics[str(i)], i)
94 i = i + 1
95 self.initTreeList()
96
97 def initTreeList(self):
98 topics = self.engine.getTopics()
99 i = 0
100 self.treeItems = {}
101 self.rootItem = self.treeCtrl1.AddRoot('Root')
102 self.treeItems[topics[str(i)]] = {}
103 for topic in topics:
104 self.treeItems[topics[str(i)]] = self.treeCtrl1.AppendItem(self.rootItem, topics[str(i)])
105 self.load_content(topics[str(i)])
106 i = i + 1
107
108
109 def load_content(self,contentkey):
110 self.payload = self.engine.listItems(contentkey)
111 self.columns = self.payload['2']
112 topics = self.engine.getTopics()
113
114 entries = self.payload['1']
115 itemid = 0
116 columnlist = self.columns
117 for entry in entries:
118
119 #print columnlist
120 #columnlist.pop()
121 if entries[entry]['1'] == '1':
122 self.treeCtrl1.AppendItem(self.treeItems[contentkey],str(entries[entry]['2']+' - English'))
123 elif entries[entry]['1'] == '2':
124 self.treeCtrl1.AppendItem(self.treeItems[contentkey],str(entries[entry]['2']+' - Deutsch'))
125 #print self.treeItems
126 itemid += 1
127
128 def OnTopicListBoxListboxDclick(self, event):
129 #event.Skip()
130 #print event
131
132 # get "ClientData" of current selected entry from widget
133 sel = self.topicListBox.GetSelection()
134 seldata = self.topicListBox.GetClientData(sel)
135
136 # determine if to activate an existing window or if to create a new one
137 win = self.parent.FindWindowByName(str(seldata))
138 if win:
139 win.Raise()
140 win.SetFocus()
141 return
142
143 # resolve associated topic entry
144 topics = self.engine.getTopics()
145 title = topics[str(seldata)]
146 #print title
147 print topics
148
149 frame = FraggleListFrame.create(self.parent)
150 frame.SetName(str(seldata))
151 frame.SetTitle(title)
152
153 # calculate new position (right beside the TopicFrame (us))
154 pos = self.GetPosition() + wxPoint(self.GetSize().GetWidth() + 5, 0)
155 frame.Move(pos)
156 self.parent.Fit()
157
158 frame.load_content(topics[str(seldata)])
159
160

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