| 1 |
#Boa:MDIChild:FraggleTopicDetailFrame |
| 2 |
|
| 3 |
from wxPython.wx import * |
| 4 |
from wxPython.stc import * |
| 5 |
#import FraggleXMLRPC |
| 6 |
|
| 7 |
def create(parent): |
| 8 |
return FraggleTopicDetailFrame(parent) |
| 9 |
|
| 10 |
[wxID_FRAGGLETOPICDETAILFRAME, wxID_FRAGGLETOPICDETAILFRAMEBUTTONCLOSE, |
| 11 |
wxID_FRAGGLETOPICDETAILFRAMEBUTTONREFRESH, |
| 12 |
wxID_FRAGGLETOPICDETAILFRAMEBUTTONUPDATE, |
| 13 |
wxID_FRAGGLETOPICDETAILFRAMECONTENT, wxID_FRAGGLETOPICDETAILFRAMEPANEL1, |
| 14 |
wxID_FRAGGLETOPICDETAILFRAMESTATICTEXTDESCRIPTION, |
| 15 |
wxID_FRAGGLETOPICDETAILFRAMESTATICTEXTKEYNAME, |
| 16 |
wxID_FRAGGLETOPICDETAILFRAMETEXTCTRLDESCRIPTION, |
| 17 |
wxID_FRAGGLETOPICDETAILFRAMETEXTCTRLKEYNAME, |
| 18 |
] = map(lambda _init_ctrls: wxNewId(), range(10)) |
| 19 |
|
| 20 |
class FraggleTopicDetailFrame(wxMDIChildFrame): |
| 21 |
def _init_ctrls(self, prnt): |
| 22 |
# generated method, don't edit |
| 23 |
wxMDIChildFrame.__init__(self, id=wxID_FRAGGLETOPICDETAILFRAME, name='', |
| 24 |
parent=prnt, pos=wxPoint(356, 362), size=wxSize(397, 238), |
| 25 |
style=wxDEFAULT_FRAME_STYLE, title='Topic details') |
| 26 |
self.SetClientSize(wxSize(389, 211)) |
| 27 |
|
| 28 |
self.panel1 = wxPanel(id=wxID_FRAGGLETOPICDETAILFRAMEPANEL1, |
| 29 |
name='panel1', parent=self, pos=wxPoint(0, 0), size=wxSize(389, |
| 30 |
211), style=wxTAB_TRAVERSAL) |
| 31 |
|
| 32 |
self.buttonClose = wxButton(id=wxID_FRAGGLETOPICDETAILFRAMEBUTTONCLOSE, |
| 33 |
label='X', name='buttonClose', parent=self.panel1, pos=wxPoint(8, |
| 34 |
8), size=wxSize(16, 16), style=0) |
| 35 |
self.buttonClose.SetAutoLayout(True) |
| 36 |
EVT_BUTTON(self.buttonClose, wxID_FRAGGLETOPICDETAILFRAMEBUTTONCLOSE, |
| 37 |
self.OnButtoncloseButton) |
| 38 |
|
| 39 |
self.content = wxStyledTextCtrl(id=wxID_FRAGGLETOPICDETAILFRAMECONTENT, |
| 40 |
name=u'content', parent=self.panel1, pos=wxPoint(88, 56), |
| 41 |
size=wxSize(296, 152), style=0) |
| 42 |
|
| 43 |
self.buttonUpdate = wxButton(id=wxID_FRAGGLETOPICDETAILFRAMEBUTTONUPDATE, |
| 44 |
label=u'&Update', name=u'buttonUpdate', parent=self.panel1, |
| 45 |
pos=wxPoint(8, 184), size=wxSize(75, 23), style=0) |
| 46 |
|
| 47 |
self.buttonRefresh = wxButton(id=wxID_FRAGGLETOPICDETAILFRAMEBUTTONREFRESH, |
| 48 |
label=u'&Refresh', name=u'buttonRefresh', parent=self.panel1, |
| 49 |
pos=wxPoint(8, 160), size=wxSize(75, 23), style=0) |
| 50 |
EVT_BUTTON(self.buttonRefresh, |
| 51 |
wxID_FRAGGLETOPICDETAILFRAMEBUTTONREFRESH, |
| 52 |
self.OnButtonRefreshButton) |
| 53 |
|
| 54 |
self.staticTextDescription = wxStaticText(id=wxID_FRAGGLETOPICDETAILFRAMESTATICTEXTDESCRIPTION, |
| 55 |
label=u'Description:', name=u'staticTextDescription', |
| 56 |
parent=self.panel1, pos=wxPoint(88, 32), size=wxSize(56, 13), |
| 57 |
style=0) |
| 58 |
|
| 59 |
self.textCtrlDescription = wxTextCtrl(id=wxID_FRAGGLETOPICDETAILFRAMETEXTCTRLDESCRIPTION, |
| 60 |
name=u'textCtrlDescription', parent=self.panel1, pos=wxPoint(152, |
| 61 |
32), size=wxSize(100, 21), style=0, value=u'') |
| 62 |
self.textCtrlDescription.SetToolTipString(u'') |
| 63 |
|
| 64 |
self.staticTextKeyname = wxStaticText(id=wxID_FRAGGLETOPICDETAILFRAMESTATICTEXTKEYNAME, |
| 65 |
label=u'Name:', name=u'staticTextKeyname', parent=self.panel1, |
| 66 |
pos=wxPoint(88, 8), size=wxSize(31, 13), style=0) |
| 67 |
|
| 68 |
self.textCtrlKeyname = wxTextCtrl(id=wxID_FRAGGLETOPICDETAILFRAMETEXTCTRLKEYNAME, |
| 69 |
name=u'textCtrlKeyname', parent=self.panel1, pos=wxPoint(152, 8), |
| 70 |
size=wxSize(100, 21), style=0, value=u'') |
| 71 |
self.textCtrlKeyname.SetToolTipString(u'') |
| 72 |
|
| 73 |
def __init__(self, parent): |
| 74 |
self._init_ctrls(parent) |
| 75 |
# get engine-instance (singleton) |
| 76 |
import __main__ |
| 77 |
self.engine = __main__.engine |
| 78 |
#self.load_content() |
| 79 |
|
| 80 |
def OnButtoncloseButton(self, event): |
| 81 |
self.Destroy() |
| 82 |
event.Skip() |
| 83 |
|
| 84 |
def load_content(self): |
| 85 |
#self.content.SetText(self.GetTitle()) |
| 86 |
#print self.engine.preferences.getConfig() |
| 87 |
topicid = int(self.GetName()) |
| 88 |
topicmeta = self.engine.getTopicById(topicid) |
| 89 |
if topicmeta['target']['type'] == 'XMLRPC': |
| 90 |
# TODO: make FraggleXMLRPC do all stuff |
| 91 |
# (call methods dynamically) |
| 92 |
from xmlrpclib import Server, Error |
| 93 |
rpc = Server(topicmeta['target']['url']) |
| 94 |
topicdata = {} |
| 95 |
try: |
| 96 |
#topicdata = rpc.getContent('Home') |
| 97 |
topicdata = rpc.getContent(tuple(topicmeta['target']['arguments'])) |
| 98 |
#print topicdata |
| 99 |
except Error, v: |
| 100 |
print "ERROR", v |
| 101 |
if topicdata: |
| 102 |
self.content.SetText(topicdata['content']) |
| 103 |
self.textCtrlKeyname.SetValue(topicdata['keyname']) |
| 104 |
self.textCtrlDescription.SetValue(topicdata['description']) |
| 105 |
|
| 106 |
def OnButtonRefreshButton(self, event): |
| 107 |
event.Skip() |
| 108 |
|
| 109 |
|