Setting up UE to run the Python interpreter?

Help with setting up and configuring custom user tools in UltraEdit (based on command line input)

Setting up UE to run the Python interpreter?

Postby JohnJSal » Tue Mar 14, 2006 10:10 pm

Is there a way to set up UE so that I can execute the Python code I've written in it, possibly through IDLE or some other interactive interpreter of that sort?

I'm sure this is possible, but I don't know how to set it up beyond creating the basic link to the program itself. I don't know how to get my code to actually run in the external program.

Thanks,
John
User avatar
JohnJSal
Advanced User
Advanced User
 
Posts: 60
Joined: Sat Mar 05, 2005 12:00 am

Re: Setting up UE to run the Python interpreter?

Postby Bego » Wed Mar 15, 2006 7:06 am

Hi John,

I don't know anything about python, but if you can call your Python from the prompt with the file as parameter, you can easily setup a "tool" in UE.
e.g.:
idlepythonwhatever.exe "%f"

So, %f is the substitution for your file you are working on.

rds Bego
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: Setting up UE to run the Python interpreter?

Postby JohnJSal » Wed Mar 15, 2006 3:03 pm

Thanks, I'll give that a try.

Edit: Now that I think about it, I'm not sure this will work. This might work for the DOS command prompt, because to run a program that way, the command would be "python filename.ext". (Although I don't know how I'd get the word 'python' in there).

But I'm trying to run the code within a more specific environment, and the way to do it there would be to run "import filename" (without the extension). Is it possible to configure the Tool to input this information in the program once it opens?
User avatar
JohnJSal
Advanced User
Advanced User
 
Posts: 60
Joined: Sat Mar 05, 2005 12:00 am

Re: Setting up UE to run the Python interpreter?

Postby Bego » Wed Mar 15, 2006 9:29 pm

I just tried to do a "%f" in the tools-dialog with a test.vbs script
AND IT WORKED, so without a
wscript.exe "%f"

--> if a double click in windows -explorer on your Python files start your script correctly, a "%f" is all you need :-)

Use Internet explorer, tools, file-types to associate extensions to applications.

rds Bego
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: Setting up UE to run the Python interpreter?

Postby JohnJSal » Wed Mar 15, 2006 9:32 pm

Thanks again! I'll do some testing when I get home. :)
User avatar
JohnJSal
Advanced User
Advanced User
 
Posts: 60
Joined: Sat Mar 05, 2005 12:00 am

Re: Setting up UE to run the Python interpreter?

Postby JohnJSal » Thu Mar 16, 2006 2:11 am

Well, I'm not having much luck. I tried a few things, but nothing seems to happen. But I've narrowed down exactly what I want, so maybe this will help: instead of trying to load the current file into some other application, all I really need to do is run it just as if I had double-clicked on it. I tried using just "%f", but that didn't do anything.
User avatar
JohnJSal
Advanced User
Advanced User
 
Posts: 60
Joined: Sat Mar 05, 2005 12:00 am

Re: Setting up UE to run the Python interpreter?

Postby Bego » Thu Mar 16, 2006 6:21 am

hmmm ....

- If you double-click on the file from explorer, does it start then ?
- You are working on a SAVED file, don't you ?
- You are working on a local Windows file, NOT working on a FTP file ?

If you got 3 "Yes" here, I don't have any more ideas why it doesn't work ...

rds Bego
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: Setting up UE to run the Python interpreter?

Postby JohnJSal » Thu Mar 16, 2006 2:58 pm

Yes for the first two, not sure about the third because it's actually a DOS window that gets run, not a regular Windows program. Not sure if that affects anything, but I've tried checking and unchecking the option of a Windows program in the Tools Configuration, and neither worked.

I've tried putting %f, %F, "%f" and "%F" in the command line, and I've also tried it with the command path of the python program itself, but nothing works.

I have noticed, however, that after running the tool, 'python.exe' is a running process in my task manager, so perhaps it is somehow running it, but for whatever reason I don't see anything on the screen.
User avatar
JohnJSal
Advanced User
Advanced User
 
Posts: 60
Joined: Sat Mar 05, 2005 12:00 am

Re: Setting up UE to run the Python interpreter?

Postby mjcarman » Fri Mar 17, 2006 2:20 am

Try this, where "*" and "x" indicate radio and checkbox selections.

Code: Select all
Command line: python "%f"
Working Directory: %P
Menu Item Name: Run Python Script
[ ] Windows Program
[ ] Save all files first
[x] Save Active File
( ) Append to Existing
(*) Replace Existing
( ) Create New File
( ) Output to List Box
[x] Show DOS Box
[x] Capture Output

If Python isn't in your path, provide the full path on the command line.
User avatar
mjcarman
Power User
Power User
 
Posts: 125
Joined: Thu Feb 10, 2005 12:00 am

Re: Setting up UE to run the Python interpreter?

Postby JohnJSal » Fri Mar 17, 2006 2:45 am

Thanks! I think it was the "Show DOS Box" option that was tripping me up. Even if I put just "%f" in the command line, and nothing in the working directory, it still works now.

Thanks again! :)
User avatar
JohnJSal
Advanced User
Advanced User
 
Posts: 60
Joined: Sat Mar 05, 2005 12:00 am

Re: Setting up UE to run the Python interpreter?

Postby mjcarman » Fri Mar 17, 2006 2:23 pm

JohnJSal wrote:Even if I put [...] nothing in the working directory, it still works now.

The working directory sets the enviroment for the running program. So if (e.g.) you want to open a file in the same directory as the script, you should set it.
User avatar
mjcarman
Power User
Power User
 
Posts: 125
Joined: Thu Feb 10, 2005 12:00 am

Re: Setting up UE to run the Python interpreter?

Postby JohnJSal » Fri Mar 17, 2006 2:49 pm

Yeah, I did set it, after all. But I had to use %P, because "%p" gave me an error for some reason.
User avatar
JohnJSal
Advanced User
Advanced User
 
Posts: 60
Joined: Sat Mar 05, 2005 12:00 am


Return to Custom User Tools/Tool Configuration