1 |
joko |
1.1 |
#Boa:MDIChild:FraggleTopicFrame |
2 |
|
|
|
3 |
xabbu |
1.7 |
# $Id: FraggleTopicFrame.py,v 1.6 2004/08/31 02:25:34 joko Exp $ |
4 |
joko |
1.2 |
# $Log: FraggleTopicFrame.py,v $ |
5 |
xabbu |
1.7 |
# 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 |
joko |
1.6 |
# Revision 1.5 2004/08/30 13:06:16 joko |
10 |
|
|
# U now gets config via self.engine |
11 |
|
|
# |
12 |
joko |
1.5 |
# 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 |
xabbu |
1.4 |
# 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 |
joko |
1.3 |
# Revision 1.2 2004/08/27 03:13:50 joko |
22 |
|
|
# added listbox for topics and button for update/sync |
23 |
|
|
# |
24 |
joko |
1.2 |
# Revision 1.1 2004/08/26 17:23:30 joko |
25 |
|
|
# initial commit |
26 |
|
|
# |
27 |
joko |
1.1 |
|
28 |
|
|
from wxPython.wx import * |
29 |
joko |
1.2 |
from wxPython.stc import * |
30 |
joko |
1.1 |
|
31 |
joko |
1.6 |
import FraggleItemFrame |
32 |
|
|
import FraggleListFrame |
33 |
joko |
1.3 |
|
34 |
joko |
1.5 |
def create(parent): |
35 |
|
|
return FraggleTopicFrame(parent) |
36 |
joko |
1.1 |
|
37 |
joko |
1.2 |
[wxID_FRAGGLETOPICFRAME, wxID_FRAGGLETOPICFRAMETOPICLISTBOX, |
38 |
|
|
wxID_FRAGGLETOPICFRAMEUPDATEBUTTON, |
39 |
|
|
] = map(lambda _init_ctrls: wxNewId(), range(3)) |
40 |
joko |
1.1 |
|
41 |
|
|
class FraggleTopicFrame(wxMDIChildFrame): |
42 |
|
|
def _init_ctrls(self, prnt): |
43 |
|
|
# generated method, don't edit |
44 |
|
|
wxMDIChildFrame.__init__(self, id=wxID_FRAGGLETOPICFRAME, name='', |
45 |
xabbu |
1.4 |
parent=prnt, pos=wxPoint(494, 328), size=wxSize(169, 192), |
46 |
joko |
1.1 |
style=wxSIMPLE_BORDER | wxDEFAULT_FRAME_STYLE, title='Topics') |
47 |
xabbu |
1.4 |
self._init_utils() |
48 |
joko |
1.2 |
self.SetClientSize(wxSize(169, 192)) |
49 |
joko |
1.1 |
|
50 |
joko |
1.2 |
self.updateButton = wxButton(id=wxID_FRAGGLETOPICFRAMEUPDATEBUTTON, |
51 |
|
|
label=u'&Update', name=u'updateButton', parent=self, |
52 |
|
|
pos=wxPoint(0, 168), size=wxSize(168, 23), style=0) |
53 |
|
|
EVT_BUTTON(self.updateButton, wxID_FRAGGLETOPICFRAMEUPDATEBUTTON, |
54 |
|
|
self.OnUpdateButtonButton) |
55 |
|
|
|
56 |
|
|
self.topicListBox = wxListBox(choices=[], |
57 |
|
|
id=wxID_FRAGGLETOPICFRAMETOPICLISTBOX, name=u'topicListBox', |
58 |
|
|
parent=self, pos=wxPoint(0, 0), size=wxSize(168, 168), style=0) |
59 |
joko |
1.3 |
EVT_LISTBOX_DCLICK(self.topicListBox, |
60 |
|
|
wxID_FRAGGLETOPICFRAMETOPICLISTBOX, |
61 |
|
|
self.OnTopicListBoxListboxDclick) |
62 |
xabbu |
1.4 |
|
63 |
|
|
def _init_utils(self): |
64 |
|
|
# generated method, don't edit |
65 |
|
|
pass |
66 |
joko |
1.2 |
|
67 |
joko |
1.5 |
def __init__(self, parent): |
68 |
joko |
1.3 |
self.parent = parent |
69 |
joko |
1.5 |
|
70 |
|
|
# render widgets |
71 |
joko |
1.1 |
self._init_ctrls(parent) |
72 |
joko |
1.5 |
|
73 |
|
|
# get engine-instance (singleton) |
74 |
joko |
1.3 |
import __main__ |
75 |
|
|
self.engine = __main__.engine |
76 |
joko |
1.2 |
|
77 |
|
|
def OnUpdateButtonButton(self, event): |
78 |
|
|
#event.Skip() |
79 |
xabbu |
1.7 |
self.engine.syncTopics() |
80 |
joko |
1.3 |
topics = self.engine.getTopics() |
81 |
xabbu |
1.7 |
#print topics |
82 |
joko |
1.6 |
self.topicListBox.Clear() |
83 |
joko |
1.2 |
i = 0 |
84 |
|
|
for topic in topics: |
85 |
xabbu |
1.7 |
self.topicListBox.Append(topics[topic], i) |
86 |
joko |
1.2 |
i = i + 1 |
87 |
joko |
1.3 |
|
88 |
|
|
def OnTopicListBoxListboxDclick(self, event): |
89 |
|
|
#event.Skip() |
90 |
|
|
#print event |
91 |
|
|
|
92 |
|
|
# get "ClientData" of current selected entry from widget |
93 |
|
|
sel = self.topicListBox.GetSelection() |
94 |
|
|
seldata = self.topicListBox.GetClientData(sel) |
95 |
|
|
|
96 |
|
|
# determine if to activate an existing window or if to create a new one |
97 |
|
|
win = self.parent.FindWindowByName(str(seldata)) |
98 |
|
|
if win: |
99 |
|
|
win.Raise() |
100 |
|
|
win.SetFocus() |
101 |
|
|
return |
102 |
|
|
|
103 |
|
|
# resolve associated topic entry |
104 |
|
|
topics = self.engine.getTopics() |
105 |
xabbu |
1.7 |
title = topics[str(seldata)] |
106 |
|
|
#print title |
107 |
joko |
1.3 |
|
108 |
xabbu |
1.7 |
frame = FraggleListFrame.create(self.parent) |
109 |
joko |
1.3 |
frame.SetName(str(seldata)) |
110 |
|
|
frame.SetTitle(title) |
111 |
|
|
|
112 |
|
|
# calculate new position (right beside the TopicFrame (us)) |
113 |
|
|
pos = self.GetPosition() + wxPoint(self.GetSize().GetWidth() + 5, 0) |
114 |
|
|
frame.Move(pos) |
115 |
|
|
self.parent.Fit() |
116 |
|
|
|
117 |
joko |
1.5 |
frame.load_content() |
118 |
joko |
1.3 |
|
119 |
|
|
|