Created
July 24, 2018 11:51
-
-
Save eyllanesc/8ec9ec1468ae13ce2b7bf842bb299f35 to your computer and use it in GitHub Desktop.
test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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