Monday, May 28, 2012

Re: Python IDLE

On Mon, 28 May 2012 05:37:43 -0700 (PDT), coded kid
<duffleboi911@gmail.com> declaimed the following in
gmane.comp.python.django.user:

> I'm in a big mess now, I've lost my projects due to this errror. I'm
> on windows, This is how I encounter the problem; I try to edit my
> settings.py in IDLE. After right clicking on the files, I choose open
> program with these default file. I choose idle window bat file, and I
> clicked Ok. It didn't open, I try to run manage.py runserver on my
> DOS. Not working, it will pop up the IDLE Shell and mange.py script by
> displaying it in IDLE. It didn't run the server. The logo of my python
> files have changed. How can I revert it back to open with IDLE? And
> use it as default for my python script?

IDLE itself is a Python script; though it sounds like you (or
someone) created a Windows BAT file to act as an intermediate.

The main problem appears to be that you've associated the "open"
action with /IDLE/... The normal "open" action for Python (.py) script
files should be Python.exe (or Pythonw.exe for .pyw). For editing you
should have/create a <right-click>"Edit" action that invokes your IDLE
BAT file.

You'll need to work with the file association commands in Windows to
reset things so that "open" means RUN the script.

Unfortunately, different installations have used different names for
the file types. Here are mine (I had to do "ftype" with no arguments and
scan the long output to find the Python entries):

E:\UserData\Wulfraed\My Documents>ftype py_auto_file
py_auto_file="E:\Python25\python.exe" "%1" %*

E:\UserData\Wulfraed\My Documents>ftype pyw_auto_file
pyw_auto_file="E:\Python25\pythonw.exe" "%1"


Note that ftype only defines the "open"/"run" action for a file.
(Interesting -- the .pyw doesn't take command line arguments, probably
to be expected for a double-click open).

The other half of the basic equation is the file extension to "file
type" association:

E:\UserData\Wulfraed\My Documents>assoc .py
.py=py_auto_file

E:\UserData\Wulfraed\My Documents>assoc .pyc
File association not found for extension .pyc

E:\UserData\Wulfraed\My Documents>assoc .pyw
.pyw=pyw_auto_file

(This is why I commented that the file type name may differ between
installs -- the assoc is
<.extension> = <file type>
and ftype is
<file type> = <command line to execute>
As long as the same <file type> is used in both commands the linkage
works)

That SHOULD clear up the double-click/<right-click>Open/command line
running of Python scripts. Setting up an Edit action (on WinXP) requires
going through either the registry by hand, or opening a directory
window,

Tools/Folder Options
File Types (tab)
scroll down to PY and PYW entries, select one
Details should show "Opens with: python" (or pythonw)
[Advanced]
the default action should be "open" (bold). If there is no "edit"
action, click [New...]

Give it Action name "edit" (or "edit with IDLE")
Application used to perform action: full path to the IDLE.BAT file
(in quotes) followed by "%1" (with quotes) for the argument placeholder
(the file to be edited).
Might need to [x] Use DDE; set "Application" to IDLE, set Topic to
System

{NOTE: I'm paraphrasing from the edit action on my system which uses
"E:\Python25\Lib\site-packages\pythonwin\Pythonwin.exe" "%1"}
{I'm not sure if you could skip the BAT file and use
"path/to/python.exe" "path/to/IDLE.py" "%1"
instead}

--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment