You Are Here:

Community: Developer Discussion Boards

#1 Old Question How to edit a Python file on a mobile device serie 60 ? - 2005-02-05, 16:57

Join Date: Feb 2005
Posts: 1,353
Location: Belgium (Europe)
cyke64's Avatar
cyke64
Offline
Super Contributor
Hello everybody

I 'm asking how to edit a python program file not on a PC but directly on the mobile phone !
Until now I don't find any decent editor for changing the source code on my Nokia 6600 ! The only editor that I have found is Yedit (a very poor editor not very capable on Python source code ).
Only one edit among a thousand applications serie 60 ...
It's not normal not to find an editor when you can find dozens of editor on PC !
Do you know some good editor ?
I would like to have an editor like this the text viewer of ProfiExplorer from Lonely Cat ...

Thank you for your answers
Reply With Quote

#2 Old 2005-02-05, 18:04

Join Date: Feb 2005
Posts: 1
hrhrhr
Offline
Registered User
YEDIT 2.50 - the best editor for text files in different encodigs.
Reply With Quote

#3 Old 2005-02-08, 11:16

Join Date: Jan 2005
Posts: 7
jeclarim
Offline
Registered User
Why not write your own text editor in Python?
With the Text widget taking care of the actual editing, it's quite easy.
Here is the code for a tiny one including the minimal functions load, save and quit:

Code:
import appuifw
import e32

def load():
    app.body.clear()
    try:
        text = open(path).read()
        text = text.decode('utf8')
        app.body.set(text)
    except IOError:
        pass

def save():
    text = app.body.get()
    text = text.encode('utf8')
    open(path, 'w').write(text)

def quit():
    app.exit_key_handler = None
    lock.signal()

lock = e32.Ao_lock()
path = 'e:\\system\\apps\\python\\my\\test.py'
app = appuifw.app
old_title = app.title
app.title = u'Test Edit'
app.body = appuifw.Text()
app.menu = [(u'Load', load), (u'Save', save), (u'Quit', quit)]
app.exit_key_handler = quit
load()
lock.wait()
app.title = old_title
app.body = None
Reply With Quote

#4 Old 2005-02-18, 20:08

Join Date: Feb 2005
Posts: 1,353
Location: Belgium (Europe)
cyke64's Avatar
cyke64
Offline
Super Contributor
Hello ,

Thanks for your idea :-)

It works but it save into unicode but python don't accept Pythib source file in unicode :-(

Could you help me ?


Code:
from appuifw import *           
from e32 import *
from key_codes import *
import codecs





class my_app:
   def single_text_query(self,string):
       a=query(string, 'text')
       if a is None:
           pass
       else:
           return a

   def display(self,t):
       if t is None:
           pass
       else:
           note(u""+ "\n" + t, 'info')

   def displaytitle(self,legend,t):
       if t is None:
           pass
       else:
           note(unicode(legend) + "\n" + t, 'info')
        
           
   def displayconf(self,t):
       if t is None:
           pass
       else:
           note(u""+ "\n" + t, 'conf')

   def __init__(self):
       self.script_lock = Ao_lock()      #needed for "active objects" (threads)
       self.filename = u'zz09.py'
       self.path =  u'e:\\system\\apps\\python\\my\\'
       self.pathf = self.path + self.filename
 
       
   def run(self):
       old_title = app.title
       app.title = u'Mini Edit UU'
       app.body = Text()
       app.menu = [(u'Set path',self.setpath),(u'Set filename',self.setfilename),(u'Clear', self.clear),(u'Load', self.loadc), (u'Save', self.savec),(u'Settings', self.settings), (u'Quit', self.quit)]
       app.exit_key_handler = self.quit
       self.script_lock.wait()
       app.title = old_title
       app.body = None

   def quit(self):
       app.exit_key_handler = None
       self.script_lock.signal()

          
		
   def settings(self):
       self.displaytitle('default path :',self.path)
       self.displaytitle('filename :',self.filename)    
        
   def setpath(self):
       self.display(self.path)
       n = self.single_text_query(u'Enter path:')        
       if n is None:
           pass
       else:
           self.path = n
           self.pathf=unicode(self.path)+self.filename
           self.displayconf(self.pathf)
        
        
   def setfilename(self):
       self.display(self.filename)
       n = self.single_text_query(u'Enter filename:')
       if n is None:
           pass
       else:
           self.filename = n
           self.pathf=unicode(self.path)+self.filename
           self.displayconf(self.pathf)
        

   def clear(self):
       app.body.clear()


   def loadc(self):
       app.body.clear()
       (encoding,decoding,reader,writer) = codecs.lookup('UTF-8')
       try:
          input = reader(open(self.pathf,'rb'))
          app.body.set(input.read())
       except IOError:
          pass

   def savec(self):
       (encoding,decoding,reader,writer) = codecs.lookup('UTF-8')  
       output = writer(open(self.pathf,'wb'))
       output.write(app.body.get())
       
       

#
#  main program
#
if __name__ == '__main__':
  my_app().run()
Reply With Quote

#5 Old 2005-02-20, 00:31

Join Date: Mar 2004
Posts: 1
echeam
Offline
Registered User
Problem seems to be with the end of line encoding. Try...

Code:
...
   def savec(self):
       text= app.body.get().encode('utf8').replace("\xE2\x80\xA9","\x0D\x0A")
       open(self.pathf,'wb').write(text)
