Author Topic: pyWrite - python script editor  (Read 48544 times)

0 Members and 1 Guest are viewing this topic.

Offline Spartan

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 7
  • Rating: +0/-0
  • Spartan. Kicking ass since 480BC.
    • View Profile
Re: pyWrite - python script editor
« Reply #45 on: December 12, 2014, 07:01:19 pm »
That would be cool as it is a pure python library, but im having troubles actually making it useable on the ti nspire CX CAS... i cant transfer the library over due to restrictions on the software, as it obviously has to be a TI Nspire file, and obviously the files i need to import are .py... any ideas how this may be available to do?

I'm not a python-user, so I'm not awared about how to import a python library.
Do you only need to transfer the .py files to the calc to use the library ? If that is so, I'm already working on a solution.

yeah i do, since its a pure python library... but it doesnt work anyway so not the main issue at the moment :(

I tried running sympy on the unix version of micropython, and I think it needs some editing to work, the imports don't work right.
Ah damn. i should get to work on that really... thanks anyway :D
Add me on steam :

My Steam Profile (from SteamDB)

  • Worth: £1117 (£294 with sales)
  • Games owned: 106
  • Games not played: 69 (65%)
  • Hours on record: 770.5h
Chris

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: pyWrite - python script editor
« Reply #46 on: December 13, 2014, 01:03:24 am »
The Nspire will reject any file that doesn't end with .tns, but doesn't do any other sort of check on them. So basically, you rename your .py files to .py.tns, and using "import" on them should work right if μPython knows that the files have the extension .py.tns.

Offline Lepzulnag

  • LV0 Newcomer (Next: 5)
  • Posts: 4
  • Rating: +0/-0
    • View Profile
Re: pyWrite - python script editor
« Reply #47 on: December 13, 2014, 11:56:40 am »
I updated Notewriter by the way, fixed some issues, now it works perfectly fine. I also put my code on Github.





Notewriter downloading link : http://tiplanet.org/forum/archives_voir.php?id=121680
My Github : https://github.com/Lepzulnag

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: pyWrite - python script editor
« Reply #48 on: December 13, 2014, 12:31:35 pm »
Quote
Does anybody have any idea if there is a possibility of adding the SymPy Python library to micropython? it would be very useful for advanced python programming and i use it alot on desktop, so im wondering if there is any way...
I haven't tested module support at all, I assume it works like normal python does.
The default module search path is /documents/ndless.
As SymPy consists of a lot of files, it will be terribly slow to install, but it should work as it doesn't require other libs.

Quote
Edit : NoteWriter's tabs are a neat idea, though :P
I've got a better, less space consuming idea :P
But first I'll have to fix some bugs, test freetype and implement Undo & Redo.

Quote
I actually agree the mouse cursor is an awesome idea that I've no idea how to code.
It's not hard: https://github.com/Vogtinator/pyWrite/blob/master/cursortask.cpp
To query the state, it's using cursor_task.x, y and state.
In general, nGL has a quite different architecture compared to your WinBox, as nGL is mainly a game library with a main loop
which makes mouse handling a bit easier.

Quote
It's smooth and useful.
Contrary to the OS's one :P

Quote
Thanks for this editor, it's really great!

I have suggestions about it:
* Draw a smaller menu and hide it when the program doesn't fit the screen (and use the scratchpad button to show it).
Smaller: Yes Hiding: No More useful: Yes.

Quote
* Make mouse move box smaller so that we can at any time see at least on pixel of the mouse.
Yeah, definitely.

Quote
* Make an auto indentation.
That's going to be hard, as that would change the program.
How should:
Code: [Select]
y = 0
z = 0
if x == 1:
y = 1
z = 2
get indented?
Quote
* Add a scrolling bar.
Yup.
Quote
* Open the last document on launching.
Yup.

Quote
I updated Notewriter by the way, fixed some issues, now it works perfectly fine. I also put my code on Github.
I had a look at your code and I can already see some bugs:
-Still using the deprecated flat binary format with objcopy
-Using nl_exec incorrectly: argv[0] is the program itself, argv[1] the first parameter
-Placing the config file outside of /documents the user can't delete it in a usual way. IMO that's very annoying, each file slows the calc down.
-Not checking the return values of fread
-Saving the file as temporary file when running as python script
-In NoteWriter.c line 405 there's an 'n' missing.
-On line 633 there's an invalid character literal: '\25' isn't 0x25 but rather "25", which is not a single character, I guess you meant '\x25'

Your WinBox framework looks useful, but there's no documentation for it and IMO it would be 100x easier to use if it was coded in C++.
You're using quite a few triple-pointers: "Widget ***wFiles", I haven't seen those in the last 20 years and I'm only 17.

Wow, this is now quite a long post now, I had to write it in a text editor and it still have to scroll to read everything.

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: pyWrite - python script editor
« Reply #49 on: December 13, 2014, 01:58:26 pm »
Your WinBox framework looks useful, but there's no documentation for it
Actually, there is a rather large one included here : https://tiplanet.org/forum/archives_voir.php?id=10587 :)
Although it's in French.
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: pyWrite - python script editor
« Reply #50 on: December 13, 2014, 02:00:40 pm »
Oh, I only looked at the repository on github, but I guess that wouldn't make a difference for me...

Offline Lepzulnag

  • LV0 Newcomer (Next: 5)
  • Posts: 4
  • Rating: +0/-0
    • View Profile
Re: pyWrite - python script editor
« Reply #51 on: December 13, 2014, 02:02:58 pm »
Well, thank you for looking at my code and giving your opinion, I appreciate it  ;) Let me answer you.


