mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
bazaar: PyCon: ToStdErr fix, now shows error messages in console window; BoostPyTest: embedding SliderCtrl testcase
git-svn-id: svn://ultimatepp.org/upp/trunk@3336 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
eb05c98dde
commit
ead226b9b2
4 changed files with 58 additions and 14 deletions
|
|
@ -1,18 +1,15 @@
|
|||
#include "BoostPyTest.h"
|
||||
|
||||
BOOST_PYTHON_MODULE(hello)
|
||||
{
|
||||
class_<World>("World")
|
||||
.def("greet", &World::greet)
|
||||
.def("set", &World::set)
|
||||
;
|
||||
}
|
||||
|
||||
BoostPyTest::BoostPyTest()
|
||||
: slpy(sl)
|
||||
{
|
||||
CtrlLayout(*this, "Boost Test");
|
||||
|
||||
int ret = PyImport_AppendInittab( "hello", &inithello );
|
||||
//bool b = Py_IsInitialized();
|
||||
|
||||
int ret;
|
||||
ret = PyImport_AppendInittab( "hello", &inithello );
|
||||
ret = PyImport_AppendInittab( "UppCtrl", &initUppCtrl );
|
||||
|
||||
//Py_Initialize(); //should be done *after* PyImport_AppendInittab, but it still works :), leaving INITBLOCK from Py
|
||||
//PyCon::Init();
|
||||
|
|
@ -33,11 +30,23 @@ BoostPyTest::BoostPyTest()
|
|||
//so better do it in python code
|
||||
main_namespace["hello"] = hello_module;
|
||||
|
||||
w.set("Welcom on earth");
|
||||
scope(hello_module).attr("earth") = ptr(&w);
|
||||
|
||||
slpy.Set(50);
|
||||
object ctrl_module(handle<>(PyImport_ImportModule("UppCtrl")));
|
||||
main_namespace["UppCtrl"] = ctrl_module;
|
||||
scope(ctrl_module).attr("sl") = ptr(&slpy);
|
||||
|
||||
//the additional import is needless
|
||||
String sc =
|
||||
"import hello\n"
|
||||
"p = hello.World()\n"
|
||||
"p.set('Some Greet Text')\n"
|
||||
"print p.greet()\n"
|
||||
|
||||
"print UppCtrl.sl.get()\n"
|
||||
"UppCtrl.sl.set(23)\n"
|
||||
;
|
||||
con.cmd.SetData(sc);
|
||||
} catch( error_already_set ) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue