1
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
2
# See LICENSE for details.
6
This module integrates Tkinter with twisted.internet's mainloop.
8
Maintainer: Itamar Shtull-Trauring
12
| tksupport.install(rootWidget)
14
and then run your reactor as usual - do *not* call Tk's mainloop(),
15
use Twisted's regular mechanism for running the event loop.
17
Likewise, to stop your program you will need to stop Twisted's
18
event loop. For example, if you want closing your root widget to
21
| root.protocol('WM_DELETE_WINDOW', reactor.stop)
26
import Tkinter, tkSimpleDialog, tkMessageBox
29
from twisted.python import log
30
from twisted.internet import task
35
def install(widget, ms=10, reactor=None):
36
"""Install a Tkinter.Tk() object into the reactor."""
39
_task = task.LoopingCall(widget.update)
40
_task.start(ms / 1000.0, False)
43
"""Remove the root Tk widget from the reactor.
45
Call this before destroy()ing the root widget.
52
def installTkFunctions():
53
import twisted.python.util
54
twisted.python.util.getPassword = getPassword
57
def getPassword(prompt = '', confirm = 0):
59
try1 = tkSimpleDialog.askstring('Password Dialog', prompt, show='*')
62
try2 = tkSimpleDialog.askstring('Password Dialog', 'Confirm Password', show='*')
66
tkMessageBox.showerror('Password Mismatch', 'Passwords did not match, starting over')
68
__all__ = ["install", "uninstall"]