1 |
#Boa:MDIChild:FraggleTopicFrame |
2 |
|
3 |
# $Id: FraggleTopicFrame.py,v 1.2 2004/08/27 03:13:50 joko Exp $ |
4 |
# $Log: FraggleTopicFrame.py,v $ |
5 |
# Revision 1.2 2004/08/27 03:13:50 joko |
6 |
# added listbox for topics and button for update/sync |
7 |
# |
8 |
# Revision 1.1 2004/08/26 17:23:30 joko |
9 |
# initial commit |
10 |
# |
11 |
|
12 |
from wxPython.wx import * |
13 |
from wxPython.stc import * |
14 |
|
15 |
import FraggleTopicDetailFrame |
16 |
|
17 |
def create(parent, config): |
18 |
return FraggleTopicFrame(parent, config) |
19 |
|
20 |
[wxID_FRAGGLETOPICFRAME, wxID_FRAGGLETOPICFRAMETOPICLISTBOX, |
21 |
wxID_FRAGGLETOPICFRAMEUPDATEBUTTON, |
22 |
] = map(lambda _init_ctrls: wxNewId(), range(3)) |
23 |
|
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 |
parent=prnt, pos=wxPoint(352, 280), size=wxSize(177, 219), |
29 |
style=wxSIMPLE_BORDER | wxDEFAULT_FRAME_STYLE, title='Topics') |
30 |
self.SetClientSize(wxSize(169, 192)) |
31 |
|
32 |
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 |
EVT_LISTBOX_DCLICK(self.topicListBox, |
42 |
wxID_FRAGGLETOPICFRAMETOPICLISTBOX, |
43 |
self.OnTopicListBoxListboxDclick) |
44 |
|
45 |
def __init__(self, parent, config): |
46 |
self.parent = parent |
47 |
self.config = config |
48 |
self._init_ctrls(parent) |
49 |
import __main__ |
50 |
self.engine = __main__.engine |
51 |
|
52 |
def OnUpdateButtonButton(self, event): |
53 |
#event.Skip() |
54 |
# todo: make fraggleEngine read config on its own |
55 |
self.engine.fraggleSync(self.config) |
56 |
topics = self.engine.getTopics() |
57 |
i = 0 |
58 |
for topic in topics: |
59 |
self.topicListBox.Append(topic['name'], i) |
60 |
i = i + 1 |
61 |
|
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 |
|