Skip to content

Commit 23b525e

Browse files
committed
Fixes #63: stylesheet issue with PySide
1 parent bb63b5b commit 23b525e

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

qwt/plot_canvas.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
QPolygonF,
3333
)
3434
from qtpy.QtWidgets import QFrame, QStyleOption, QStyle
35-
from qtpy.QtCore import Qt, QSizeF, QEvent, QPointF, QRectF
35+
from qtpy.QtCore import Qt, QSizeF, QEvent, QPointF, QRectF, QRect
3636
from qtpy import QtCore as QC
3737

3838

@@ -81,8 +81,17 @@ def updateState(self, state):
8181
self.__origin = state.brushOrigin()
8282

8383
def drawRects(self, rects, count):
84-
for i in range(count):
85-
self.border.rectList += [rects[i]]
84+
if QT_API.startswith("pyside"):
85+
# Pyside
86+
if isinstance(rects, (QRect, QRectF)):
87+
self.border.list = [rects]
88+
else:
89+
for i in range(count):
90+
self.border.rectList += [rects.getRect().index(i)]
91+
else:
92+
# PyQt
93+
for i in range(count):
94+
self.border.rectList += [rects[i]]
8695

8796
def drawPath(self, path):
8897
rect = QRectF(QPointF(0.0, 0.0), self.__size)

qwt/tests/data/stylesheet.png

13.1 KB
Loading

qwt/tests/stylesheet.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
3+
SHOW = True # Show test in GUI-based test launcher
4+
5+
import numpy as np
6+
from qtpy.QtCore import Qt
7+
8+
import qwt
9+
10+
11+
class StyleSheetPlot(qwt.QwtPlot):
12+
def __init__(self):
13+
super().__init__()
14+
self.setTitle("Stylesheet test (Issue #63)")
15+
self.setStyleSheet("background-color: #19232D; color: #E0E1E3;")
16+
qwt.QwtPlotGrid.make(self, color=Qt.white, width=0, style=Qt.DotLine)
17+
x = np.arange(-5.0, 5.0, 0.1)
18+
qwt.QwtPlotCurve.make(x, np.sinc(x), "y = sinc(x)", self, linecolor="green")
19+
20+
21+
if __name__ == "__main__":
22+
from qwt import tests
23+
24+
tests.test_widget(StyleSheetPlot, size=(600, 400))

0 commit comments

Comments
 (0)