Skip to content

Commit

Permalink
Merge pull request #38 from trivedigaurav/tts_example
Browse files Browse the repository at this point in the history
Shows an error popup if there is no TTS
  • Loading branch information
brousch committed Mar 12, 2014
2 parents 2ad22ef + d73a3e2 commit edf2ffa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
12 changes: 10 additions & 2 deletions examples/text2speech/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@
from kivy.app import App
from kivy.properties import ObjectProperty
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.popup import Popup

from plyer import tts

class Text2SpeechDemo(BoxLayout):
def do_read(self):
tts.speak(self.ids.notification_text.text)
try:
tts.speak(self.ids.notification_text.text)
except NotImplementedError:
popup = ErrorPopup()
popup.open()

class Text2SpeechDemoApp(App):
def build(self):
return Text2SpeechDemo()

class ErrorPopup(Popup):
pass

if __name__ == '__main__':
Text2SpeechDemoApp().run()

20 changes: 19 additions & 1 deletion examples/text2speech/text2speechdemo.kv
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,22 @@
Button:
text: 'Read'
size_hint_y: 0.2
on_press: root.do_read()
on_press: root.do_read()

<ErrorPopup>:
size_hint: .7, .4
title: "Error"

BoxLayout:
orientation: 'vertical'
padding: 10
spacing: 20

Label:
size_hint_y: 0.4
text: "This feature has not yet been implemented in Plyer."
Button:
text: 'Dismiss'
size_hint_y: 0.4
on_press: root.dismiss()

0 comments on commit edf2ffa

Please sign in to comment.