Hello, Ihsan.<div><br></div><div>In general, I find it easier to develop my code on one of my main systems rather than directly on the mobile device (to transfer and test it on the device I would then use ftp or a usb cable and activesync).</div>
<div><br></div><div>However, if you want to code and test directly on the mobile device, I suggest the following steps (this is more of a workaround than a solution, but it works reasonably well):</div><div><br></div><div>
- create three plain text files on your device</div><div> >>> f=open("/yourpath/infile.txt","wb")</div><div> >>> f.write("mycode")</div><div> >>> f.close()</div>
<div> >>> f=open("/yourpath/mycode.txt","wb")</div><div> >>> f.write("# python code\r\n")</div><div> >>> f.close()</div><div> >>> f=open("/yourpath/txt2py.txt","wb")</div>
<div> >>> f.write("# txt2py renaming utility\r\n")</div><div> >>> f.close()</div><div><br></div><div>(note: when in the python interpreter, you can tap a line you have already typed and press enter/return, and it will appear at the '>>>' prompt so you can modify it and enter it again - this is quicker than typing the whole line again)</div>
<div><br></div><div>- now close python and open the 'txt2py.txt' file with the Windows Mobile text editor (Notes or Word, I think), but remember that when you save the file you must NOT let Notes change the format. Because it is a text file, just tapping it should open it in the default editor. Enter the following python code in the text editor:</div>
<div> f=open("infile.txt","rb")</div><div> fname=f.read()</div><div> f.close()</div><div> print "opening:",fname+".txt"</div><div> f=open(fname+".txt","rb")</div>
<div> fdat=f.read()</div><div> f.close()</div><div> print "saving:",fname+".py.py"</div><div> f=open(fname+".py.py","wb")</div><div> f.write(fdat)</div><div> f.close()</div>
<div><br></div><div>Now back in python:</div><div><div> >>> f=open("/yourpath/txt2py.txt","rb")</div><div> >>> fdat=f.read()</div><div> >>> f.close()</div><div> >>> f=open("/yourpath/<a href="http://txt2py.py.py">txt2py.py.py</a>","wb")</div>
<div> >>> f.write(fdat)</div><div> >>> f.close()</div></div><div><br></div><div>That's it! Now you can modify the 'mycode.txt' file in your text editor. When you have saved it you can run the 'txt2py' tool to make a copy of the file with the '.py.py' extension. Why the double extension? This is just a simple workaround to make your python files more visible, because Windows Mobile hides the file extension. By using a simple text file to hold the root of the filename to convert in 'infile.txt' you can easily modify the name so 'txt2py' can rename any '.txt' file to a '.py.py' file. Once you have one text file created, you can create a new text file by doing copy & paste, then renaming it. Note that the suggestion I am making assumes you are working with all your files in the same folder.</div>
<div><br></div><div>Of course, once you have it all working, you can work on improving the code. For example, you could create a 'py2txt' tool.</div><div><br></div><div>This is just my suggestion. Others on the list may have better ideas(?).</div>
<div><br></div><div>Adam</div><div><br></div><div><div class="gmail_quote">On 13 February 2011 22:59, Ihsan Cingisiz <span dir="ltr"><<a href="mailto:ihsan_cingisiz@live.nl">ihsan_cingisiz@live.nl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>
Hello,<div><br></div><div>I did all of this:</div><div><div class="im"><div style="text-indent:0px !important">>>> import _winreg as reg</div><div style="text-indent:0px !important">>>> k=reg.CreateKey(reg.HKEY_CLASSES_ROOT,'.py')</div>
<div style="text-indent:0px !important">>>> reg.SetValueEx(k,'Default',0,reg.REG_SZ,'Python.File')</div><div style="text-indent:0px !important">>>> k=reg.CreateKey(reg.HKEY_CLASSES_ROOT,'Python.File\\Shell\\Open\\Command')</div>
<div style="text-indent:0px !important">>>> reg.SetValueEx(k,'Default',0,reg.REG_SZ,'\"\\Storage Card\\Program Files\\python.exe\" \"%1\"')</div><div style="text-indent:0px !important">
<br></div></div><div style="text-indent:0px !important">But I need help with editing and creating a .py file..</div><div style="text-indent:0px !important">Can you please help me?</div><div style="text-indent:0px !important">
<br></div><div style="text-indent:0px !important">Thanks!</div><div style="text-indent:0px !important"><br></div><div style="text-indent:0px !important">K. Regards,</div><div style="text-indent:0px !important">Ihsan.</div>
<br><hr>Date: Thu, 10 Feb 2011 19:23:46 +0000<br>From: <a href="mailto:adam.walley@gmail.com" target="_blank">adam.walley@gmail.com</a><br>To: <a href="mailto:pythonce@python.org" target="_blank">pythonce@python.org</a><br>
Subject: Re: [PythonCE] PythonCE - I'm a subscriber<div><div></div><div class="h5"><br><br>Hi, Ihsan.<div><br></div><div>Welcome to the list. I am not sure what you mean by programming without the '>>>'s, but I have a feeling that you mean the Python interpreter is not associated with .py files. Once the association is created in the registry, you can launch .py files. I use WM5, but I think WM6.1 will probably let you do this too. To create the association in the registry you need to start the Python interpreter on your device, and yes you need to use the '>>>'s, but only for these steps:</div>
<div><br></div><div><div>>>> import _winreg as reg</div><div>>>> k=reg.CreateKey(reg.HKEY_CLASSES_ROOT,'.py')</div><div>>>> reg.SetValueEx(k,'Default',0,reg.REG_SZ,'Python.File')</div>
<div>>>> k=reg.CreateKey(reg.HKEY_CLASSES_ROOT,'Python.File\\Shell\\Open\\Command')</div><div>>>> reg.SetValueEx(k,'Default',0,reg.REG_SZ,'\"\\Storage Card\\Program Files\\python.exe\" \"%1\"')</div>
<div><br></div>DISCLAIMER: please be aware that modifying the registry can cause serious problems with your operating system. Do not undertake any changes unless you know and understand what you are doing!</div><div><br>
</div>
<div>The above lines of code may get broken through the email and/or mailing list, so check them carefully! Also remember the underscore for the '_winreg' module name, and look carefully at the string value you need to enter for the path to the Python.exe file - there are single AND double quotation marks.</div>
<div><br></div><div>When you have completed the above steps, you should be able to launch a simple .py file containing Python code without needing to open the interpreter first.</div><div><br></div><div>Note that I prefer to run my Python executable from an SD card, so the registry path begins with '\\Storage Card\\Program Files\\...', but if your Python.exe is located on the main device, the value will probably simply begin '\\Program Files\\...'.</div>
<div><br></div><div>Alternatively, if you are able to establish an ActiveSync link with your computer and device, then you can download a registry editor to make the task easier (e.g. CERegEditor by MDSoft is one, but there are many).</div>
<div><br></div><div>Now, writing and editing .py files is another matter...</div><div><br></div><div>HTH</div><div><br></div><div>Adam</div><div><br><div>On 10 February 2011 16:23, Ihsan Cingisiz <span dir="ltr"><<a href="mailto:ihsan_cingisiz@live.nl" target="_blank">ihsan_cingisiz@live.nl</a>></span> wrote:<br>
<blockquote style="border-left:1px #ccc solid;padding-left:1ex">
<div>
Hello,<div><br></div><div>I download PythonCE today because I love programming in Python, i'm using it on</div><div>my computer and wanted to use it on my HTC Touch Pro with Windows Mobile 6.1.</div><div>It work, but only the 'IDLE', I mean this for example:</div>
<div>>>> print "Hello..."</div><div><br></div><div>In Python PC Version you can do open a new window and program without the >>>'s.</div><div>Is that possible in PythonCE too? If it is, how do I open it?</div>
<div><br></div><div>Kind Regards,</div><div>I. Cingisiz.</div>                                            </div>
<br>_______________________________________________<br>
PythonCE mailing list<br>
<a href="mailto:PythonCE@python.org" target="_blank">PythonCE@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/pythonce" target="_blank">http://mail.python.org/mailman/listinfo/pythonce</a><br>
<br></blockquote></div><br></div>
<br></div></div>_______________________________________________
PythonCE mailing list
<a href="mailto:PythonCE@python.org" target="_blank">PythonCE@python.org</a>
<a href="http://mail.python.org/mailman/listinfo/pythonce" target="_blank">http://mail.python.org/mailman/listinfo/pythonce</a></div>                                            </div>
</blockquote></div><br></div>