-
Content Count
778 -
Joined
-
Last visited
-
Days Won
41
Posts posted by pyscripter
-
-
You can either install python and PyPDF2 in the target machine or distribute an embedded version of Python with your app. If you follow the second route, have a look at Embarcadero/PythonEnviroments: Components to simplify the deployment for Python environments for Delphi applications using Python4Delphi. (github.com).
-
5 hours ago, Eezygzy said:I have just installed Python4Delphi.
Did you use the GetIt version?
If not have you read Installation · pyscripter/python4delphi Wiki (github.com)?
-
Vcl issues
in VCL
I have recently submitted two Vcl related quality issue reports:
The first one relates to a change in TCustomForm.SetParent introduced in Delphi Alexandria. It broke docking behaviour, but there may be other applications affected. One way to work around it is to set the form AutoScroll property to True. Question: Are there any undesired consequences of doing this?
The second report relates to the fact that TControlForm.ChangeScale is not used and there is no good available options to achieve what you do when you overwrite ChangeScale in custom controls. Question: Am I missing something? Is there a good way to execute some code whenever the form dpi is changed?
-
Have you read these:
-
On 3/24/2021 at 2:07 AM, Vincent Parrett said:I tried to fudge a BeginUpdate/EndUpdate with this :
This is an old thread, but I have just noticed that Delphi 11 deals with this issue by calling the new LockDrawing/UnlockDrawing wrapper around WM_SETREDRAW in DoBeforeMonitorDpiChanged/DoAfterMonitorDpiChanged. They have also fixed https://quality.embarcadero.com/browse/RSP-30931.
It seems to work reasonably well now.
-
It turns out that the causes of LSP failure were more complex than I originally thought.
In the attached project in TestCI-JclSysUtils LSP does not work. The project is relatively simple. It has three units
- Unit1.pas (a form with one button)
- uCommonFunctions.pas (contains three functions)
- JclSysUtils (an exact copy of the Jcl unit)
With Jcl installed it compiles and runs fine.
Here is the interesting thing. LSP starts working if:
- either you remove an unused import of JclPeImage from the uses clauses of uCommonFunctions
- or you remove the "forked" JclSysUtils from the project.
Looks like LSP is a lot more fragile than is should be. I was without IDE support in my a project, since Delphi 11.2 was released and it took substantial effort and a bit of luck to restore it.
- 1
-
You are right. It works with WinApi.Messages.
I have added another project with JclSysUtils instead of WinApi.Messages. The project will compile fine if you have Jcl installed. LSP fails with that project. It also fails if you use System.Variants instead of WinApi.Messages. But in that case the project does not compile.
I will try to find out what triggers the failure.
-
@Brandon Staggs Could you please try the minimal project attached to the QA report. Does it work for you?
I think the bug affects units that either use directly the forked units or units that depend on such units.
-
See [RSP-41949] LSP does not work when project includes modified file found in the search path - Embarcadero Technologies for details. Has anyone been bitten by this?
Code Insight now works in my PyScripter project. I thought that cyclic unit dependencies may be the cause and spent quite a bit of time reducing them. I guess, that this was time well spent, but it was not the source of the LSP failures.
-
PyScripter has reached 1.5 million downloads. This is just from Sourceforge and does not include downloads from Embarcadero, many other download sites and forks such as GuiPy. What is quite satisfying is that there is no country in the world without downloads. Greenland for instance, a vast country with a population of only 56000, has 7 downloads.
- 5
- 4
-
When I debug my application, just before exiting, I see some strange messages in the Events log, such as:
Debug Output: onecore\com\combase\winrt\error\restrictederror.cpp(945)\combase.dll!00007FFD636832D1: (caller: 00007FFD6358BCC5) ReturnHr(4) tid(b80) 80070490 Element not found. Process PyScripter.exe (14872)
All messages are related to winrt, however I am not explicitly using winrt. Any clues? Should I worry?
-
Could you post a sample project that demonstrates the issue?
-
If you want to preserve globals in script execution you need to use the ExecString(s) overload with the locals, globals parameters.
-
Firstly, let me say that my work on SynEdit has moved back to pyscripter/SynEdit for reasons explained here.
The newest enhancement to SynEdit is accessibility support. Now, SynEdit fully supports screen readers such as Windows Narrator and NVDA. The support is much better than, for instance, in Visual Studio Code. The implementation is not based on the older Microsoft Active Accessibility (MSAA), but on the newer Microsoft UI Automation. Microsoft UI Automation has been around since 2005 and is available to all Windows versions, since Windows XP. In addition to making applications accessible, it can also be used by automated UI testing tools.
Despite been available for almost 20 years, Delphi does not provide the relevant header translations (See RSP-41898), which complicated the implementation. I also could not find any other complete Delphi implementation of UI automation. So, the SynEdit implementation may serve as a guide to how to implement UI Automation in other controls. Further details can be found here.
- 6
- 2
-
Python code needs to be properly indented (see for instance Python Indentation (w3schools.com)). Otherwise you will get the IndentationError you show above.
If you want to built your own interpreter, a good starting point is the InteractiveInterpeter class of the code module. The runsource method will tell you whether the input is incomplete and more input is required.
-
I am not sure what the issue you are trying to solve is.
You can have the statement:
from oct2py import Oct2Py
or just
import oct2py
within different python modules or functions.
It does not result in the module being reimported. If it has been already imported it just uses the already imported one and there is no speed penalty.
The same applies to the VarPyth Import statement.
-
-
Demo32 demonstrates how to use PyArg_ParseTupleAndKeywords.
-
-
function TPyPoint.SetAttr(key : PAnsiChar; value : PPyObject) : Integeris called whenever a property is set (e.g. spam.myPoint.x = 10). So you can take an action when the object is modified.
However you are not notified when spam.myPoint is assigned a value.
To do what you would have to override the __setattr__ on the module, but this is too complicated.
-
On 5/18/2023 at 8:05 PM, xpert13 said:Is there any way to immediately terminate script it waiting for
timer.sleep
Code from demo 33 doesn't help in this situation. The same issue if script is waiting for answer for http request.
See multithreading - Python threading interrupt sleep - Stack Overflow for alternatives to sleep that can be interrupted.
-
from io import StringIO import sys old_stderr = sys.stderr sys.stderr = mystderr = StringIO() # examine mystderr.getvalue()
-
I wrote the code without testing, just to give you the idea. Good that you solved the problem.
Also instead of MainModule.builtins._input_prompt you can use BuiltinModule._input_prompt.
And the following would do. No need to convert to AnsiString and back.
procedure TForm1.PythonInputOutput1ReceiveUniData(Sender: TObject; var Data: string); begin InputQuery( 'Query from Python', BuiltinModule._input_prompt, Data); end;
- 1
-
Run a script like this:
import builtins def myinput(prompt): builtins._input_prompt = prompt builtins._input(prompt) builtins._input = builtins.input builtins.input = myinput
Then the prompt will be stored in builtins._input_prompt
Module "sentence_transformers" import in P4D not possible
in Python4Delphi
Posted
Did you mask exceptions (MaskFPUExceptions · pyscripter/python4delphi Wiki (github.com)?
If yes, have you checked sys.version and sys.path to make sure they are the same as in stand alone python?