/[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.10 - (show annotations)
Tue Sep 21 18:11:05 2004 UTC (19 years, 9 months ago) by xabbu
Branch: MAIN
CVS Tags: HEAD
Changes since 1.9: +28 -4 lines
File MIME type: text/x-python
+ started work on the final tree Controll to display contenttypes and their items

1 #Boa:MDIChild:FraggleTopicFrame
2
3 # $Id: FraggleTopicFrame.py,v 1.9 2004/09/17 20:51:24 xabbu Exp $
4 # $Log: FraggleTopicFrame.py,v $
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
33 # added listbox for topics and button for update/sync
34 #
35 # Revision 1.1 2004/08/26 17:23:30 joko
36 # initial commit
37 #
38
39 from wxPython.wx import *
40 from wxPython.stc import *
41
42 import FraggleItemFrame
43 import FraggleListFrame
44
45 def create(parent):
46 return FraggleTopicFrame(parent)
47
48 [wxID_FRAGGLETOPICFRAME, wxID_FRAGGLETOPICFRAMETOPICLISTBOX,
49 wxID_FRAGGLETOPICFRAMETREECTRL1, wxID_FRAGGLETOPICFRAMEUPDATEBUTTON,
50 ] = map(lambda _init_ctrls: wxNewId(), range(4))
51
52 class FraggleTopicFrame(wxMDIChildFrame):
53 def _init_ctrls(self, prnt):
54 # generated method, don't edit
55 wxMDIChildFrame.__init__(self, id=wxID_FRAGGLETOPICFRAME, name='',
56 parent=prnt, pos=wxPoint(494, 328), size=wxSize(424, 219),
57 style=wxSIMPLE_BORDER | wxDEFAULT_FRAME_STYLE, title='Topics')
58 self.SetClientSize(wxSize(416, 192))
59
60 self.updateButton = wxButton(id=wxID_FRAGGLETOPICFRAMEUPDATEBUTTON,
61 label=u'&Update', name=u'updateButton', parent=self,
62 pos=wxPoint(0, 168), size=wxSize(168, 23), style=0)
63 EVT_BUTTON(self.updateButton, wxID_FRAGGLETOPICFRAMEUPDATEBUTTON,
64 self.OnUpdateButtonButton)
65
66 self.topicListBox = wxListBox(choices=[],
67 id=wxID_FRAGGLETOPICFRAMETOPICLISTBOX, name=u'topicListBox',
68 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 EVT_LEFT_DCLICK(self.treeCtrl1, self.OnTreeCtrl1LeftDclick)
78
79 def __init__(self, parent):
80 self.parent = parent
81
82 # render widgets
83 self._init_ctrls(parent)
84
85 # get engine-instance (singleton)
86 import __main__
87 self.engine = __main__.engine
88
89 def OnUpdateButtonButton(self, event):
90 #event.Skip()
91 self.engine.syncTopics()
92 topics = self.engine.getTopics()
93 #print topics
94 self.topicListBox.Clear()
95 self.treeCtrl1.Clear()
96 i = 0
97 for topic in topics:
98 self.topicListBox.Append(topics[str(i)], i)
99 i = i + 1
100 self.initTreeList()
101
102 def initTreeList(self):
103 topics = self.engine.getTopics()
104 i = 0
105 self.treeItems = {}
106 self.rootItem = self.treeCtrl1.AddRoot('Root')
107 self.treeItems[topics[str(i)]] = {}
108 for topic in topics:
109 self.treeItems[topics[str(i)]] = self.treeCtrl1.AppendItem(self.rootItem, topics[str(i)])
110 self.load_content(topics[str(i)])
111 i = i + 1
112
113
114 def load_content(self,contentkey):
115 self.payload = self.engine.listItems(contentkey)
116 self.columns = self.payload['2']
117 topics = self.engine.getTopics()
118
119 entries = self.payload['1']
120 itemid = 0
121 columnlist = self.columns
122 for entry in entries:
123 data = entries[entry]
124 itemData = wxTreeItemData()
125 itemData.SetData(data)
126 #print columnlist
127 #columnlist.pop()
128 if entries[entry]['1'] == '1':
129 self.treeCtrl1.AppendItem(self.treeItems[contentkey],
130 str(entries[entry]['2']+' - English'),
131 -1,
132 -1,
133 itemData)
134 elif entries[entry]['1'] == '2':
135 self.treeCtrl1.AppendItem(self.treeItems[contentkey],
136 str(entries[entry]['2']+' - Deutsch'),
137 -1,
138 -1,
139 itemData)
140 #print self.treeItems
141 itemid += 1
142
143 def OnTopicListBoxListboxDclick(self, event):
144 #event.Skip()
145 #print event
146
147 # get "ClientData" of current selected entry from widget
148 sel = self.topicListBox.GetSelection()
149 seldata = self.topicListBox.GetClientData(sel)
150
151 # determine if to activate an existing window or if to create a new one
152 win = self.parent.FindWindowByName(str(seldata))
153 if win:
154 win.Raise()
155 win.SetFocus()
156 return
157
158 # resolve associated topic entry
159 topics = self.engine.getTopics()
160 title = topics[str(seldata)]
161 #print title
162 print topics
163
164 frame = FraggleListFrame.create(self.parent)
165 frame.SetName(str(seldata))
166 frame.SetTitle(title)
167
168 # calculate new position (right beside the TopicFrame (us))
169 pos = self.GetPosition() + wxPoint(self.GetSize().GetWidth() + 5, 0)
170 frame.Move(pos)
171 self.parent.Fit()
172
173 frame.load_content(topics[str(seldata)])
174
175 def OnTreeCtrl1LeftDclick(self, event):
176 sel = self.treeCtrl1.GetSelection()
177 selitem = self.treeCtrl1.GetItemData(sel)
178 seldata = selitem.GetData()
179 selparent = self.treeCtrl1.GetItemParent(sel)
180 seltype = self.treeCtrl1.GetItemText(selparent)
181 self.engine.modules.Dispatch(seldata,seltype)
182 event.Skip()
183
184

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