--- nfo/projects/netfraggle/bin/FraggleTopicDetailFrame.py 2004/08/27 21:14:01 1.2 +++ nfo/projects/netfraggle/bin/FraggleTopicDetailFrame.py 2004/08/30 16:51:22 1.4 @@ -1,21 +1,28 @@ #Boa:MDIChild:FraggleTopicDetailFrame from wxPython.wx import * +from wxPython.stc import * +#import FraggleXMLRPC def create(parent): return FraggleTopicDetailFrame(parent) [wxID_FRAGGLETOPICDETAILFRAME, wxID_FRAGGLETOPICDETAILFRAMEBUTTONCLOSE, - wxID_FRAGGLETOPICDETAILFRAMEPANEL1, -] = map(lambda _init_ctrls: wxNewId(), range(3)) + wxID_FRAGGLETOPICDETAILFRAMEBUTTONREFRESH, + wxID_FRAGGLETOPICDETAILFRAMEBUTTONUPDATE, + wxID_FRAGGLETOPICDETAILFRAMECONTENT, wxID_FRAGGLETOPICDETAILFRAMEPANEL1, + wxID_FRAGGLETOPICDETAILFRAMESTATICTEXTDESCRIPTION, + wxID_FRAGGLETOPICDETAILFRAMESTATICTEXTKEYNAME, + wxID_FRAGGLETOPICDETAILFRAMETEXTCTRLDESCRIPTION, + wxID_FRAGGLETOPICDETAILFRAMETEXTCTRLKEYNAME, +] = map(lambda _init_ctrls: wxNewId(), range(10)) class FraggleTopicDetailFrame(wxMDIChildFrame): def _init_ctrls(self, prnt): # generated method, don't edit wxMDIChildFrame.__init__(self, id=wxID_FRAGGLETOPICDETAILFRAME, name='', - parent=prnt, pos=wxPoint(356, 362), size=wxSize(389, 211), + parent=prnt, pos=wxPoint(356, 362), size=wxSize(397, 238), style=wxDEFAULT_FRAME_STYLE, title='Topic details') - self._init_utils() self.SetClientSize(wxSize(389, 211)) self.panel1 = wxPanel(id=wxID_FRAGGLETOPICDETAILFRAMEPANEL1, @@ -29,13 +36,74 @@ EVT_BUTTON(self.buttonClose, wxID_FRAGGLETOPICDETAILFRAMEBUTTONCLOSE, self.OnButtoncloseButton) - def _init_utils(self): - # generated method, don't edit - pass + self.content = wxStyledTextCtrl(id=wxID_FRAGGLETOPICDETAILFRAMECONTENT, + name=u'content', parent=self.panel1, pos=wxPoint(88, 56), + size=wxSize(296, 152), style=0) + + self.buttonUpdate = wxButton(id=wxID_FRAGGLETOPICDETAILFRAMEBUTTONUPDATE, + label=u'&Update', name=u'buttonUpdate', parent=self.panel1, + pos=wxPoint(8, 184), size=wxSize(75, 23), style=0) + + self.buttonRefresh = wxButton(id=wxID_FRAGGLETOPICDETAILFRAMEBUTTONREFRESH, + label=u'&Refresh', name=u'buttonRefresh', parent=self.panel1, + pos=wxPoint(8, 160), size=wxSize(75, 23), style=0) + EVT_BUTTON(self.buttonRefresh, + wxID_FRAGGLETOPICDETAILFRAMEBUTTONREFRESH, + self.OnButtonRefreshButton) + + self.staticTextDescription = wxStaticText(id=wxID_FRAGGLETOPICDETAILFRAMESTATICTEXTDESCRIPTION, + label=u'Description:', name=u'staticTextDescription', + parent=self.panel1, pos=wxPoint(88, 32), size=wxSize(56, 13), + style=0) + + self.textCtrlDescription = wxTextCtrl(id=wxID_FRAGGLETOPICDETAILFRAMETEXTCTRLDESCRIPTION, + name=u'textCtrlDescription', parent=self.panel1, pos=wxPoint(152, + 32), size=wxSize(100, 21), style=0, value=u'') + self.textCtrlDescription.SetToolTipString(u'') + + self.staticTextKeyname = wxStaticText(id=wxID_FRAGGLETOPICDETAILFRAMESTATICTEXTKEYNAME, + label=u'Name:', name=u'staticTextKeyname', parent=self.panel1, + pos=wxPoint(88, 8), size=wxSize(31, 13), style=0) + + self.textCtrlKeyname = wxTextCtrl(id=wxID_FRAGGLETOPICDETAILFRAMETEXTCTRLKEYNAME, + name=u'textCtrlKeyname', parent=self.panel1, pos=wxPoint(152, 8), + size=wxSize(100, 21), style=0, value=u'') + self.textCtrlKeyname.SetToolTipString(u'') def __init__(self, parent): self._init_ctrls(parent) + # get engine-instance (singleton) + import __main__ + self.engine = __main__.engine + #self.load_content() def OnButtoncloseButton(self, event): self.Destroy() event.Skip() + + def load_content(self): + #self.content.SetText(self.GetTitle()) + #print self.engine.preferences.getConfig() + topicid = int(self.GetName()) + topicmeta = self.engine.getTopicById(topicid) + if topicmeta['target']['type'] == 'XMLRPC': + # TODO: make FraggleXMLRPC do all stuff + # (call methods dynamically) + from xmlrpclib import Server, Error + rpc = Server(topicmeta['target']['url']) + topicdata = {} + try: + #topicdata = rpc.getContent('Home') + topicdata = rpc.getContent(tuple(topicmeta['target']['arguments'])) + #print topicdata + except Error, v: + print "ERROR", v + if topicdata: + self.content.SetText(topicdata['content']) + self.textCtrlKeyname.SetValue(topicdata['keyname']) + self.textCtrlDescription.SetValue(topicdata['description']) + + def OnButtonRefreshButton(self, event): + event.Skip() + +