/[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.9 - (hide annotations)
Fri Sep 17 20:51:24 2004 UTC (20 years, 2 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 joko 1.1 #Boa:MDIChild:FraggleTopicFrame
2    
3 xabbu 1.9 # $Id: FraggleTopicFrame.py,v 1.8 2004/09/17 09:46:30 xabbu Exp $
4 joko 1.2 # $Log: FraggleTopicFrame.py,v $
5 xabbu 1.9 # 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 xabbu 1.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 xabbu 1.7 # 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 joko 1.6 # Revision 1.5 2004/08/30 13:06:16 joko
17     # U now gets config via self.engine
18     #
19 joko 1.5 # 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 xabbu 1.4 # 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 joko 1.3 # Revision 1.2 2004/08/27 03:13:50 joko
29     # added listbox for topics and button for update/sync
30     #
31 joko 1.2 # Revision 1.1 2004/08/26 17:23:30 joko
32     # initial commit
33     #
34 joko 1.1
35     from wxPython.wx import *
36 joko 1.2 from wxPython.stc import *
37 joko 1.1
38 joko 1.6 import FraggleItemFrame
39     import FraggleListFrame
40 joko 1.3
41 joko 1.5 def create(parent):
42     return FraggleTopicFrame(parent)
43 joko 1.1
44 joko 1.2 [wxID_FRAGGLETOPICFRAME, wxID_FRAGGLETOPICFRAMETOPICLISTBOX,
45 xabbu 1.9 wxID_FRAGGLETOPICFRAMETREECTRL1, wxID_FRAGGLETOPICFRAMEUPDATEBUTTON,
46     ] = map(lambda _init_ctrls: wxNewId(), range(4))
47 joko 1.1
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 xabbu 1.9 parent=prnt, pos=wxPoint(494, 328), size=wxSize(424, 219),
53 joko 1.1 style=wxSIMPLE_BORDER | wxDEFAULT_FRAME_STYLE, title='Topics')
54 xabbu 1.9 self.SetClientSize(wxSize(416, 192))
55 joko 1.1
56 joko 1.2 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 joko 1.3 EVT_LISTBOX_DCLICK(self.topicListBox,
66     wxID_FRAGGLETOPICFRAMETOPICLISTBOX,
67     self.OnTopicListBoxListboxDclick)
68 xabbu 1.4
69 xabbu 1.9 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 joko 1.2
74 joko 1.5 def __init__(self, parent):
75 joko 1.3 self.parent = parent
76 joko 1.5
77     # render widgets
78 joko 1.1 self._init_ctrls(parent)
79 joko 1.5
80     # get engine-instance (singleton)
81 joko 1.3 import __main__
82     self.engine = __main__.engine
83 joko 1.2
84     def OnUpdateButtonButton(self, event):
85     #event.Skip()
86 xabbu 1.7 self.engine.syncTopics()
87 joko 1.3 topics = self.engine.getTopics()
88 xabbu 1.7 #print topics
89 joko 1.6 self.topicListBox.Clear()
90 xabbu 1.9 self.treeCtrl1.Clear()
91 joko 1.2 i = 0
92     for topic in topics:
93 xabbu 1.8 self.topicListBox.Append(topics[str(i)], i)
94 joko 1.2 i = i + 1
95 xabbu 1.9 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 joko 1.3 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 xabbu 1.7 title = topics[str(seldata)]
146     #print title
147 xabbu 1.8 print topics
148    
149 xabbu 1.7 frame = FraggleListFrame.create(self.parent)
150 joko 1.3 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 xabbu 1.8 frame.load_content(topics[str(seldata)])
159 joko 1.3
160 xabbu 1.9

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