Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shows an error popup if there is no TTS #38

Merged
merged 2 commits into from
Mar 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()