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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (hide 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 joko 1.1 #Boa:MDIChild:FraggleTopicFrame
2    
3 xabbu 1.10 # $Id: FraggleTopicFrame.py,v 1.9 2004/09/17 20:51:24 xabbu Exp $
4 joko 1.2 # $Log: FraggleTopicFrame.py,v $
5 xabbu 1.10 # 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 xabbu 1.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 xabbu 1.8 # 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 xabbu 1.7 # 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 joko 1.6 # Revision 1.5 2004/08/30 13:06:16 joko
21     # U now gets config via self.engine
22     #
23 joko 1.5 # 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 xabbu 1.4 # 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 joko 1.3 # Revision 1.2 2004/08/27 03:13:50 joko
33     # added listbox for topics and button for update/sync
34     #
35 joko 1.2 # Revision 1.1 2004/08/26 17:23:30 joko
36     # initial commit
37     #
38 joko 1.1
39     from wxPython.wx import *
40 joko 1.2 from wxPython.stc import *
41 joko 1.1
42 joko 1.6 import FraggleItemFrame
43     import FraggleListFrame
44 joko 1.3
45 joko 1.5 def create(parent):
46     return FraggleTopicFrame(parent)
47 joko 1.1
48 joko 1.2 [wxID_FRAGGLETOPICFRAME, wxID_FRAGGLETOPICFRAMETOPICLISTBOX,
49 xabbu 1.9 wxID_FRAGGLETOPICFRAMETREECTRL1, wxID_FRAGGLETOPICFRAMEUPDATEBUTTON,
50     ] = map(lambda _init_ctrls: wxNewId(), range(4))
51 joko 1.1
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 xabbu 1.9 parent=prnt, pos=wxPoint(494, 328), size=wxSize(424, 219),
57 joko 1.1 style=wxSIMPLE_BORDER | wxDEFAULT_FRAME_STYLE, title='Topics')
58 xabbu 1.9 self.SetClientSize(wxSize(416, 192))
59 joko 1.1
60 joko 1.2 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 joko 1.3 EVT_LISTBOX_DCLICK(self.topicListBox,
70     wxID_FRAGGLETOPICFRAMETOPICLISTBOX,
71     self.OnTopicListBoxListboxDclick)
72 xabbu 1.4
73 xabbu 1.9 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 xabbu 1.10 EVT_LEFT_DCLICK(self.treeCtrl1, self.OnTreeCtrl1LeftDclick)
78 joko 1.2
79 joko 1.5 def __init__(self, parent):
80 joko 1.3 self.parent = parent
81 joko 1.5
82     # render widgets
83 joko 1.1 self._init_ctrls(parent)
84 joko 1.5
85     # get engine-instance (singleton)
86 joko 1.3 import __main__
87     self.engine = __main__.engine
88 joko 1.2
89     def OnUpdateButtonButton(self, event):
90     #event.Skip()
91 xabbu 1.7 self.engine.syncTopics()
92 joko 1.3 topics = self.engine.getTopics()
93 xabbu 1.7 #print topics
94 joko 1.6 self.topicListBox.Clear()
95 xabbu 1.9 self.treeCtrl1.Clear()
96 joko 1.2 i = 0
97     for topic in topics:
98 xabbu 1.8 self.topicListBox.Append(topics[str(i)], i)
99 joko 1.2 i = i + 1
100 xabbu 1.9 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 xabbu 1.10 data = entries[entry]
124     itemData = wxTreeItemData()
125     itemData.SetData(data)
126 xabbu 1.9 #print columnlist
127     #columnlist.pop()
128     if entries[entry]['1'] == '1':
129 xabbu 1.10 self.treeCtrl1.AppendItem(self.treeItems[contentkey],
130     str(entries[entry]['2']+' - English'),
131     -1,
132     -1,
133     itemData)
134 xabbu 1.9 elif entries[entry]['1'] == '2':
135 xabbu 1.10 self.treeCtrl1.AppendItem(self.treeItems[contentkey],
136     str(entries[entry]['2']+' - Deutsch'),
137     -1,
138     -1,
139     itemData)
140 xabbu 1.9 #print self.treeItems
141     itemid += 1
142    
143 joko 1.3 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 xabbu 1.7 title = topics[str(seldata)]
161     #print title
162 xabbu 1.8 print topics
163    
164 xabbu 1.7 frame = FraggleListFrame.create(self.parent)
165 joko 1.3 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 xabbu 1.8 frame.load_content(topics[str(seldata)])
174 xabbu 1.10
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 joko 1.3
184 xabbu 1.9

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