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

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

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