-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
graphicspixmapwidget: PyQt6 compatibility
- Loading branch information
1 parent
2ff5d9e
commit 85b83db
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from AnyQt.QtCore import Qt, QSize, QSizeF | ||
from AnyQt.QtGui import QPixmap | ||
from AnyQt.QtWidgets import QGraphicsScene, QGraphicsView | ||
|
||
from orangewidget.tests.base import GuiTest | ||
from Orange.widgets.utils.graphicspixmapwidget import GraphicsPixmapWidget | ||
|
||
|
||
class TestGraphicsPixmapWidget(GuiTest): | ||
def setUp(self) -> None: | ||
super().setUp() | ||
self.scene = QGraphicsScene() | ||
self.view = QGraphicsView(self.scene) | ||
|
||
def tearDown(self) -> None: | ||
self.scene.clear() | ||
self.scene.deleteLater() | ||
self.view.deleteLater() | ||
del self.scene | ||
del self.view | ||
|
||
def test_graphicspixmapwidget(self): | ||
w = GraphicsPixmapWidget() | ||
self.scene.addItem(w) | ||
w.setPixmap(QPixmap(100, 100)) | ||
p = w.pixmap() | ||
self.assertEqual(p.size(), QSize(100, 100)) | ||
self.view.grab() | ||
w.setScaleContents(True) | ||
w.setAspectRatioMode(Qt.KeepAspectRatio) | ||
s = w.sizeHint(Qt.PreferredSize) | ||
self.assertEqual(s, QSizeF(100., 100.)) | ||
s = w.sizeHint(Qt.PreferredSize, QSizeF(200., -1.)) | ||
self.assertEqual(s, QSizeF(200., 200.)) | ||
s = w.sizeHint(Qt.PreferredSize, QSizeF(-1., 200.)) | ||
self.assertEqual(s, QSizeF(200., 200.)) | ||
self.view.grab() |