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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Fri Aug 27 04:47:35 2004 UTC (19 years, 10 months ago) by joko
Branch: MAIN
Changes since 1.2: +45 -5 lines
File MIME type: text/x-python
instance of FraggleEngine now available in self.engine
added event handler "OnTopicListBoxListboxDclick" and logic to open "FraggleTopicDetailFrame"s

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

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