MCPcopy Create free account
hub / github.com/ActiveState/code / __init__

Method __init__

recipes/Python/167487_Windows_SAPI4/recipe-167487.py:173–255  ·  view source on GitHub ↗
(self, dialog)

Source from the content-addressed store, hash-verified

171
172class ExampleSapi:
173 def __init__(self, dialog):
174
175 self.dialog = dialog
176 dialog.title("Voice Settings")
177 self.sapi = Sapi4()
178 self.frame_dialog = Frame(dialog, height=500)
179 self.frame_dialog.pack(side=TOP, expand=NO, fill=BOTH)
180
181 #buttons
182 frame_button = Frame(dialog)
183 frame_button.pack(side=BOTTOM, expand=NO, fill=X)
184 button = Button(frame_button, text='Close', command=dialog.destroy, width=10, foreground='DarkRed')
185 button.pack(side=RIGHT, padx=2, pady=2)
186 button = Button(frame_button, text='Test', command=self.test, width=10, foreground='DarkBlue')
187 button.pack(side=RIGHT, padx=2, pady=2)
188
189 frame_left = Frame(self.frame_dialog)
190 frame_left.pack(side=TOP, expand=YES, fill=BOTH)
191
192 scrollbar = Scrollbar(frame_left, orient=VERTICAL)
193 self.listbox = Listbox(frame_left, yscrollcommand=scrollbar.set, exportselection=0, font="Arial 10")
194 scrollbar.config(command=self.listbox.yview)
195 scrollbar.pack(side=RIGHT, fill=Y)
196 for item in self.sapi.voice_list:
197 self.listbox.insert(END, item)
198 self.listbox.pack(side=LEFT, padx=2, pady=2, expand=YES, fill=BOTH)
199 self.listbox.select_set(self.sapi.voice_index)
200 self.listbox.see(self.sapi.voice_index)
201
202 #settings frame
203 frame_right = Frame(self.frame_dialog)
204 frame_right.pack(side=TOP, expand=NO, fill=BOTH)
205
206 #speed
207 self.label_speed = Label(frame_right, text=" Speed:", font="Arial 10")
208 self.label_speed.grid(row=0, col=0, sticky=E, padx=2, pady=1)
209 self.scale_speed = Scale(frame_right, length=300, orient='horizontal', command=self.sapi.setSpeed, showvalue=0)
210 self.scale_speed.grid(row=0, column=1, sticky=W, padx=2, pady=1)
211 self.label_speed_percent = Label(frame_right, textvariable=self.sapi.SpeedPercent, width=5)
212 self.label_speed_percent.grid(row=0, column=2, sticky=W, padx=2, pady=1)
213
214 #pitch
215 self.label_pitch = Label(frame_right, text=" Pitch:", font="Arial 10")
216 self.label_pitch.grid(row=1, column=0, sticky=E, padx=2, pady=1)
217 self.scale_pitch = Scale(frame_right, length=300, orient='horizontal', command=self.sapi.setPitch, showvalue=0)
218 self.scale_pitch.grid(row=1, column=1, sticky=W, padx=2, pady=1)
219 self.label_pitch_percent = Label(frame_right, textvariable=self.sapi.PitchPercent, width=5)
220 self.label_pitch_percent.grid(row=1, column=2, sticky=W, padx=2, pady=1)
221
222 #volume left
223 self.label_volume_left = Label(frame_right, text=" Volume:", font="Arial 10")
224 self.label_volume_left.grid(row=2, column=0, sticky=E, padx=2, pady=1)
225 self.scale_volume_left = Scale(frame_right, length=300, orient='horizontal', command=self.sapi.setVolumeLeft, showvalue=0)
226 self.scale_volume_left.grid(row=2, column=1, sticky=W, padx=2, pady=1)
227 self.label_volume_left_percent = Label(frame_right, textvariable=self.sapi.VolumeLeftPercent, width=5)
228 self.label_volume_left_percent.grid(row=2, column=2, sticky=W, padx=2, pady=1)
229
230 #volume right - does not appear to work

Callers

nothing calls this directly

Calls 15

drawFaceMethod · 0.95
setVoiceMethod · 0.95
centerMeMethod · 0.95
Sapi4Class · 0.85
ListboxClass · 0.85
LabelClass · 0.85
ScaleClass · 0.85
FrameClass · 0.50
ButtonClass · 0.50
ScrollbarClass · 0.50
EntryClass · 0.50
titleMethod · 0.45

Tested by

no test coverage detected