pythonverse

Python-based client for OpenVerse with extra features
git clone https://code.literati.org/pythonverse.git
Log | Files | Refs | README | LICENSE

commit 3a694827f3b8807afdf6dbc5c6b5f5f427cb544a
parent fbd0d682907cf7ec02c8e7d9b69836a73eb77a55
Author: renze <renze>
Date:   Sun, 20 Jan 2002 20:22:51 +0000

Made the call to webbrowser.open() non-blocking by starting a new thread

Diffstat:
MOpenVerse.py | 4++++
Mpvui_pygame.py | 7+++----
2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/OpenVerse.py b/OpenVerse.py @@ -17,6 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # import sys, os, asyncore, asynchat, socket, string, struct, stat +import thread, webbrowser import transutil # Global constants are all caps; global variables start with _ @@ -282,6 +283,9 @@ class ServerConnection(transutil.Connection): for n in nicks: self.write('URL %s %s\r\n' % (n, url)) + def openurl(self, url): + thread.start_new_thread(webbrowser.open, (url, 1)) + def chat(self, text): self.write('CHAT %s\r\n' % text) diff --git a/pvui_pygame.py b/pvui_pygame.py @@ -19,7 +19,7 @@ # # vim:syntax=python -import sys, bisect, string, random, webbrowser +import sys, bisect, string, random import pygame, pygame.font, pygame.image, pygame.time, pygame.draw from math import * from pygame.locals import * @@ -988,7 +988,7 @@ class Client: dirtyrects.append(urlmo.rect) del self.avatars[url] try: del self.exits['{' + url + '}_link'] - except: print url, 'not in exits' + except: print url, 'is not an exit.' self.sprites.remove(urlmo) if dirtyrects: self.redraw(dirtyrects) @@ -1042,7 +1042,7 @@ class Client: except: self.server.move(event.pos) else: if port == -1: - webbrowser.open(host) + self.server.openurl(host) if port == -2: print 'TODO: file transfers' if port > 0: @@ -1230,7 +1230,6 @@ class Client: self.avatars[url] = urlmo dirtyrects.append(urlmo.rect) self.redraw(dirtyrects) - else: print url, 'already exits' def chat(self, nick, s): dirtyrects = self.write('<%s> %s' % (nick, s))