Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

[SOLVED}Making noises when buttons get pushed.

$
0
0
I want to get a button to make a noise when it gets pushed so I know it’s sent an email, someone previously told me I need Phonon, but I can’t find it anywhere, is there any other way of doing it that doesn’t require additional modules? This is the script I’ve got so far from PyQt4 import QtGui, QtCore   import smtplib import wave   from email.mime.text import MIMEText   class Window(QtGui.QWidget):     def __init__(self):         QtGui.QWidget.__init__(self)         self.button = QtGui.QPushButton('', self)         self.button.clicked.connect(self.handleButton)         self.button.setIcon(QtGui.QIcon("./z.jpg"))         self.button.setIconSize(QtCore.QSize(300,250))         layout = QtGui.QVBoxLayout(self)         layout.addWidget(self.button)       def handleButton(self):         fp = open('Firetruck.txt', 'r')         msg = MIMEText(fp.read())         fp.close()           msg['Subject'] = 'Subject'         msg['From'] = 'ajames@brecon-hs.powys.sch.uk'         msg['To'] = 'swilliams@brecon-hs.powys.sch.uk'           s = smtplib.SMTP('BHS-MAIL')         s.send_message(msg)   if __name__ == '__main__':       import sys     app = QtGui.QApplication(sys.argv)     window = Window()     window.show()     sys.exit(app.exec_()) I’m assuming the code for the sound goes under      def handleButton(self): Right?

Viewing all articles
Browse latest Browse all 13965

Trending Articles