First, thanks for tips on how to make the <script type="text/python">,
that's now working fine on my side.
For the module, create a folder "/src/lib/test" and create a
"__init.py__" in it with your code.
Compile with "m dist", then, in your .html page, do :
<script type="text/python">
import test
t = test.myTest( 1 )
print t.run( 2 )
</script>
You can also create Javascript modules in the same way, the structure
& communication is a little bit more tricky, but that's the way to go
to be able to communicate between Python/Javascript/DOM.
To allow import of "non compiled modules", we should be able to use
your XHR method. Either to do a dirty "str_replace" of "import
myModule.py" by the content of the module (lets says that adding .py
means it's a non compiled module) or modifying the existing import
function to handle that case.
Regards,
Pascal
On Jun 25, 11:45 pm, Billy Earney <
billy.ear...@gmail.com> wrote:
> Brad,
>
> I saw your blog athttp://
blog.bonelakesoftware.com/2011/03/adding-module-to-skulpt.htmlwhich
> describes some basics of Skulpt. I'm using your builtinRead function. I
> believe skulpt is able to find my module (which is a python module), but I
> get an error "TypeError: a.tp$setattr is not a function". Is it possible to
> create a module named myTest.py and place it in the src/lib directory and
> have it work?
>
> Here's the test module I'm playing with:
>
> class myTest:
> def __init__(self, c):
> self._c=c
>
> def run(self, b):
> return self._c+b
>
> I've double checked and the builtin.js file contains the myTest class and I
> have added builtin.js after skulpt.js in my html file.
>
> Any help or guidance is appreciated..
>
> Thanks!
>
> Billy
>
> On Sat, Jun 25, 2011 at 8:16 AM, Billy Earney <
billy.ear...@gmail.com>wrote:
>
>
>
>
>
>
>
> > Brad,
>
> > Can you explain the builtin.js approach? I've played with the code a
> > little, and I'm failing to figure out how to import a module.
>
> > Thanks!
>
> > On Thu, Jun 23, 2011 at 2:41 PM, Brad Miller <
bonel...@gmail.com> wrote:
>
> >> I agree. In the long run that would be a cool approach. I think I've
> >> learned enough about the guts of skulpt that I could probably do it, but
> >> unfortunately its pretty far down on my priority list right now. I can
> >> accomplish everything I need for my current usage of skulpt using the
> >> builtin.js approach.
>
> >> Brad
>
> >> --
> >> Brad Miller
> >> Sent with Sparrow <
http://www.sparrowmailapp.com>
>
> >> On Thursday, June 23, 2011 at 1:07 PM, Billy Earney wrote:
>
> >> Brad,
>
> >> Thanks for the response. That is sad news. I was hoping to be able to
> >> import py files in the same (or from a different directory). It seems to me
> >> that this could be a possibility. I'm not sure how much Skulpt would need
> >> to be modified to get it to work, but I could see a lot of potential , if
> >> this feature was implemented.
>
> >> On Thu, Jun 23, 2011 at 11:41 AM, Brad Miller <
bonel...@gmail.com> wrote:
>
> >> --
> >> Brad Miller
> >> Sent with Sparrow <
http://www.sparrowmailapp.com>