FigureCanvasGTK4Agg
as
FigureCanvas
from
matplotlib.figure
import
def
on_activate
(
app
):
win
=
Gtk
.
ApplicationWindow
(
application
=
app
)
win
.
set_default_size
(
400
,
300
)
win
.
set_title
(
"Embedded in GTK4"
)
fig
=
(
figsize
=
(
5
,
4
),
dpi
=
100
)
ax
=
fig
.
add_subplot
()
t
=
(
0.0
,
3.0
,
0.01
)
s
=
(
2
*
*
t
)
ax
.
plot
(
t
,
s
)
sw
=
Gtk
.
ScrolledWindow
(
margin_top
=
10
,
margin_bottom
=
10
,
margin_start
=
10
,
margin_end
=
10
)
win
.
set_child
(
sw
)
canvas
=
FigureCanvas
(
fig
)
canvas
.
set_size_request
(
800
,
600
)
sw
.
set_child
(
canvas
)
win
.
present
()
app
=
Gtk
.
Application
(
application_id
=
'org.matplotlib.examples.EmbeddingInGTK4'
)
app
.
connect
(
'activate'
,
on_activate
)
app
.
run
(
None
)