Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3484940
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:50:52+00:00 2026-05-18T10:50:52+00:00

I’m trying to figure whats wrong with some autogenerated (with Pyste) boost::python code, but

  • 0

I’m trying to figure whats wrong with some autogenerated (with Pyste) boost::python code, but have no luck so far.

There is C++ library, Magick++, which provides two classes, Magick::Drawable and Magick::DrawableRectangle:

https://www.imagemagick.org/subversion/ImageMagick/trunk/Magick++/lib/Magick++/Drawable.h

class MagickDLLDecl DrawableBase:
   public std::unary_function<MagickCore::DrawingWand,void>
{...}
class MagickDLLDecl Drawable
{
  public:
    // Constructor
    Drawable ( void );
    // Construct from DrawableBase
    Drawable ( const DrawableBase& original_ );
...
}
class MagickDLLDecl DrawableRectangle : public DrawableBase
{ ... }

These are used as arguments for Image.draw():
https://www.imagemagick.org/subversion/ImageMagick/trunk/Magick++/lib/Magick++/Image.h

// Draw on image using a single drawable
void            draw ( const Drawable &drawable_ );
// Draw on image using a drawable list
void            draw ( const std::list<Magick::Drawable> &drawable_ );

I’m trying to make python bindings for it, there are autogenned wrappers for all the classes,

http://bitbucket.org/dan.kluev/pythonmagick/src/65d45c998ef3/src/_Drawable.cpp

http://bitbucket.org/dan.kluev/pythonmagick/src/65d45c998ef3/src/_DrawableRectangle.cpp

http://bitbucket.org/dan.kluev/pythonmagick/src/65d45c998ef3/src/_Image.cpp

Problem is, due to indirect class casts from DrawableBase to Drawable, these wrappers do not work:

>>> import PythonMagick
>>> image = PythonMagick.Image()
>>> square = PythonMagick._PythonMagick.DrawableRectangle(0,0,200,200)
>>> image.draw(square)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
Boost.Python.ArgumentError: Python argument types in
    Image.draw(Image, DrawableRectangle)
did not match C++ signature:
    draw(Magick::Image {lvalue}, std::list<Magick::Drawable, std::allocator<Magick::Drawable> >)
    draw(Magick::Image {lvalue}, Magick::Drawable)
# But abstract Drawable() does work:
>>> image.draw(PythonMagick._PythonMagick.Drawable())
>>> 

Is there any better way to handle this than write my own draw() wrapper in C++, which would cast PyObject into Drawable?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:50:52+00:00Added an answer on May 18, 2026 at 10:50 am

    If you want BP to implicitly convert objects foy you , you must tell BP that thay are implicitly convertable. put something like this in your bp::code:

    boost::python::implicitly_convertible<SourceType,DestType>();
    

    I do not know how to induce Pyste to do this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm making a simple page using Google Maps API 3. My first. One marker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.