Quote
Still using the deprecated flat binary format with objcopy
Hum... sorry about that, but I don't know what you are talking about ??? I'd be glad you enlight me :)


Quote
Using nl_exec incorrectly: argv[0] is the program itself, argv[1] the first parameter
Actually I read on hackspire :
"args[] must not include the program name (argv[0]) nor the terminating NULL argument"
Since .py execution is working, I guess im doing it the right way.


Quote
Placing the config file outside of /documents the user can't delete it in a usual way. IMO that's very annoying, each file slows the calc down.
I don't think this a real issue, since the config file's aim is to be not deleted ; and even if you do so, it will be re-created next time you launch the program. Therefore, I admit it's indeed more convenient for the user to control the file.


Quote
Not checking the return values of fread
You just spotted my laziness  :P
But since the config file is hidden and can't be edited by usual ways, it should always has the structure I gave him, no ? ;)


Quote
Saving the file as temporary file when running as python script
Why is this a problem ?  :o It enables the user, when he has modified a .py file, to test his changes without having to save his current work. There's no way to do it otherwise.


Quote
In NoteWriter.c line 405 there's an 'n' missing.
Thanks for this ;)


Quote
On line 633 there's an invalid character literal: '\25' isn't 0x25 but rather "25", which is not a single character, I guess you meant '\x25'
I have to thank you for this too. Actually Notewriter 1.0 was using this '\25' character for indicating line feeds, which wasn't very proper. The 2.0 version was not intended to use this character anymore, and even if it still supports his use, this '\25' was unintended.


Quote
Your WinBox framework looks useful, but there's no documentation for it and IMO it would be 100x easier to use if it was coded in C++.
Actually I made a documentation, but sadly its in french :( I wanted to provide an english version too, but since I was not on omnimaga at this time, I told myself it would be some harassing work for almost nothing.
If you want to take a look nonetheless, it's available here, with Winbox 1.2 : http://tiplanet.org/forum/archives_voir.php?id=10587
I would have prefer to code Winbox in C++ too, but when I started the project, years ago, C++ was not fully implemented for the nspire (or I've been misinformed).


Quote
You're using quite a few triple-pointers: "Widget ***wFiles", I haven't seen those in the last 20 years and I'm only 17.
The last, but not least ! I dont know if I should be ashamed, or proud... :angel: My father, who is an engeneer and develop projects for more than 20 years, also told me triple pointers were never necessary. I guess I just found a specific case where they are necessary.
« Last Edit: December 13, 2014, 02:05:59 pm by Lepzulnag »

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: pyWrite - python script editor
« Reply #52 on: December 13, 2014, 03:08:21 pm »
Well, thank you for looking at my code and giving your opinion, I appreciate it  ;) Let me answer you.

Quote
Still using the deprecated flat binary format with objcopy
Hum... sorry about that, but I don't know what you are talking about ??? I'd be glad you enlight me :)
The PRG file format introduced by Ndless 1.2 I believe is basically just a hack to get basic execution working.
With 3.1 tangrs implemented a loader for the bFLT format which supports some relocations and I added Zehn some months ago which adds some more metadata,
is less buggy and supports C++ exceptions.

