python tool not working interactively

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
jazzastronomer
Posts: 36
Joined: Sat Nov 03, 2007 3:04 am

python tool not working interactively

Post by jazzastronomer »

I have set python as a tool in Textpad. It works in a non-interactive mode. However it fails when I run a script which requires user input, all I get is a spinning circle. Here is my present configuration

Code: Select all

Command:	my path to \Python\Python313\python.exe
Parameters:	$File	
Initial folder:	$FileDir	
N	Prompt for parameters
N	Run minimized
N	Save all documents first
Y 	Capture output
N 	Suppress output until completed 
N 	Sound alert when completed
Here is a sample interactive code:

Code: Select all

# Simple interactive Python script

def main():
    name = input("Enter your name: ")
    print(f"Hello, {name}!")

if __name__ == "__main__":
    main()
User avatar
AmigoJack
Posts: 549
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Re: python tool not working interactively

Post by AmigoJack »

jazzastronomer wrote: Sun Jan 19, 2025 10:50 pmIt works in a non-interactive mode.
You cannot even set up a tool in interactive mode. It doesn't matter if you "just" execute python.exe with parameters (speak: parsing a script) or without - in sum it is always python.exe which outputs to STDOUT (or STDERR) or wants to wait for input on STDIN. However, for TextPad the "tool" is expected to only capture STDOUT output - if the program wants input it is not suited to be executed as tool by TextPad.

Recode your script to use program parameters.
User avatar
bbadmin
Site Admin
Posts: 903
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Re: python tool not working interactively

Post by bbadmin »

As AmigoJack wrote, TextPad only captures STDOUT. The intention is to capture the output of tools such as compilers and then be able to jump to lines corresponding to any flagged with errors.

What advantage would it be to you, if you could interact with your script within TextPad? If it's just convenient to be able to run it from TextPad, configure it as a Command Prompt tool like this:

2025-01-21.png
2025-01-21.png (44.43 KiB) Viewed 20 times
jazzastronomer
Posts: 36
Joined: Sat Nov 03, 2007 3:04 am

Re: python tool not working interactively

Post by jazzastronomer »

Thanks for the explanations much appreciated. There is an old saying "If you don't use it, you loose it!" which clearly is what is happening to me. It has been many a year since I last did any scripting.

I got around my issue by running these scripts from Idle. Idle works as a tool in Textpad.

On a humorous note, did you know that there is a file in windows 11 that looks like the installed python executable, but if you use that file in your python tool in Textpad you get a message directing you to the Microsoft Store to download python? Guess how I found this out! For more info Google "CMD opens Windows Store when I type 'python'"

it has been a weird couple days
Post Reply