~landscape/zope3/newer-from-ztk

« back to all changes in this revision

Viewing changes to src/twisted/internet/pyuisupport.py

  • Committer: Thomas Hervé
  • Date: 2009-07-08 13:52:04 UTC
  • Revision ID: thomas@canonical.com-20090708135204-df5eesrthifpylf8
Remove twisted copy

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
2
 
# See LICENSE for details.
3
 
 
4
 
 
5
 
"""This module integrates PyUI with twisted.internet's mainloop.
6
 
 
7
 
API Stability: unstable
8
 
 
9
 
Maintainer: U{Jp Calderone<mailto:exarkun@twistedmatrix.com>}
10
 
 
11
 
See doc/examples/pyuidemo.py for example usage.
12
 
"""
13
 
 
14
 
# System imports
15
 
import pyui
16
 
 
17
 
def _guiUpdate(reactor, delay):
18
 
    pyui.draw()
19
 
    if pyui.update() == 0:
20
 
        pyui.quit()
21
 
        reactor.stop()
22
 
    else:
23
 
        reactor.callLater(delay, _guiUpdate, reactor, delay)
24
 
 
25
 
 
26
 
def install(ms=10, reactor=None, args=(), kw={}):
27
 
    """
28
 
    Schedule PyUI's display to be updated approximately every C{ms}
29
 
    milliseconds, and initialize PyUI with the specified arguments.
30
 
    """
31
 
    d = pyui.init(*args, **kw)
32
 
 
33
 
    if reactor is None:
34
 
        from twisted.internet import reactor
35
 
    _guiUpdate(reactor, ms / 1000.0)
36
 
    return d
37
 
 
38
 
__all__ = ["install"]