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

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

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