File: qt_sink_c_python.cc

package info (click to toggle)
gr-fosphor 3.9~git20240323.74d54fc-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,268 kB
  • sloc: python: 9,483; ansic: 3,422; cpp: 1,281; lisp: 609; makefile: 33
file content (61 lines) | stat: -rw-r--r-- 1,168 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * Copyright 2013-2021 Sylvain Munaut <tnt@246tNt.com>
 *
 * This file is part of gr-fosphor
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include <pybind11/complex.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

namespace py = pybind11;

#include <QWidget>

#include <gnuradio/fosphor/qt_sink_c.h>

#define D(...) ""

void bind_qt_sink_c(py::module& m)
{
	using qt_sink_c = gr::fosphor::qt_sink_c;

	py::class_<qt_sink_c,
		gr::fosphor::base_sink_c,
		gr::sync_block,
		gr::block,
		gr::basic_block,
		std::shared_ptr<qt_sink_c>>(m, "qt_sink_c", D(qt_sink_c))

		.def(py::init(&qt_sink_c::make),
			py::arg("parent") = nullptr,
			D(qt_sink_c,make)
		)

		.def("exec_",
			&qt_sink_c::exec_,
			D(qt_sink_c, exec_)
		)

		.def("qwidget",
			&qt_sink_c::qwidget,
			D(qt_sink_c, qwidget)
		)

		//.def("pyqwidget",
		//	&qt_sink_c::pyqwidget,
		//	D(qt_sink_c, pyqwidget)
		//)
		// For the sip conversion to python to work, the widget object
		// needs to be explicitly converted to long long.
		.def("pyqwidget",
			[](std::shared_ptr<qt_sink_c> p) {
				return PyLong_AsLongLong(p->pyqwidget());
				},
			D(qt_sink_c, pyqwidget)
		)

		;
}