Skip to content

Commit 64af9f7

Browse files
committed
Added QwtPlotItem.setIcon and QwtPlotItem.icon
Methods for setting and getting the icon associated to the plot item
1 parent 4b00c76 commit 64af9f7

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

qwt/plot.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1731,6 +1731,7 @@ def __init__(self):
17311731
self.yAxis = QwtPlot.yLeft
17321732
self.legendIconSize = QSize(8, 8)
17331733
self.title = None # QwtText
1734+
self.icon = None
17341735

17351736

17361737
class QwtPlotItem(object):
@@ -1813,7 +1814,7 @@ class QwtPlotItem(object):
18131814
# enum RenderHint
18141815
RenderAntialiased = 0x1
18151816

1816-
def __init__(self, title=None):
1817+
def __init__(self, title=None, icon=None):
18171818
"""title: QwtText"""
18181819
if title is None:
18191820
title = QwtText("")
@@ -1822,6 +1823,7 @@ def __init__(self, title=None):
18221823
assert isinstance(title, QwtText)
18231824
self.__data = QwtPlotItem_PrivateData()
18241825
self.__data.title = title
1826+
self.__data.icon = icon
18251827

18261828
def attach(self, plot):
18271829
"""
@@ -1938,6 +1940,29 @@ def title(self):
19381940
"""
19391941
return self.__data.title
19401942

1943+
def setIcon(self, icon):
1944+
"""
1945+
Set item icon
1946+
1947+
:param icon: Icon
1948+
:type icon: QIcon
1949+
1950+
.. seealso::
1951+
1952+
:py:meth:`icon()`
1953+
"""
1954+
self.__data.icon = icon
1955+
1956+
def icon(self):
1957+
"""
1958+
:return: Icon of the item
1959+
1960+
.. seealso::
1961+
1962+
:py:meth:`setIcon()`
1963+
"""
1964+
return self.__data.icon
1965+
19411966
def setItemAttribute(self, attribute, on=True):
19421967
"""
19431968
Toggle an item attribute

0 commit comments

Comments
 (0)