#!/usr/bin/env python
def __init__(self, helper):
super(TicTacToe, self).__init__()
self.
mypixmap = QPixmap("exit.png")
def paint(self, painter, option, widget):
self.painte.setOpacity(0.1)
self.painte.drawPixmap(0,0, 300, 300, self.mypixmap)
def boundingRect(self):
def __init__(self):
super(MyGraphicsView, self).__init__()
self.tic_tac_toe = TicTacToe(self)
scene.addItem(self.tic_tac_toe)
scene.addPixmap(self.tic_tac_toe)
self.setScene(scene)
def __init__(self):
super(Example, self).__init__()
self.y = MyGraphicsView()
self.setCentralWidget(self.y)
if __name__ == '__main__':
import sys
w = Example()
w.show()
sys.exit(app.exec_())
#!/usr/bin/env python
from PyQt5.QtCore import (QLineF, QPointF, QRectF, pyqtSignal)
from PyQt5.QtGui import (QIcon, QBrush, QColor, QPainter, QPixmap)
from PyQt5.QtWidgets import (QAction, QMainWindow, QApplication, QGraphicsObject, QGraphicsView, QGraphicsScene, QGraphicsItem,
QGridLayout, QVBoxLayout, QHBoxLayout,
QLabel, QLineEdit, QPushButton)
class TicTacToe(QGraphicsItem):
def __init__(self, helper):
super(TicTacToe, self).__init__()
self.mypixmap = QPixmap("exit.png")
self.painte = QPainter()
def paint(self, painter, option, widget):
self.painte.setOpacity(0.1)
self.painte.drawPixmap(0,0, 300, 300, self.mypixmap)
def boundingRect(self):
return QRectF(0,0,300,300)
class MyGraphicsView(QGraphicsView):
def __init__(self):
super(MyGraphicsView, self).__init__()
scene = QGraphicsScene(self)
self.tic_tac_toe = TicTacToe(self)
scene.addItem(self.tic_tac_toe)
scene.addPixmap(self.tic_tac_toe)
self.setScene(scene)
class Example(QMainWindow):
def __init__(self):
super(Example, self).__init__()
self.y = MyGraphicsView()
self.setCentralWidget(self.y)
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
w = Example()
w.show()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
Bookmarks