--- nfo/projects/netfraggle/bin/FraggleTopicFrame.py 2004/08/27 03:13:50 1.2 +++ nfo/projects/netfraggle/bin/FraggleTopicFrame.py 2004/08/27 04:47:35 1.3 @@ -1,7 +1,11 @@ #Boa:MDIChild:FraggleTopicFrame -# $Id: FraggleTopicFrame.py,v 1.2 2004/08/27 03:13:50 joko Exp $ +# $Id: FraggleTopicFrame.py,v 1.3 2004/08/27 04:47:35 joko Exp $ # $Log: FraggleTopicFrame.py,v $ +# Revision 1.3 2004/08/27 04:47:35 joko +# instance of FraggleEngine now available in self.engine +# added event handler "OnTopicListBoxListboxDclick" and logic to open "FraggleTopicDetailFrame"s +# # Revision 1.2 2004/08/27 03:13:50 joko # added listbox for topics and button for update/sync # @@ -12,6 +16,8 @@ from wxPython.wx import * from wxPython.stc import * +import FraggleTopicDetailFrame + def create(parent, config): return FraggleTopicFrame(parent, config) @@ -36,19 +42,54 @@ self.topicListBox = wxListBox(choices=[], id=wxID_FRAGGLETOPICFRAMETOPICLISTBOX, name=u'topicListBox', parent=self, pos=wxPoint(0, 0), size=wxSize(168, 168), style=0) + EVT_LISTBOX_DCLICK(self.topicListBox, + wxID_FRAGGLETOPICFRAMETOPICLISTBOX, + self.OnTopicListBoxListboxDclick) def __init__(self, parent, config): + self.parent = parent self.config = config self._init_ctrls(parent) + import __main__ + self.engine = __main__.engine def OnUpdateButtonButton(self, event): #event.Skip() - import __main__ - engine = __main__.engine # todo: make fraggleEngine read config on its own - engine.fraggleSync(self.config) - topics = engine.getTopics() + self.engine.fraggleSync(self.config) + topics = self.engine.getTopics() i = 0 for topic in topics: self.topicListBox.Append(topic['name'], i) i = i + 1 + + def OnTopicListBoxListboxDclick(self, event): + #event.Skip() + #print event + + # get "ClientData" of current selected entry from widget + sel = self.topicListBox.GetSelection() + seldata = self.topicListBox.GetClientData(sel) + + # determine if to activate an existing window or if to create a new one + win = self.parent.FindWindowByName(str(seldata)) + if win: + win.Raise() + win.SetFocus() + return + + # resolve associated topic entry + topics = self.engine.getTopics() + title = topics[seldata]['name'] + + frame = FraggleTopicDetailFrame.create(self.parent) + frame.SetName(str(seldata)) + frame.SetTitle(title) + + # calculate new position (right beside the TopicFrame (us)) + pos = self.GetPosition() + wxPoint(self.GetSize().GetWidth() + 5, 0) + frame.Move(pos) + self.parent.Fit() + + + \ No newline at end of file