473,396 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

interactive programe-pyTTS &Tk

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.

class MyApp:
def __init__(self, parent):
self.myContainer1 = Frame(parent)
self.myContainer1.pack()

self.button1 = Button(self.myContainer1)
self.button1 ["text"] = "Hi Molly!" ### (1)
self.button1["background"] = "green" ### (1)
tts = pyTTS.Create()
tts.Speak ('hello molly')
self.button1.pack()

self.button2 = Button(self.myContainer1)
self.button2.configure(text="Connor!") ### (2)
self.button2.configure(background="tan") ### (2)
self.button2.pack()
self.button3 = Button(self.myContainer1)
self.button3.configure(text="Nige", background="cyan") ### (3)
self.button3.pack()

self.button4 = Button(self.myContainer1, text="Carmel!", background="red")
### (4)
self.button4.pack()
def button1Click(self, event): ### (3)
tts = pyTTS.Create()
if self.button1:
self.button1["background"] = "yellow"
tts.Speak('Hello Molly.') ### (4)
else:
self.button1["background"] = "green"
root = Tk()
myapp = MyApp(root)
root.mainloop()
#"""<tt060.py
Sep 24 '06 #1
1 1433
Nigel wrote in news:ma**************************************@pyth on.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/
Sep 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matthew Wilson | last post by:
Hi - I wrote this program: import Tkinter root = Tkinter.Tk() root.title('tkfun is tktastic!') cc = Tkinter.Canvas(root, width=400, height=400, bg="white")
16
by: Ali | last post by:
I have a the list: info = , , ] I want this info to show on a tk window like this: |--|------------------------| |TK|Blah |
0
by: cm012b5105 | last post by:
Hello i want to put an interactive text programme in to a graphical box this is a small section of my text programme s = raw_input ("Hello whats your name? ") if s=='melvyn': print "your my...
7
by: B.G.R. | last post by:
Hi all, I'm working on an interpreter for a university subject, which is programmed in python under linux. I got most of the work done and I'm just trying to settle some problems I've found on...
2
by: Charles Krug | last post by:
List: I'm trying to us pylab to see what I'm doing with some DSP algorithms, in case my posts about convolution and ffts weren't giving it away. I've been using pylab's plot function, but I'm...
3
by: DGG | last post by:
I have got a question arsing from my perl program. Basically, I want to get the machine date and time, and display it on a Tk label. I am using ActivePerl, and running on DOS/Windows. So I...
1
by: cm012b5105 | last post by:
Hello i am fairly new to python, I have written an interactive programme a small example of it is here. s = raw_input ("Do you have any children? ") if s== 'yes': print "Thats great" elif...
2
by: nigel | last post by:
Hello i have been working on an interactive programme,i wish to use a small amount of Tk.Which i have taken from a tutorial. from Tkinter import * root = Tk() w =Label(root, text="Congratulations...
1
by: nigel | last post by:
somebody recently showed me how to create a new line using \n which was great.The thing is when i am creating the programme the text i wish to add is quite long.and it ends up stretching the width...
5
by: linuxnow | last post by:
I don't know what I'm doing wrong, but the result is that _import_ only works from a python shell, but not when I call a python script. $ cat test.py mod = __import__("/home/me/tests/test_imp")...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.