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