interactive programe-pyTTS &Tk

Rob Williscroft rtw at freenet.co.uk
Sun Sep 24 20:53:21 CEST 2006


Nigel wrote in news:mailman.534.1159111835.10491.python-list at python.org
in comp.lang.python: 

> from Tkinter import *
> import pyTTS
> Hi i am trying to get a button so that when i click on it i hear a
> voice say "Hi Molly" this is my code so far.Can any one shed any light
> on this for please.
> Thanks Nige.

Your problem appears to be that you do not know how to associate
an action (the press of the button) with the code you want to run
( tts.Speak ('hello molly') ).


Tk buttions have a command attribute that is called when the button 
is clicked:

    self.button1[ 'command' ] = HelloMolly


Where HelloMolly is an already defined python callable, for example:

    def HelloMolly():
      self.tts.Speak ('hello molly')

The above defenition of HelloMolly requires that somtime before it
is called, self.tts is created:

    self.tts = pyTTS.Create()

HTH.

Rob.
-- 
http://www.victim-prime.dsl.pipex.com/



More information about the Python-list mailing list