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

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.5

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