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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Thu Aug 26 17:23:30 2004 UTC revision 1.3 by joko, Fri Aug 27 04:47:35 2004 UTC
# Line 2  Line 2 
2    
3  # $Id$  # $Id$
4  # $Log$  # $Log$
5    # Revision 1.3  2004/08/27 04:47:35  joko
6    # instance of FraggleEngine now available in self.engine
7    # added event handler "OnTopicListBoxListboxDclick" and logic to open "FraggleTopicDetailFrame"s
8    #
9    # Revision 1.2  2004/08/27 03:13:50  joko
10    # added listbox for topics and button for update/sync
11    #
12  # Revision 1.1  2004/08/26 17:23:30  joko  # Revision 1.1  2004/08/26 17:23:30  joko
13  # initial commit  # initial commit
14  #  #
15    
16  from wxPython.wx import *  from wxPython.wx import *
17    from wxPython.stc import *
18    
19  def create(parent):  import FraggleTopicDetailFrame
     return FraggleTopicFrame(parent)  
20    
21  [wxID_FRAGGLETOPICFRAME] = map(lambda _init_ctrls: wxNewId(), range(1))  def create(parent, config):
22        return FraggleTopicFrame(parent, config)
23    
24    [wxID_FRAGGLETOPICFRAME, wxID_FRAGGLETOPICFRAMETOPICLISTBOX,
25     wxID_FRAGGLETOPICFRAMEUPDATEBUTTON,
26    ] = map(lambda _init_ctrls: wxNewId(), range(3))
27    
28  class FraggleTopicFrame(wxMDIChildFrame):  class FraggleTopicFrame(wxMDIChildFrame):
29      def _init_ctrls(self, prnt):      def _init_ctrls(self, prnt):
30          # generated method, don't edit          # generated method, don't edit
31          wxMDIChildFrame.__init__(self, id=wxID_FRAGGLETOPICFRAME, name='',          wxMDIChildFrame.__init__(self, id=wxID_FRAGGLETOPICFRAME, name='',
32                parent=prnt, pos=wxPoint(352, 280), size=wxSize(138, 215),                parent=prnt, pos=wxPoint(352, 280), size=wxSize(177, 219),
33                style=wxSIMPLE_BORDER | wxDEFAULT_FRAME_STYLE, title='Topics')                style=wxSIMPLE_BORDER | wxDEFAULT_FRAME_STYLE, title='Topics')
34          self.SetClientSize(wxSize(130, 188))          self.SetClientSize(wxSize(169, 192))
35    
36      def __init__(self, parent):          self.updateButton = wxButton(id=wxID_FRAGGLETOPICFRAMEUPDATEBUTTON,
37                  label=u'&Update', name=u'updateButton', parent=self,
38                  pos=wxPoint(0, 168), size=wxSize(168, 23), style=0)
39            EVT_BUTTON(self.updateButton, wxID_FRAGGLETOPICFRAMEUPDATEBUTTON,
40                  self.OnUpdateButtonButton)
41    
42            self.topicListBox = wxListBox(choices=[],
43                  id=wxID_FRAGGLETOPICFRAMETOPICLISTBOX, name=u'topicListBox',
44                  parent=self, pos=wxPoint(0, 0), size=wxSize(168, 168), style=0)
45            EVT_LISTBOX_DCLICK(self.topicListBox,
46                  wxID_FRAGGLETOPICFRAMETOPICLISTBOX,
47                  self.OnTopicListBoxListboxDclick)
48    
49        def __init__(self, parent, config):
50            self.parent = parent
51            self.config = config
52          self._init_ctrls(parent)          self._init_ctrls(parent)
53            import __main__
54            self.engine = __main__.engine
55    
56        def OnUpdateButtonButton(self, event):
57            #event.Skip()
58            # todo: make fraggleEngine read config on its own
59            self.engine.fraggleSync(self.config)
60            topics = self.engine.getTopics()
61            i = 0
62            for topic in topics:
63                self.topicListBox.Append(topic['name'], i)
64                i = i + 1
65    
66        def OnTopicListBoxListboxDclick(self, event):
67            #event.Skip()
68            #print event
69            
70            # get "ClientData" of current selected entry from widget
71            sel = self.topicListBox.GetSelection()
72            seldata = self.topicListBox.GetClientData(sel)
73            
74            # determine if to activate an existing window or if to create a new one
75            win = self.parent.FindWindowByName(str(seldata))
76            if win:
77                win.Raise()
78                win.SetFocus()
79                return
80    
81            # resolve associated topic entry
82            topics = self.engine.getTopics()
83            title = topics[seldata]['name']
84    
85            frame = FraggleTopicDetailFrame.create(self.parent)
86            frame.SetName(str(seldata))
87            frame.SetTitle(title)
88            
89            # calculate new position (right beside the TopicFrame (us))
90            pos = self.GetPosition() + wxPoint(self.GetSize().GetWidth() + 5, 0)
91            frame.Move(pos)
92            self.parent.Fit()
93            
94            
95            

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

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