1 # Copyright (c) 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)
23 When using Aqua Tcl/Tk on Mac OS X the standard Quit menu item in
24 your application might become unresponsive without the additional
27 | root.createcommand("::tk::mac::Quit", reactor.stop)
29 @see: U{Tcl/TkAqua FAQ for more info<http://wiki.tcl.tk/12987>}
33 import Tkinter, tkSimpleDialog, tkMessageBox
36 from twisted.python import log
37 from twisted.internet import task
42 def install(widget, ms=10, reactor=None):
43 """Install a Tkinter.Tk() object into the reactor."""
46 _task = task.LoopingCall(widget.update)
47 _task.start(ms / 1000.0, False)
50 """Remove the root Tk widget from the reactor.
52 Call this before destroy()ing the root widget.
59 def installTkFunctions():
60 import twisted.python.util
61 twisted.python.util.getPassword = getPassword
64 def getPassword(prompt = '', confirm = 0):
66 try1 = tkSimpleDialog.askstring('Password Dialog', prompt, show='*')
69 try2 = tkSimpleDialog.askstring('Password Dialog', 'Confirm Password', show='*')
73 tkMessageBox.showerror('Password Mismatch', 'Passwords did not match, starting over')
75 __all__ = ["install", "uninstall"]