def __init__(self, canvas): self.canvas = canvas self.findRootVisual() self.rand = Random() self.RedrawScreen(0) wc = WebClient() wc.DownloadStringCompleted += self.xamlDownloaded wc.DownloadStringAsync(Uri('star.xaml', UriKind.Relative))
def server(*urlcomponents): url = "/%s/" % serverurl + "/".join(urlcomponents) result = [False, None, None] def callback(s, e): result[0] = True result[1] = e.Error if not result[1]: result[2] = e.Result webclient = WebClient() webclient.DownloadStringCompleted += callback webclient.DownloadStringAsync(Uri(url, UriKind.Relative)) while not result[0]: sleep(0.5) if result[1]: raise IOError, "Problem accessing web server\n%s" % result[1] return result[2]