Recent

Author Topic: Preventing Application Freeze During User Input in Lazarus Python Script  (Read 856 times)

babycode

  • Newbie
  • Posts: 3
I have a Python script that asks for user input:

Code: Pascal  [Select][+][-]
  1. confirmation = input("Enter confirmation (Y/S")

In a program written with the Lazarus IDE I inserted the TPythonEngine and TPythonGUIInputOutput components from the PythonForLazarus component library.

TPythonEngine.IO is pointing to TPythonGUIInput and this in turn has TPythonGUIInput.Output pointing to a Memo. When I run the Python script using TPythonEngine.ExecStrings(TListStrings), in the user input part, the Lazarus InputQuery is displayed for the user to enter the option but the application is frozen waiting for the user input, that is, the InputQuery (box ) freezes the application until the user enters the value. How do I ensure that the user can continue using the application window before entering data into InputQuery?


marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11453
  • FPC developer.
Re: Preventing Application Freeze During User Input in Lazarus Python Script
« Reply #1 on: November 15, 2023, 09:48:31 am »
See if python has some event that you can plug while it is waiting for input and call application.processmessages in it.

babycode

  • Newbie
  • Posts: 3
Re: Preventing Application Freeze During User Input in Lazarus Python Script
« Reply #2 on: November 15, 2023, 06:53:25 pm »
Could you be a little more specific please? I'm new with lazarus and python. I would be happy if you could show an example.   :D

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11453
  • FPC developer.
Re: Preventing Application Freeze During User Input in Lazarus Python Script
« Reply #3 on: November 15, 2023, 07:22:21 pm »
I don't know python, but lazarus must run its mainloop.  (which is what application.processmessages does).

If python can run code while it is waiting for input, you must run that.

babycode

  • Newbie
  • Posts: 3
Re: Preventing Application Freeze During User Input in Lazarus Python Script
« Reply #4 on: November 15, 2023, 08:05:12 pm »
Is it possible to change the default InputQuery at runtime? When the inputquery is called, does it execute another form instead?

 

TinyPortal © 2005-2018