Tk/Tcl interface module

Steen Lumholt (lumholt@login.dkuug.dk)
31 May 94 20:39:44 GMT

My Python interface to Tk/Tcl is kind of finished. The tk & tcl
library interface is finished. I'm still working on a set of Tk
wrapper classes.

So now it's possible to create and manipulate Tk/Tcl programs from
Python. Python methods can also be registered as Tk/Tcl commands; so
that you don't need to write Tcl procedures!

If you use Python in interactive mode, you can (as in wish) manipulate
the running GUI interactively. This only works if you use readline,
as rl_event_hook is used for event processing.

Here's an example (it works):

##################################################
from Tkinter import *

def do_hello():
print 'Hello world!'

class Test(Frame):
text = 'Testing'
num = 1
def do_xy(self, x, y):
x, y = self.tk.getint(x), self.tk.getint(y)
print (x,y)
def do_test(self):
self.text = self.text + ' ' + `self.num`
self.num = self.num + 1
self.test['text'] = self.text
def __init__(self, master):
Frame.__init__(self, master)
self['bd'] = 30
self.pack()
self.bind('<Motion>', self.do_xy, ('%x', '%y'))
self.hello = Button(self)
self.hello['text'] = 'Hello'
self.hello['command'] = do_hello
Pack.setitem(self.hello, 'fill', 'both')
self.hello.pack()
self.test = Button(self)
self.test['text'] = self.text
self.test['command'] = self.do_test
Pack.setitem(self.test, 'fill', 'both')
self.test.pack()

m = Tk()
test = Test(m)
##################################################

If somebody wants to test/use Tkinter drop me a note, and I'll
email the source.

-sl