Skip to content
Snippets Groups Projects
Commit 00e32e2f authored by stefan's avatar stefan
Browse files

New sip export for python shell

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2080 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent eb4a9b4a
No related branches found
No related tags found
No related merge requests found
......@@ -26,11 +26,11 @@ using namespace boost::python;
#include <ost/gui/gl_win.hh>
#include <ost/gui/perspective.hh>
#include <ost/gui/tools/tool_options_win.hh>
#include <ost/gui/python_shell/python_shell.hh>
#include "transfer_ownership.hh"
#include "sip_handler.hh"
#include "python_shell_proxy.hh"
#include "tool_options_win_proxy.hh"
#include "scene_win_proxy.hh"
#include "sequence_viewer_proxy.hh"
......@@ -44,11 +44,6 @@ using namespace ost::gui;
namespace {
PythonShellProxy app_get_py_shell(GostyApp* app)
{
return PythonShellProxy(app->GetPyShell());
}
ToolOptionsWinProxy app_get_tool_options_win(GostyApp* app)
{
return ToolOptionsWinProxy(app->GetToolOptionsWin());
......@@ -100,8 +95,10 @@ void export_Gosty()
.def("Instance", &GostyApp::Instance,
return_value_policy<reference_existing_object>()).staticmethod("Instance")
.def("SetAppTitle", &GostyApp::SetAppTitle)
.def("GetPyShell", &app_get_py_shell)
.add_property("py_shell", &app_get_py_shell)
.def("GetPyShell", &GostyApp::GetPyShell,
return_value_policy<reference_existing_object>())
.add_property("py_shell", make_function(&GostyApp::GetPyShell,
return_value_policy<reference_existing_object>()))
.def("GetGLWin", &GostyApp::GetGLWin,
return_value_policy<reference_existing_object>())
.add_property("gl_win", make_function(&GostyApp::GetGLWin,
......
......@@ -17,25 +17,36 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------
#include <boost/python.hpp>
#include <boost/python/register_ptr_to_python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
using namespace boost::python;
#include <iostream>
#include "python_shell_proxy.hh"
#include <ost/gui/python_shell/python_shell.hh>
#include <ost/gui/python_shell/python_shell_widget.hh>
#include "sip_handler.hh"
using namespace boost::python;
using namespace ost;
using namespace ost::gui;
namespace {
void pyshell_set_tab_width(PythonShell* py_shell, int width) {
py_shell->PyShell()->SetTabWidth(width);
}
int pyshell_get_tab_width(PythonShell* py_shell) {
return py_shell->PyShell()->GetTabWidth();
}
}
void export_PyShell()
{
class_<PythonShellProxy, bases<SipHandlerBase> >("PythonShell", no_init)
.def("Show", &PythonShellProxy::Show)
.def("Hide", &PythonShellProxy::Hide)
.def("SetTabWidth", &PythonShellProxy::SetTabWidth)
.def("GetTabWidth", &PythonShellProxy::GetTabWidth)
class_<PythonShell, boost::noncopyable>("PythonShell", no_init)
.def("Show", &PythonShell::show)
.def("Hide", &PythonShell::hide)
.def("SetTabWidth", &pyshell_set_tab_width)
.def("GetTabWidth", &pyshell_get_tab_width)
.def("GetQObject",&get_py_qobject<PythonShell>)
.add_property("qobject", &get_py_qobject<PythonShell>)
;
}
//------------------------------------------------------------------------------
// This file is part of the OpenStructure project <www.openstructure.org>
//
// Copyright (C) 2008-2010 by the OpenStructure authors
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation; either version 3.0 of the License, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------
#ifndef OST_GUI_PYTHON_SHELL_PROXY_HH
#define OST_GUI_PYTHON_SHELL_PROXY_HH
#include <ost/gui/python_shell/python_shell.hh>
#include <ost/gui/python_shell/python_shell_widget.hh>
#include "sip_handler.hh"
namespace ost { namespace gui {
class PythonShellProxy : public SipHandler<PythonShell> {
public:
PythonShellProxy()
: SipHandler<PythonShell>(NULL) {}
PythonShellProxy(PythonShell* shell)
: SipHandler<PythonShell>(shell) {}
void Show()
{
Me()->show();
}
void Hide()
{
Me()->hide();
}
void SetTabWidth(int width) {
Me()->PyShell()->SetTabWidth(width);
}
int GetTabWidth() {
return Me()->PyShell()->GetTabWidth();
}
};
}}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment