from
PyQt5.QtWidgets
import
*
import
sys
import
pyqtgraph as pg
from
PyQt5.QtGui
import
*
class
BarGraphItem(pg.BarGraphItem):
def
__init__(
self
,
*
args,
*
*
kwargs):
pg.BarGraphItem.__init__(
self
,
*
args,
*
*
kwargs)
def
viewChanged(
self
, view, oldView):
print
(view)
class
Window(QMainWindow):
def
__init__(
self
):
super
().__init__()
self
.setWindowTitle(
"PyQtGraph"
)
self
.setGeometry(
100
,
100
,
600
,
500
)
icon
=
QIcon(
"skin.png"
)
self
.setWindowIcon(icon)
self
.UiComponents()
self
.show()
def
UiComponents(
self
):
widget
=
QWidget()
plot
=
pg.plot()
y1
=
[
5
,
5
,
7
,
10
,
3
,
8
,
9
,
1
,
6
,
2
]
x
=
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
]
bargraph
=
BarGraphItem(x
=
x, height
=
y1, width
=
0.6
, brush
=
'g'
)
plot.addItem(bargraph)
layout
=
QGridLayout()
widget.setLayout(layout)
layout.addWidget(plot,
0
,
1
,
3
,
1
)
self
.setCentralWidget(widget)
App
=
QApplication(sys.argv)
window
=
Window()
sys.exit(App.
exec
())