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

[SOLVED] PyQt button with an image on it

$
0
0
I’m making a button that sends an email, it’s all working, but I want to change the size of the button and put an image on it, what lines would I add to my code and where? =] from PyQt4 import QtGui, QtCore   import smtplib   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)         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_())

Viewing all articles
Browse latest Browse all 13965

Trending Articles