#!/usr/bin/env python # -*- coding: cp1252 mode:python -*- # listbox1.py # (C) Håvard Dahle, 2004 # License: GPL BLOGID = "SHOT" HOST= "http://www.orakel.ntnu.no/~havardda/blogg/xmlrpc.php" # your host USERNAME = "" # your username PASSWORD = "" # your password from wax import * import xmlrpclib class MainFrame(Frame): def Body(self): # the panel isn't really necessary, but we can use it to add a border p1 = Panel(self, direction='v') self.titlebox = TextBox(p1, "title") p1.AddComponent(self.titlebox, border=3, stretch=1, expand=0) self.postbox = TextBox(p1, "post", multiline=1, size=(300,300)) p1.AddComponent(self.postbox, border=3, stretch=1, expand=1) btn = Button(p1, "New post") p1.AddComponent(btn, border=1, stretch=0, expand=0) p1.Pack() btn.OnClick = self.post self.AddComponent(p1, border=5, stretch=1, expand=1) self.Pack() def post(self, event): title = self.titlebox.GetValue() content = "%s%s" % (title, self.postbox.GetValue()) rpc = xmlrpclib.ServerProxy(HOST) publish = xmlrpclib.Boolean(1) try: id = rpc.blogger.newPost("", # appkey BLOGID, # blogid USERNAME, # username PASSWORD, # password content, # content? publish # publish ) except: self.alert("Couldn't publish..") else: self.info("Published successfully with id %s" % id) def alert(self, msg): self.modal("Error", msg, "error") def info(self, msg): self.modal("Info", msg, "information") def modal(self, title, msg, type): dialog = MessageDialog(self, title, msg, icon=type) dialog.ShowModal() dialog.Destroy() if __name__ == "__main__": app = Application(MainFrame, title='SHOT', direction='v') app.Run()