...
Patchy, but seems to work ok (at least with my Nokia 7610)
Reply With Quote

#6 Old 2005-02-20, 17:57

Join Date: Feb 2005
Posts: 1
mikeful
Offline
Registered User
How I can make editor working that cyke64 posted? Should I copy text to "zz09.py" and transfer it to my phone? Or can it be named any way? Where to put it in phone?
Reply With Quote

#7 Old browse and edit - 2005-02-23, 12:32

Join Date: Dec 2004
Posts: 18
mueller-stach
Offline
Registered User
Thank you guys for the editor code. I combined it with
filebrowser.py that comes with the SDK. Now one can
browse through all directories and edit/save/delete/move files.
The option "move to c: " is for easier exchange with the
desktop. Download at
http://www.mathematik.uni-mainz.de/~...on/myeditor.py

It does not need a default file as some previous code had.
Browsing starts at c: but may be changed to the python directory.
Reply With Quote

#8 Old 2005-05-16, 03:00

Join Date: Feb 2005
Posts: 18
makuchaku
Offline
Registered User
Scribble Pad v0.2 (stable) is available for download.

Download Link
1. http://www.geocities.com/mayank2cool...Pad-0.2.tar.gz

How to install/run...
1. Download Python for series 60 phones from here.
2. Install Python for series 60 on your device.
3. Copy ScribblePad.py to E:\System\Apps\Python\my\
4. Run Python & chose to run a script, ie. ScribblePad.

For any comments/suggestions, please mail at
"mayank[dot]gnu[at]gmail.com"
Reply With Quote

#9 Old 2005-05-16, 13:36

Join Date: Dec 2004
Posts: 50
Location: Czech Republic
Send a message via ICQ to Zen13546
Zen13546
Offline
Regular Contributor
First I used YEdit, but (I don't know what this problem caused) it couldn't save the file correctly. About every 200 characters it leaves out about 10 characters. So I had to insert empty comments very often(see http://www.gigahosting.cz/zen/bordel/yedit.jpg). That wouldn't be so bad, but when you insert any more code before the comments youi had to move it and so on...I tried to reinstall it (version 2.53 i think), but it didn't change anything.

Anyway, that would be great editor, if it worked (to me).

So I tried "myeditor.py". That was OK, but I'm working on an app that has got now about 15kB, and it was really difficult to orientate in this code. So I created modified version, I implemented several functions, like find and so on. Now my edited version is about 8kB (original has about 3-4kB).

//EDIT: If someone wanted, I can upload my modded version
Reply With Quote

#10 Old 2005-05-16, 22:22

Join Date: Dec 2004
Posts: 18
mueller-stach
Offline
Registered User
In my opinion it would be fantastic if you could post your
improved version of myeditor.py. In fact I was checking out ScribblePad today and find the editing of file paths excellent.
On the other hand I miss the browsing feature. If we combine
all 3 attempts this would give a nice tool. Would anyone like to do this?
Reply With Quote

#11 Old 2005-05-17, 00:06

Join Date: Dec 2004
Posts: 50
Location: Czech Republic
Send a message via ICQ to Zen13546
Zen13546
Offline
Regular Contributor
Quote:
Originally posted by mueller-stach
In my opinion it would be fantastic if you could post your
improved version of myeditor.py. In fact I was checking out ScribblePad today and find the editing of file paths excellent.
On the other hand I miss the browsing feature. If we combine
all 3 attempts this would give a nice tool. Would anyone like to do this?
of course I could

editor PY file:
http://www.gigahosting.cz/zen/Python/myeditor_mod.py

or you can download this, unpack to E:\System\Apps\, and you'll have standalone application running from menu. Maybe I'll pack it to SIS, but I am not able to do it now. And some icon could be also good, maybe I'll do it later.
the link:
http://www.gigahosting.cz/zen/Python/editor.zip

I just have to say there might be some bugs. What have I added(fixed):

- while listing files, try pressing the green key, you'll get to E:\System\Apps\Python\my . hope it'll work, I didn't know how to do it simply so I had to use the hardcore technique maybe someone will do it better
- you can use the right arrow instead of pressing joystick (a little more comfortable for me) in file listing, I know, that's nothing significant, but that was my first edit when I didn't know Python so much as I do now and it was done just because the terrible boredom at school
- ability to cycle in file listing, that's not fully functional yet

editor:
- "go to begin" added to menu, I think that's clear
- "run py" now I realise that "execute py" could be better, and I think that's also clear. Just quickly executes the py without debugging. Works only when editor runs as standalone (or under Python, simply doesn't work when run by file manager running just straight myeditor.py), because otherwise myeditors runs under appmgr and the py would be executed under appmgr too, and there can't be two appmgrs
- "find" added to menu as well, it is case insensitive, and remembers last search, but there are probably still some bugs (when not found)
- try pressing the green key, there are some predeclared constructions, like def, generates " def ():\n \n" and so on

maybe there are some more things what I've added, I can't remember everything just try. if someone continued developing this, I wouldn't be against, it would be great
Reply With Quote

#12 Old 2005-05-20, 11:09

Join Date: May 2005
Posts: 3
nigol@seznam.cz
Offline
Registered User
Zen: Sounding great! Your improvements could be very useful. I must try it as soon as possible. Thanks
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia