@@ -31,6 +31,8 @@ namespace matplotlibcpp {
31
31
32
32
struct _interpreter {
33
33
PyObject *s_python_function_show;
34
+ PyObject *s_python_function_draw;
35
+ PyObject *s_python_function_pause;
34
36
PyObject *s_python_function_save;
35
37
PyObject *s_python_function_figure;
36
38
PyObject *s_python_function_plot;
@@ -105,6 +107,8 @@ namespace matplotlibcpp {
105
107
if (!pylabmod) { throw std::runtime_error (" Error loading module pylab!" ); }
106
108
107
109
s_python_function_show = PyObject_GetAttrString (pymod, " show" );
110
+ s_python_function_draw = PyObject_GetAttrString (pymod, " draw" );
111
+ s_python_function_pause = PyObject_GetAttrString (pymod, " pause" );
108
112
s_python_function_figure = PyObject_GetAttrString (pymod, " figure" );
109
113
s_python_function_plot = PyObject_GetAttrString (pymod, " plot" );
110
114
s_python_function_fill_between = PyObject_GetAttrString (pymod, " fill_between" );
@@ -125,6 +129,8 @@ namespace matplotlibcpp {
125
129
s_python_function_tight_layout = PyObject_GetAttrString (pymod, " tight_layout" );
126
130
127
131
if ( !s_python_function_show
132
+ || !s_python_function_draw
133
+ || !s_python_function_pause
128
134
|| !s_python_function_figure
129
135
|| !s_python_function_plot
130
136
|| !s_python_function_fill_between
@@ -146,6 +152,8 @@ namespace matplotlibcpp {
146
152
) { throw std::runtime_error (" Couldn't find required function!" ); }
147
153
148
154
if ( !PyFunction_Check (s_python_function_show)
155
+ || !PyFunction_Check (s_python_function_draw)
156
+ || !PyFunction_Check (s_python_function_pause)
149
157
|| !PyFunction_Check (s_python_function_figure)
150
158
|| !PyFunction_Check (s_python_function_plot)
151
159
|| !PyFunction_Check (s_python_function_fill_between)
@@ -651,6 +659,30 @@ namespace matplotlibcpp {
651
659
Py_DECREF (res);
652
660
}
653
661
662
+ inline void draw ()
663
+ {
664
+ PyObject* res = PyObject_CallObject (
665
+ detail::_interpreter::get ().s_python_function_draw ,
666
+ detail::_interpreter::get ().s_python_empty_tuple );
667
+
668
+ if (!res) throw std::runtime_error (" Call to draw() failed." );
669
+
670
+ Py_DECREF (res);
671
+ }
672
+
673
+ template <typename Numeric>
674
+ void pause (Numeric interval)
675
+ {
676
+ PyObject* args = PyTuple_New (1 );
677
+ PyTuple_SetItem (args, 0 , PyFloat_FromDouble (interval));
678
+
679
+ PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_pause , args);
680
+ if (!res) throw std::runtime_error (" Call to pause() failed." );
681
+
682
+ Py_DECREF (args);
683
+ Py_DECREF (res);
684
+ }
685
+
654
686
inline void save (const std::string& filename)
655
687
{
656
688
PyObject* pyfilename = PyString_FromString (filename.c_str ());
0 commit comments