ultimatepp/bazaar/BoostPyTest/BoostPyTest.h
kohait 3679491ce2 bazaar: PyCon, PyConsoleCtrl: proper exit() python funciton handling, now exit handler can terminate gui app
git-svn-id: svn://ultimatepp.org/upp/trunk@3337 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2011-04-12 21:54:26 +00:00

61 lines
1.2 KiB
C++

#ifndef _BoostPyTest_BoostPyTest_h_
#define _BoostPyTest_BoostPyTest_h_
#include <PyConsoleCtrl/PyConsoleCtrl.h>
using namespace boost::python;
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct World
{
void set(std::string msg) { this->msg = msg; }
std::string greet() const { return msg; }
std::string msg;
};
BOOST_PYTHON_MODULE(hello)
{
scope().attr("__doc__") = "Hello module's docstring";
class_<World>("World", "A simple world")
.def("greet", &World::greet)
.def("set", &World::set)
;
}
struct SliderCtrlPy
{
SliderCtrlPy(SliderCtrl& o) : o(o) {}
void Set(const int& d) { o.SetData(d); }
int Get() const { return o.GetData(); }
SliderCtrl& o;
};
BOOST_PYTHON_MODULE(UppCtrl)
{
scope().attr("__doc__") = "ctrl module's docstring";
class_<SliderCtrlPy, boost::noncopyable>("SliderCtrlPy", "A SliderCtrl wrapper", no_init)
.def("get", &SliderCtrlPy::Get)
.def("set", &SliderCtrlPy::Set)
;
}
#define LAYOUTFILE <BoostPyTest/BoostPyTest.lay>
#include <CtrlCore/lay.h>
class BoostPyTest : public WithBoostPyTestLayout<TopWindow> {
public:
typedef BoostPyTest CLASSNAME;
BoostPyTest();
~BoostPyTest();
void ExitHandler();
World w;
SliderCtrlPy slpy;
};
#endif