Esempio n. 1
0
	def OnNext(self, event):
		'''
		When you press the "Next" button:
		- a new minimal pair is chosen randomly
		- the buttons are relabelled with the new words
		- the buttons' background colour is reset to neutral (grey)
		- the sound is played
		'''
		# allow the user to answer
		if self.pendingAnswer == False:
			self.pendingAnswer = True # this variable stops people from being able to answer the same question many times (by pressing a key)
			
			# reset the background colour of the buttons
			self.moo.SetBackgroundColour(wx.NullColour)
			self.quack.SetBackgroundColour(wx.NullColour)
			
			# Take a random sample, and store it
			filename, item_1, item_2, answer = random.choice(self.items)
			self.file = pyphon.filepath(filename)
			self.options = [item_1, item_2]
			self.answer = answer
			print(self.file)
			print(self.options)
			print(self.answer)
			assert len(self.options) == 2
			
			# Relabel the buttons
			self.moo.Label = self.options[0]
			self.quack.Label = self.options[1]
			self.moo.Enable()
			self.quack.Enable()
			self.next.Label = "Play again"
		
		# Play the file
		wx.Sound(self.file).Play()
Esempio n. 2
0
	def OnNext(self, event):
		# allow the user to answer
		self.pendingAnswer = True
		
		# Take a random sample, and store it
		filename, item_1, item_2, answer = random.choice(self.items)
		self.file = pyphon.filepath(filename)
		self.options = [item_1, item_2]
		self.answer = answer
		print(self.file)
		print(self.options)
		print(self.answer)
		assert len(self.options) == 2
		
		# Relabel the buttons
		self.moo.Label = self.options[0]
		self.quack.Label = self.options[1]
		self.moo.Show()
		self.quack.Show()
		self.feedback.Label = ""
		self.next.Hide()
		
		# Play the file
		wx.Sound(self.file).Play()
Esempio n. 3
0
	def OnPlay(self, event):
		'''Plays the sound file from the selected row.'''
		filename = self.GetFocusedText(0)
		filename = pyphon.filepath(filename)
		wx.Sound(filename).Play()