I use python3.5, and I made a GUI with pyqt5. In that GUI, when I push the button, I can play back a music with wav file. This is the code.
import sys
from PyQt5 import QtCore, QtWidgets, QtMultimedia
from PyQt5.QtGui import QColor
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class Window(QtWidgets.QWidget):
def __init__(self):
super(Window, self).__init__()
self.setWindowTitle("sound")
self.setGeometry(500,300,100,100)
btn = QPushButton(self)
btn.setIcon(self.style().standardIcon(getattr(QStyle,"SP_MediaPlay")))
btn.setToolTip('音が出ます')
btn.move(50, 25)
btn.clicked.connect(self.handlePlay)
self.mediaPlayer = QtMultimedia.QMediaPlayer(self)
sound=QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile("Magia.wav"))
self.mediaPlayer.setMedia(sound)
self.show()
def handlePlay(self):
self.mediaPlayer.stop()
self.mediaPlayer.play()
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
window = Window()
sys.exit(app.exec_())
By this code, you can make a GUI like this.
When you push the button, you can play back a music which is wav file. And I changed this python code into exe file by pyinstaller. But in the exe file, when I push the button, nothing happens. My OS environment is windows8.1 and 64bits.