Skip to content

Instantly share code, notes, and snippets.

@eyllanesc
Created July 24, 2018 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eyllanesc/8ec9ec1468ae13ce2b7bf842bb299f35 to your computer and use it in GitHub Desktop.
Save eyllanesc/8ec9ec1468ae13ce2b7bf842bb299f35 to your computer and use it in GitHub Desktop.
test.py
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
class PicButton(QAbstractButton):
def __init__(self, pixmap, parent=None):
super(PicButton, self).__init__(parent)
self.pixmap = pixmap
def paintEvent(self, event):
painter = QPainter(self)
painter.drawPixmap(QPoint(), self.pixmap)
def sizeHint(self):
return self.pixmap.size()
def close():
print("xxx")
app = QApplication(sys.argv)
window = QWidget()
window.setFixedSize(740, 850) #window size.
button = PicButton(QPixmap("thinking.png"), window)
button.clicked.connect(close)
button.move(100, 100)
window.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment