You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use the pytype_mapping function to get automatic conversion from a PyObject type to one of my wrapper types in Julia. My code is below:
vis= pyimport("ovito.vis")
struct OpenGLRenderer <: Renderer
o::PyObject
function OpenGLRenderer(antialiasing_level)
return new(vis.OpenGLRenderer(antialiasing_level = antialiasing_level))
end
end
pytype_mapping(vis."OpenGLRenderer", OpenGLRenderer)
renderer = vis.OpenGLRenderer()
The typeof renderer is just PyObject still how do I make this automatically recognize as my Julia type? I'm a little confused as to what the correct pattern is supposed to be here. If I call pytype_query on renderer PyCall sees that renderer could be my OpenGLRenderer Julia type but that conversion is not happening automatically.
On the flip side, I also want the user to be able to construct their own OpenGLRenderer without having to call the python library. My constructor above works for that but it required me to manually add the antialiasing_level. Is the only way around this to use kwargs and args?
The text was updated successfully, but these errors were encountered:
Hello,
I'm trying to use the
pytype_mapping
function to get automatic conversion from a PyObject type to one of my wrapper types in Julia. My code is below:The typeof
renderer
is just PyObject still how do I make this automatically recognize as my Julia type? I'm a little confused as to what the correct pattern is supposed to be here. If I callpytype_query
onrenderer
PyCall sees thatrenderer
could be myOpenGLRenderer
Julia type but that conversion is not happening automatically.On the flip side, I also want the user to be able to construct their own OpenGLRenderer without having to call the python library. My constructor above works for that but it required me to manually add the
antialiasing_level
. Is the only way around this to use kwargs and args?The text was updated successfully, but these errors were encountered: