[pygame] unsubscribe

2010-01-07 Thread David Gustafson
-- 
Doubt is not a pleasant condition, but certainty is absurd.
-- Voltaire


[pygame] py2exe oceangui problem

2009-04-07 Thread David Gustafson
I'm having a problem and I wonder if anyone has any insight.  I have a
program that works runs properly but when I use py2exe to create an
executable and then attempt to run that executable from the dist dir I
get:

D:\code\test\disttwisted_ocean_client.exe
D:\code\test\dist\library.zip\twisted\spread\pb.py:30:
DeprecationWarning: the md5 module is deprecated; use hashlib instead
D:\code\test\dist\library.zip\ocempgui\draw\String.py:71:
RuntimeWarning: use font: DLL load failed: The specified module could
not be found
.
Traceback (most recent call last):
  File twisted_ocean_client.py, line 279, in module
  File twisted_ocean_client.py, line 227, in __init__
  File twisted_ocean_client.py, line 239, in drawButton
  File ocempgui\widgets\Button.pyc, line 83, in __init__
  File ocempgui\widgets\Button.pyc, line 97, in set_text
  File ocempgui\widgets\Label.pyc, line 124, in __init__
  File ocempgui\widgets\Label.pyc, line 158, in set_text
  File ocempgui\widgets\BaseWidget.pyc, line 961, in lambda
  File ocempgui\widgets\BaseWidget.pyc, line 527, in set_dirty
  File ocempgui\widgets\BaseWidget.pyc, line 875, in update
  File ocempgui\widgets\BaseWidget.pyc, line 792, in draw
  File ocempgui\widgets\Label.pyc, line 318, in draw_bg
  File D:\Python26\share\ocempgui\themes\default\DefaultEngine.py,
line 682, in draw_label
rtext = self.draw_string (label.text, label.state, cls, st)
  File D:\Python26\share\ocempgui\themes\default\DefaultEngine.py,
line 287, in draw_string
return String.draw_string (text, name, size, alias, color, st)
  File ocempgui\draw\String.pyc, line 169, in draw_string
  File ocempgui\draw\String.pyc, line 135, in create_font
  File ocempgui\draw\String.pyc, line 71, in create_file_font
  File pygame\__init__.pyc, line 70, in __getattr__
NotImplementedError: font module not available

D:\code\test\dist


Here is the code it is compiling and I can run it directly with python.
--


import pygame
import sys
from pygame import QUIT, event
from pygame import error as PygameError
from pygame import time as PygameTime

from random import randint

from ocempgui.widgets import *
from ocempgui.widgets.Constants import *
from ocempgui.object import BaseObject

from ocempgui.widgets import Button, Renderer
from twisted.internet._threadedselect import install
install()
from twisted.spread import pb
from twisted.internet import reactor

REPORT = pygame.locals.USEREVENT + 4
SCORE = pygame.locals.USEREVENT + 5

def main_loop():
events = pygame.event.get ()
for ev in events:
if ev.type == pygame.QUIT:
sys.exit ()

re.distribute_events (*events)
re.refresh ()
pygame.time.delay (15)


class CustomTwistedRenderer (Renderer):
TwistedRenderer () - TwistedRenderer

A Renderer that allows the easy integration with Twisted.

Because Twisted's threadedselectreactor *must* be shut down before
the main loop shuts down, this Renderer will keep running until
explicitly told to stop.

Before starting the main loop, this Renderer will check to see if it
has a Twisted reactor attached to it. This is an attribute set like
any of the normal Renderer attributes:

self.reactor = reactor

If self.reactor is None (default), this will behave like a normal
Renderer. If self.reactor has been set, the QUIT signal will call
reactor.stop(), and then wait for reactor.addSystemEventTrigger to
call self.stop(). This function will then stop the main loop.

Usage
-
Install the threadedselectreactor instead of the default reactor:

from twisted.internet.threadedselectreactor import install
install()
from twisted.internet import reactor

In the main section of your program, where you create the Renderer,
just set TwistedRenderer's reactor:

re = TwistedRenderer()
re.reactor = reactor

Everything else is handled internally by TwistedRenderer.

Attributes:
reactor - The twisted reactor attached to the TwistedRenderer.

def __init__ (self):
Renderer.__init__ (self)
self._reactor = None
self._running = False

def start (self):
T.start () - None

Overrides default start() to use self._running. If a reactor is
attached, interleave self.waker

self._running = 1
if self._reactor != None:
self._reactor.interleave (self.waker)
self._loop()

def stop (self):
T.stop () - None

Tells the internal loop to stop running.

self._running = False

def set_reactor (self, reactor):
T.set_reactor (...) - None

Sets the internal reactor.

if not hasattr (reactor, 'interleave'):
raise AttributeError (interleave() method not found in %s %
  reactor)
self._reactor = reactor
self._reactor.addSystemEventTrigger ('after', 'shutdown', self.stop)

def waker (self, func):