def tap(self, keycode, character, press): """Parent class PyKeyboardEvent call this method when user tap keyboard key. See PyUserInput documentation for parameter meaning. """ give_name2thread('keyboard_event_thread', self) self.notify_if_should()
def run(self): """Plays sound. Note: calling this function directly will call it in current thread. So current thread will wait while sound is playing. You might want to call it using .start() function - then it will be called in separate thread """ give_name2thread('playing_song_' + self._sound_path, self) with wave.open(self._sound_path, 'rb') as sound_file: stream = pyaudio_obj.open( format=pyaudio_obj.get_format_from_width( sound_file.getsampwidth() ), channels=sound_file.getnchannels(), rate=sound_file.getframerate(), output=True ) data = sound_file.readframes(CHUNK) while len(data): stream.write(data) data = sound_file.readframes(CHUNK) stream.stop_stream() stream.close()
def run(self): """Plays endless beeps. Note: calling this function directly will call it in current thread. So current thread will wait while sound is playing. You might want to call it using .start() function - then it will be called in separate thread """ give_name2thread('infinity_beep_th', self) self.stoprequest.clear() # if stopped before, clear while not self.stoprequest.is_set(): self._player.run() # call and wait sleep(2)
def run(self): """Plays sound. Note: calling this function directly will call it in current thread. So current thread will wait while sound is playing. You might want to call it using .start() function - then it will be called in separate thread """ give_name2thread('playing_song_' + self._sound_path, self) with wave.open(self._sound_path, 'rb') as sound_file: stream = pyaudio_obj.open(format=pyaudio_obj.get_format_from_width( sound_file.getsampwidth()), channels=sound_file.getnchannels(), rate=sound_file.getframerate(), output=True) data = sound_file.readframes(CHUNK) while len(data): stream.write(data) data = sound_file.readframes(CHUNK) stream.stop_stream() stream.close()
def move(self, x, y): """Parent class PyMouseEvent call this method when user move mouse.""" give_name2thread('mouse_event_thread', self) self.notify_if_should()
or 2) Source of file and file usage rules (for moonOnBlue256.png) """ import sys import threading import os from PyQt4 import QtGui, QtCore # other programs module from common_qt_app.helpers import give_name2thread from reminders_modules.tray import TrayController if __name__ == '__main__': give_name2thread('main_reminder_thread', threading.current_thread()) app = QtGui.QApplication(sys.argv) # start GUI Application and give args # load translations translator = QtCore.QTranslator(app) translator.load(os.path.join( sys.path[0], 'i18n', 'reminder_%s.qm' % QtCore.QLocale().name() )) app.installTranslator(translator) # set icon used in taskbar, when settings opened app_icon = QtGui.QIcon(os.path.join( sys.path[0],