May-06-2020, 12:02 PM
Hi,
I have the following code which I want to use to display a figure constructed out of circles.
Does anyone know what is causing the problem?
I have the following code which I want to use to display a figure constructed out of circles.
import sys
from PySide2 import QtGui, QtWidgets
class MainWindow(QtWidgets.QDialog):
def __init__(self):
super().__init__()
self.label = QtWidgets.QLabel()
canvas = QtGui.QPixmap(400, 300)
self.label.setPixmap(canvas)
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.label)
self.setLayout(self.layout)
self.draw_something()
def draw_something(self):
painter = QtGui.QPainter(self.label.pixmap())
painter.drawPoint(200, 150)
painter.end()
app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()However, the example shows a nice dot in the middle, see attachment (Example window.png). Whereas I get a black screen, see attachment (Error.png).Does anyone know what is causing the problem?
