Was anybody being able to make work the "billearney" cloned version of
Skulpt which is supposed to allow use of the <script type="text/
python></script> syntax ?
The example provided in this cloned version didn't work for me out of
the box, seems that's "deps.js" is calling for some Closures libs/
files that are not in the repository.
It also seems that this functionality isn't included in the master
branch of Skulpt.
I've been able to get basic scripts working, but once you add an import, etc it would bomb. Not sure of the best (or correct way) to import python code in Skulpt..
If someone could produce an example in which a library was imported, that might help..
-----Original Message----- From: skulpt@googlegroups.com [mailto:skulpt@googlegroups.com] On Behalf Of
Hypee Sent: Monday, June 20, 2011 4:30 AM To: Skulpt Subject: [Skulpt] Using "<script type="text/python></script>" syntax ?
Hi,
Was anybody being able to make work the "billearney" cloned version of Skulpt which is supposed to allow use of the <script type="text/ python></script> syntax ?
The example provided in this cloned version didn't work for me out of the box, seems that's "deps.js" is calling for some Closures libs/ files that are not in the repository.
It also seems that this functionality isn't included in the master branch of Skulpt.
Just to be sure... You do know that in order to import a library you need to add the builtin.js script to your source. It must come after you include skulpt.js
On Tuesday, June 21, 2011 at 7:31 AM, Billy Earney wrote: > Hypee,
> I've been able to get basic scripts working, but once you add an import, etc > it would bomb. Not sure of the best (or correct way) to import python code > in Skulpt..
> If someone could produce an example in which a library was imported, that > might help..
> -----Original Message----- > From: skulpt@googlegroups.com [mailto:skulpt@googlegroups.com] On Behalf Of > Hypee > Sent: Monday, June 20, 2011 4:30 AM > To: Skulpt > Subject: [Skulpt] Using "<script type="text/python></script>" syntax ?
> Hi,
> Was anybody being able to make work the "billearney" cloned version of > Skulpt which is supposed to allow use of the <script type="text/ > python></script> syntax ?
> The example provided in this cloned version didn't work for me out of > the box, seems that's "deps.js" is calling for some Closures libs/ > files that are not in the repository.
> It also seems that this functionality isn't included in the master > branch of Skulpt.
In your Skult version, the "/example/Example1.html" seems to correctly
compile the code inside <script type="text/python> (which is already
quite amazing). But unfortunately, it doesn't seems to execute the
generated/compiled javascript code, or am I missing something ?
Might you give some info on how you achieved to make the <script
type="text/python> thing work ? (I mean what files did you modify).
@Brad
Do you mean that it's possible to make an "import myModule" that will
import the "myModule.py" file located in the same folder than
the .html file, without having to create an "/src/lib/myModule" folder
+ "_init_.py" file + recompiling with "m dist" ?
Look at the init.js script. It accesses the DOM and reads the contents between the <script type="text/python"> ... </script> tags, and then sends it to a skulpt function to parse it, and then execute it.
I've also created a myread function (that overrides read) which uses XMLHTTPRequest to download the python file..
I'm having some trouble at this point. ( get a Typeerror: a is undefined).. Not sure what is causing this. I know the file is being read in properly but after that something is wrong..
comment out the import myTest and it works fine. uncomment the import myTest, and I get the error above. Paste the code from myTest.py inside the script tags and it works (and parses, and executes) fine.
Does anyone have any suggestions?
Would be cool to get this working, and then to get python to access the DOM, would be very awesome! :)
On Mon, Jun 20, 2011 at 4:30 AM, Hypee <pascal.hy...@gmail.com> wrote: > Hi,
> Was anybody being able to make work the "billearney" cloned version of > Skulpt which is supposed to allow use of the <script type="text/ > python></script> syntax ?
> The example provided in this cloned version didn't work for me out of > the box, seems that's "deps.js" is calling for some Closures libs/ > files that are not in the repository.
> It also seems that this functionality isn't included in the master > branch of Skulpt.
> Look at the init.js script. It accesses the DOM and reads the contents > between the <script type="text/python"> ... </script> tags, and then > sends it to a skulpt function to parse it, and then execute it.
> I've also created a myread function (that overrides read) which uses > XMLHTTPRequest to download the python file..
> I'm having some trouble at this point. ( get a Typeerror: a is > undefined).. Not sure what is causing this. I know the file is being > read in properly but after that something is wrong..
> comment out the import myTest and it works fine. uncomment the import > myTest, and I get the error above. Paste the code from myTest.py inside > the script tags and it works (and parses, and executes) fine.
> Does anyone have any suggestions?
> Would be cool to get this working, and then to get python to access the > DOM, would be very awesome! :)
> On Mon, Jun 20, 2011 at 4:30 AM, Hypee <pascal.hy...@gmail.com> wrote:
>> Hi,
>> Was anybody being able to make work the "billearney" cloned version of >> Skulpt which is supposed to allow use of the <script type="text/ >> python></script> syntax ?
>> The example provided in this cloned version didn't work for me out of >> the box, seems that's "deps.js" is calling for some Closures libs/ >> files that are not in the repository.
>> It also seems that this functionality isn't included in the master >> branch of Skulpt.
On Wednesday, June 22, 2011 at 5:23 PM, Hypee wrote: > @Billy
> Thanks for the quick answer !
> In your Skult version, the "/example/Example1.html" seems to correctly > compile the code inside <script type="text/python> (which is already > quite amazing). But unfortunately, it doesn't seems to execute the > generated/compiled javascript code, or am I missing something ?
> Might you give some info on how you achieved to make the <script > type="text/python> thing work ? (I mean what files did you modify).
> @Brad
> Do you mean that it's possible to make an "import myModule" that will > import the "myModule.py" file located in the same folder than > the .html file, without having to create an "/src/lib/myModule" folder > + "_init_.py" file + recompiling with "m dist" ?
No, all modules that you import have to be built into the builtin.js file that gets created when you run m dist or m docbi .
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 Wednesday, June 22, 2011 at 5:23 PM, Hypee wrote:
> @Billy
> Thanks for the quick answer !
> In your Skult version, the "/example/Example1.html" seems to correctly > compile the code inside <script type="text/python> (which is already > quite amazing). But unfortunately, it doesn't seems to execute the > generated/compiled javascript code, or am I missing something ?
> Might you give some info on how you achieved to make the <script > type="text/python> thing work ? (I mean what files did you modify).
> @Brad
> Do you mean that it's possible to make an "import myModule" that will > import the "myModule.py" file located in the same folder than > the .html file, without having to create an "/src/lib/myModule" folder > + "_init_.py" file + recompiling with "m dist" ?
> No, all modules that you import have to be built into the builtin.js file > that gets created when you run m dist or m docbi .
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.
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 (mailto:bonel...@gmail.com)> wrote:
> > On Wednesday, June 22, 2011 at 5:23 PM, Hypee wrote:
> > > @Billy
> > > Thanks for the quick answer !
> > > In your Skult version, the "/example/Example1.html" seems to correctly > > > compile the code inside <script type="text/python> (which is already > > > quite amazing). But unfortunately, it doesn't seems to execute the > > > generated/compiled javascript code, or am I missing something ?
> > > Might you give some info on how you achieved to make the <script > > > type="text/python> thing work ? (I mean what files did you modify).
> > > @Brad
> > > Do you mean that it's possible to make an "import myModule" that will > > > import the "myModule.py" file located in the same folder than > > > the .html file, without having to create an "/src/lib/myModule" folder > > > + "_init_.py" file + recompiling with "m dist" ?
> > No, all modules that you import have to be built into the builtin.js file that gets created when you run m dist or m docbi .
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.
> 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:
> On Wednesday, June 22, 2011 at 5:23 PM, Hypee wrote:
> @Billy
> Thanks for the quick answer !
> In your Skult version, the "/example/Example1.html" seems to correctly > compile the code inside <script type="text/python> (which is already > quite amazing). But unfortunately, it doesn't seems to execute the > generated/compiled javascript code, or am I missing something ?
> Might you give some info on how you achieved to make the <script > type="text/python> thing work ? (I mean what files did you modify).
> @Brad
> Do you mean that it's possible to make an "import myModule" that will > import the "myModule.py" file located in the same folder than > the .html file, without having to create an "/src/lib/myModule" folder > + "_init_.py" file + recompiling with "m dist" ?
> No, all modules that you import have to be built into the builtin.js file > that gets created when you run m dist or m docbi .
I saw your blog at http://blog.bonelakesoftware.com/2011/03/adding-module-to-skulpt.html which 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:
> 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.
>> 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:
>> On Wednesday, June 22, 2011 at 5:23 PM, Hypee wrote:
>> @Billy
>> Thanks for the quick answer !
>> In your Skult version, the "/example/Example1.html" seems to correctly >> compile the code inside <script type="text/python> (which is already >> quite amazing). But unfortunately, it doesn't seems to execute the >> generated/compiled javascript code, or am I missing something ?
>> Might you give some info on how you achieved to make the <script >> type="text/python> thing work ? (I mean what files did you modify).
>> @Brad
>> Do you mean that it's possible to make an "import myModule" that will >> import the "myModule.py" file located in the same folder than >> the .html file, without having to create an "/src/lib/myModule" folder >> + "_init_.py" file + recompiling with "m dist" ?
>> No, all modules that you import have to be built into the builtin.js file >> that gets created when you run m dist or m docbi .
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:
> I saw your blog athttp://blog.bonelakesoftware.com/2011/03/adding-module-to-skulpt.html... > 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.
> >> 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:
> >> On Wednesday, June 22, 2011 at 5:23 PM, Hypee wrote:
> >> @Billy
> >> Thanks for the quick answer !
> >> In your Skult version, the "/example/Example1.html" seems to correctly
> >> compile the code inside <script type="text/python> (which is already
> >> quite amazing). But unfortunately, it doesn't seems to execute the
> >> generated/compiled javascript code, or am I missing something ?
> >> Might you give some info on how you achieved to make the <script
> >> type="text/python> thing work ? (I mean what files did you modify).
> >> @Brad
> >> Do you mean that it's possible to make an "import myModule" that will
> >> import the "myModule.py" file located in the same folder than
> >> the .html file, without having to create an "/src/lib/myModule" folder
> >> + "_init_.py" file + recompiling with "m dist" ?
> >> No, all modules that you import have to be built into the builtin.js file
> >> that gets created when you run m dist or m docbi .
On Saturday, June 25, 2011 at 4:45 PM, Billy Earney wrote: > Brad,
> I saw your blog at http://blog.bonelakesoftware.com/2011/03/adding-module-to-skulpt.html which 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 (http://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 (mailto: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 (mailto: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.
> > > 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 (mailto:bonel...@gmail.com)> wrote:
> > > > > On Wednesday, June 22, 2011 at 5:23 PM, Hypee wrote:
> > > > > > @Billy
> > > > > > Thanks for the quick answer !
> > > > > > In your Skult version, the "/example/Example1.html" seems to correctly > > > > > > compile the code inside <script type="text/python> (which is already > > > > > > quite amazing). But unfortunately, it doesn't seems to execute the > > > > > > generated/compiled javascript code, or am I missing something ?
> > > > > > Might you give some info on how you achieved to make the <script > > > > > > type="text/python> thing work ? (I mean what files did you modify).
> > > > > > @Brad
> > > > > > Do you mean that it's possible to make an "import myModule" that will > > > > > > import the "myModule.py" file located in the same folder than > > > > > > the .html file, without having to create an "/src/lib/myModule" folder > > > > > > + "_init_.py" file + recompiling with "m dist" ?
> > > > > No, all modules that you import have to be built into the builtin.js file that gets created when you run m dist or m docbi .
On Mon, Jun 27, 2011 at 4:50 PM, Brad Miller <bonel...@gmail.com> wrote: > Billy,
> The way I've tested it is to create a subdirectory under lib and then put > my python module code in __init__.py
> when you run ./m dist that will compile the python to javascript and store > it in builtin.js.
> I'm not sure why you are getting the error below but it sounds like you > might be seeing Python in builtin.js which is not good.
> Brad
> -- > Brad Miller
> On Saturday, June 25, 2011 at 4:45 PM, Billy Earney wrote:
> Brad,
> I saw your blog at > http://blog.bonelakesoftware.com/2011/03/adding-module-to-skulpt.html... 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.
> 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:
> On Wednesday, June 22, 2011 at 5:23 PM, Hypee wrote:
> @Billy
> Thanks for the quick answer !
> In your Skult version, the "/example/Example1.html" seems to correctly > compile the code inside <script type="text/python> (which is already > quite amazing). But unfortunately, it doesn't seems to execute the > generated/compiled javascript code, or am I missing something ?
> Might you give some info on how you achieved to make the <script > type="text/python> thing work ? (I mean what files did you modify).
> @Brad
> Do you mean that it's possible to make an "import myModule" that will > import the "myModule.py" file located in the same folder than > the .html file, without having to create an "/src/lib/myModule" folder > + "_init_.py" file + recompiling with "m dist" ?
> No, all modules that you import have to be built into the builtin.js file > that gets created when you run m dist or m docbi .
1. I don't know what I was talking about when I said no python in the builtin.js file. I just double checked how my example worked and there it was. So thats not the issue.
2. I took your builtin.js that you sent me and dropped it into my test environment. I tried the following program:
import myTest
x = myTest.myTest(2) print x.run(3)
And it worked just fine. Now I did this using a textarea and the run script I posted on my blog, not in a <script> tag. So that would seem to point to the script tag not necessarily anything in skulpt proper. I haven't looked at the branch that implements <script type="text/python"> so I can't really comment.
On Tuesday, June 28, 2011 at 5:36 PM, Billy Earney wrote: > Brad,
> Enclosed is my builtin.js file when I do a ./m dist
> The python code is being inserted into the builtin.js file,and isn't being compiled into javascript. Is there a step I should do before ./m dist?
> Thanks!
> On Mon, Jun 27, 2011 at 4:50 PM, Brad Miller <bonel...@gmail.com (mailto:bonel...@gmail.com)> wrote: > > Billy,
> > The way I've tested it is to create a subdirectory under lib and then put my python module code in __init__.py
> > when you run ./m dist that will compile the python to javascript and store it in builtin.js.
> > I'm not sure why you are getting the error below but it sounds like you might be seeing Python in builtin.js which is not good.
> > Brad > > -- > > Brad Miller
> > On Saturday, June 25, 2011 at 4:45 PM, Billy Earney wrote:
> > > Brad,
> > > I saw your blog at http://blog.bonelakesoftware.com/2011/03/adding-module-to-skulpt.html which 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 (http://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?
> > > 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 (mailto: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 (mailto: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.
> > > > > 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 (mailto:bonel...@gmail.com)> wrote:
> > > > > > > On Wednesday, June 22, 2011 at 5:23 PM, Hypee wrote:
> > > > > > > > @Billy
> > > > > > > > Thanks for the quick answer !
> > > > > > > > In your Skult version, the "/example/Example1.html" seems to correctly > > > > > > > > compile the code inside <script type="text/python> (which is already > > > > > > > > quite amazing). But unfortunately, it doesn't seems to execute the > > > > > > > > generated/compiled javascript code, or am I missing something ?
> > > > > > > > Might you give some info on how you achieved to make the <script > > > > > > > > type="text/python> thing work ? (I mean what files did you modify).
> > > > > > > > @Brad
> > > > > > > > Do you mean that it's possible to make an "import myModule" that will > > > > > > > > import the "myModule.py" file located in the same folder than > > > > > > > > the .html file, without having to create an "/src/lib/myModule" folder > > > > > > > > + "_init_.py" file + recompiling with "m dist" ?
> > > > > > > No, all modules that you import have to be built into the builtin.js file that gets created when you run m dist or m docbi .
No problem. I’ll look at this a little later today, and hopefully I can get it running.
From: skulpt@googlegroups.com [mailto:skulpt@googlegroups.com] On Behalf Of Brad Miller Sent: Wednesday, June 29, 2011 1:26 PM To: skulpt@googlegroups.com Subject: Re: [Skulpt] Re: Using "<script type="text/python></script>" syntax ?
Billy,
Two things:
1. I don't know what I was talking about when I said no python in the builtin.js file. I just double checked how my example worked and there it was. So thats not the issue.
2. I took your builtin.js that you sent me and dropped it into my test environment. I tried the following program:
import myTest
x = myTest.myTest(2)
print x.run(3)
And it worked just fine. Now I did this using a textarea and the run script I posted on my blog, not in a <script> tag. So that would seem to point to the script tag not necessarily anything in skulpt proper. I haven't looked at the branch that implements <script type="text/python"> so I can't really comment.
Sorry for the mis-information before.
Brad
-- Brad Miller
On Tuesday, June 28, 2011 at 5:36 PM, Billy Earney wrote:
Brad,
Enclosed is my builtin.js file when I do a ./m dist
The python code is being inserted into the builtin.js file,and isn't being compiled into javascript. Is there a step I should do before ./m dist?
Thanks!
On Mon, Jun 27, 2011 at 4:50 PM, Brad Miller <bonel...@gmail.com> wrote:
Billy,
The way I've tested it is to create a subdirectory under lib and then put my python module code in __init__.py
when you run ./m dist that will compile the python to javascript and store it in builtin.js.
I'm not sure why you are getting the error below but it sounds like you might be seeing Python in builtin.js which is not good.
Brad
-- Brad Miller
On Saturday, June 25, 2011 at 4:45 PM, Billy Earney wrote:
Brad,
I saw your blog at http://blog.bonelakesoftware.com/2011/03/adding-module-to-skulpt.html which 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.
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:
On Wednesday, June 22, 2011 at 5:23 PM, Hypee wrote:
@Billy
Thanks for the quick answer !
In your Skult version, the "/example/Example1.html" seems to correctly compile the code inside <script type="text/python> (which is already quite amazing). But unfortunately, it doesn't seems to execute the generated/compiled javascript code, or am I missing something ?
Might you give some info on how you achieved to make the <script type="text/python> thing work ? (I mean what files did you modify).
@Brad
Do you mean that it's possible to make an "import myModule" that will import the "myModule.py" file located in the same folder than the .html file, without having to create an "/src/lib/myModule" folder + "_init_.py" file + recompiling with "m dist" ?
No, all modules that you import have to be built into the builtin.js file that gets created when you run m dist or m docbi .
Thanks for helping me with this. I believe I have it working, thanks to the example you give below. Also I believe I have the dynamic import thingee solved as well. I've created a myExample.py script (and it isn't in the builtin.js file), and was able to import it by using <script src="myExample.py" type="text/python"></script>
So we could use builtin.js for the regular py files that come with python (random, math, etc), and the above format could be another option of dynamically adding one or more .py files without using the builtin.js technique..
How to reproduce:
save the attachments.
mv dist.7z.txt dist.7z mv example.7z.txt example 7za x dist.7z 7za x example.7z
cd example open script.html in a browser and if the page says Hello World, then 15, and then good bye!. The dynamic import worked and compiled properly..
There might be a better way of doing this. When I parse the script tag (which contains the src attribute), I look for and download the file (myExample.py) and then I place it in the builitin['files'] data structure. After that, skulpt doesn't know if its really part of builtin.js or not.
Like I said, there could be a better way of doing this, but I guess this is a start. :)
Let me know if you have trouble replicating my results..
On Wed, Jun 29, 2011 at 1:26 PM, Brad Miller <bonel...@gmail.com> wrote: > Billy,
> Two things:
> 1. I don't know what I was talking about when I said no python in the > builtin.js file. I just double checked how my example worked and there it > was. So thats not the issue.
> 2. I took your builtin.js that you sent me and dropped it into my test > environment. I tried the following program:
> import myTest
> x = myTest.myTest(2) > print x.run(3)
> And it worked just fine. Now I did this using a textarea and the run > script I posted on my blog, not in a <script> tag. So that would seem to > point to the script tag not necessarily anything in skulpt proper. I > haven't looked at the branch that implements <script type="text/python"> so > I can't really comment.
> Sorry for the mis-information before.
> Brad
> -- > Brad Miller
> On Tuesday, June 28, 2011 at 5:36 PM, Billy Earney wrote:
> Brad,
> Enclosed is my builtin.js file when I do a ./m dist
> The python code is being inserted into the builtin.js file,and isn't being > compiled into javascript. Is there a step I should do before ./m dist?
> Thanks!
> On Mon, Jun 27, 2011 at 4:50 PM, Brad Miller <bonel...@gmail.com> wrote:
> Billy,
> The way I've tested it is to create a subdirectory under lib and then put > my python module code in __init__.py
> when you run ./m dist that will compile the python to javascript and store > it in builtin.js.
> I'm not sure why you are getting the error below but it sounds like you > might be seeing Python in builtin.js which is not good.
> Brad
> -- > Brad Miller
> On Saturday, June 25, 2011 at 4:45 PM, Billy Earney wrote:
> Brad,
> I saw your blog at > http://blog.bonelakesoftware.com/2011/03/adding-module-to-skulpt.html... 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.
> 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:
> On Wednesday, June 22, 2011 at 5:23 PM, Hypee wrote:
> @Billy
> Thanks for the quick answer !
> In your Skult version, the "/example/Example1.html" seems to correctly > compile the code inside <script type="text/python> (which is already > quite amazing). But unfortunately, it doesn't seems to execute the > generated/compiled javascript code, or am I missing something ?
> Might you give some info on how you achieved to make the <script > type="text/python> thing work ? (I mean what files did you modify).
> @Brad
> Do you mean that it's possible to make an "import myModule" that will > import the "myModule.py" file located in the same folder than > the .html file, without having to create an "/src/lib/myModule" folder > + "_init_.py" file + recompiling with "m dist" ?
> No, all modules that you import have to be built into the builtin.js file > that gets created when you run m dist or m docbi .