Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
labcode
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CST
labcode
Commits
3ead7308
Commit
3ead7308
authored
1 month ago
by
Alexandros Asonitis
Browse files
Options
Downloads
Patches
Plain Diff
toolbar added
parent
f98742e7
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
hp4194/cv_qt_inteface.py
+28
-4
28 additions, 4 deletions
hp4194/cv_qt_inteface.py
with
28 additions
and
4 deletions
hp4194/cv_qt_inteface.py
+
28
−
4
View file @
3ead7308
...
...
@@ -6,11 +6,13 @@ os.environ["QT_API"] = "PyQt6"
from
PyQt6.QtWidgets
import
*
from
matplotlib.backends.backend_qtagg
import
FigureCanvasQTAgg
from
matplotlib.figure
import
Figure
import
random
from
PyQt6.QtGui
import
QAction
class
MplCanvas
(
FigureCanvasQTAgg
):
def
__init__
(
self
,
parent
=
None
,
width
=
5
,
height
=
4
,
dpi
=
100
):
fig
=
Figure
(
figsize
=
(
width
,
height
),
dpi
=
dpi
)
self
.
axes
=
fig
.
add_
subplot
(
111
)
self
.
axes
=
fig
.
subplot
s
(
nrows
=
2
,
ncols
=
3
)
super
().
__init__
(
fig
)
class
MainWinow
(
QMainWindow
):
...
...
@@ -190,15 +192,37 @@ class MainWinow(QMainWindow):
self
.
app_grid
.
addWidget
(
self
.
sweep
,
2
,
0
)
# add the plot below
sc
=
MplCanvas
(
self
,
width
=
10
,
height
=
8
,
dpi
=
100
)
sc
.
axes
.
plot
([
0
,
1
,
2
,
3
,
4
],[
10
,
1
,
20
,
3
,
40
])
self
.
sc
=
MplCanvas
(
self
,
width
=
15
,
height
=
9
,
dpi
=
100
)
self
.
app_grid
.
addWidget
(
sc
,
0
,
1
,
3
,
1
)
self
.
xdata
=
list
(
range
(
20
))
for
i
in
range
(
2
):
for
j
in
range
(
3
):
self
.
sc
.
axes
[
i
,
j
].
plot
(
self
.
xdata
,
random
.
sample
(
range
(
50
),
20
))
toolbar
=
QToolBar
(
"
Toolbar
"
)
self
.
addToolBar
(
toolbar
)
button_action
=
QAction
(
"
start measurement
"
,
self
)
button_action
.
triggered
.
connect
(
self
.
toolbar_button_clicked
)
toolbar
.
addAction
(
button_action
)
self
.
app_grid
.
addWidget
(
self
.
sc
,
0
,
1
,
3
,
1
)
self
.
widget
.
setLayout
(
self
.
app_grid
)
self
.
setCentralWidget
(
self
.
widget
)
self
.
showMaximized
()
def
toolbar_button_clicked
(
self
):
self
.
xdata
=
list
(
range
(
20
))
for
i
in
range
(
2
):
for
j
in
range
(
3
):
self
.
sc
.
axes
[
i
,
j
].
cla
()
# Clear the canvas.
self
.
sc
.
axes
[
i
,
j
].
plot
(
self
.
xdata
,
random
.
sample
(
range
(
50
),
20
))
# Trigger the canvas to update and redraw.
self
.
sc
.
draw
()
app
=
QApplication
(
sys
.
argv
)
w
=
MainWinow
()
app
.
exec
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment