- Joined
- Sep 24, 2006
- Messages
- 1
- Reaction score
- 0
Hi i have created 4 buttons using Tk what i want is when i press lets say button 1 you here "hello molly" this is my code so far.
from Tkinter import *
import pyTTS
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()
#can anybody give me some guidance on this please.
from Tkinter import *
import pyTTS
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()
#can anybody give me some guidance on this please.