Quote
Using nl_exec incorrectly: argv[0] is the program itself, argv[1] the first parameter
Actually I read on hackspire :
"args[] must not include the program name (argv[0]) nor the terminating NULL argument"
Since .py execution is working, I guess im doing it the right way.[/quote]
Yup, you are. I forgot that nl_exec is an abomination of a syscall and I assumed it was doing it like it should do, like execve.
Actually, I should implement execve in libsyscalls so nl_exec can be deprecated.

Quote
Quote
Placing the config file outside of /documents the user can't delete it in a usual way. IMO that's very annoying, each file slows the calc down.
I don't think this a real issue, since the config file's aim is to be not deleted ; and even if you do so, it will be re-created next time you launch the program. Therefore, I admit it's indeed more convenient for the user to control the file.

Quote
Not checking the return values of fread
You just spotted my laziness  :P
But since the config file is hidden and can't be edited by usual ways, it should always has the structure I gave him, no ? ;)[/quote]
I'd add a version number, so it won't try to load a config file with incompatible data.

Quote
Quote
Saving the file as temporary file when running as python script
Why is this a problem ?  :o It enables the user, when he has modified a .py file, to test his changes without having to save his current work. There's no way to do it otherwise.
-It's slow
-It will damage the flash (although that's more an issue on classic calcs)
-The user may think if the file works, it's saved
-If micropython crashes or hangs, the work is lost.

Quote
Quote
In NoteWriter.c line 405 there's an 'n' missing.
Thanks for this ;)

Quote
On line 633 there's an invalid character literal: '\25' isn't 0x25 but rather "25", which is not a single character, I guess you meant '\x25'
I have to thank you for this too. Actually Notewriter 1.0 was using this '\25' character for indicating line feeds, which wasn't very proper. The 2.0 version was not intended to use this character anymore, and even if it still supports his use, this '\25' was unintended.
There are some more cases, it's highlighted in red on GitHub.

Quote
Quote
Your WinBox framework looks useful, but there's no documentation for it and IMO it would be 100x easier to use if it was coded in C++.
Actually I made a documentation, but sadly its in french :( I wanted to provide an english version too, but since I was not on omnimaga at this time, I told myself it would be some harassing work for almost nothing.
If you want to take a look nonetheless, it's available here, with Winbox 1.2 : http://tiplanet.org/forum/archives_voir.php?id=10587
If you like the doxygen approach, it's really easy to make documentation with it. It's generated from comments in your source files.

Quote
I would have prefer to code Winbox in C++ too, but when I started the project, years ago, C++ was not fully implemented for the nspire (or I've been misinformed).
You're absolutely right, vtables didn't work due to the missing support for relocations (like I said above), but now everything except std::thread is implemented.

Quote
Quote
You're using quite a few triple-pointers: "Widget ***wFiles", I haven't seen those in the last 20 years and I'm only 17.
The last, but not least ! I dont know if I should be ashamed, or proud... :angel: My father, who is an engeneer and develop projects for more than 20 years, also told me triple pointers were never necessary. I guess I just found a specific case where they are necessary.
Actually, they're only necessary in bad code, a refactor should get rid of most of them. The issue is that code that needs triple pointers has triple pointers and is therefore bad code... Also, it's a triple indirection nobody wants to think about so bugs are pre-programmed.

Offline hedehede81

  • LV0 Newcomer (Next: 5)
  • Posts: 1
  • Rating: +0/-0
    • View Profile
Re: pyWrite - python script editor
« Reply #53 on: February 27, 2015, 08:58:32 am »
Guys, is it possible to put quotation marks " as in print("hello world") on the calculator itself? I could put that using the key next to letter G, but don't know how to put it either in Pywrite or Notewriter. Thanks.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: pyWrite - python script editor
« Reply #54 on: February 27, 2015, 09:01:44 am »
It's shift + "*"

Offline Chirlian

  • LV2 Member (Next: 40)
  • **
  • Posts: 22
  • Rating: +0/-0
    • View Profile
Re: pyWrite - python script editor
« Reply #55 on: March 08, 2017, 09:52:45 pm »
Hi Vogtinator,
am trying to work with pyWrite but there seems to be a problem: can select signs and text, but the 'ctrl-c' function doesn't work (same with ctrl-x and ctrl-v. The functions don't work but when entering, I get simply the sign, so ctrl-c writes a 'c'.
cu
klaus