-
Content Count
920 -
Joined
-
Last visited
-
Days Won
56
Everything posted by pyscripter
-
Found why LSP stopped working in Delphi 11.2 and 11.3
pyscripter replied to pyscripter's topic in Delphi IDE and APIs
@programmerdelphi2k 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. -
Found why LSP stopped working in Delphi 11.2 and 11.3
pyscripter replied to pyscripter's topic in Delphi IDE and APIs
@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. -
Development of SynEdit at PyScripter has been moved to and merged with TurboPack SynEdit. The focus of the development is to modernize the code base and enhance the functionality (sometimes at the expense of backward compatibility). In addition to the earlier enhancements and fixes two more features have been recently added: Per-monitor DPI awareness Support for Font Ligatures (new option eoShowLigatures) Fonts like Cascadia Code and Fira Code contain ligatures relevant to programming. See this article for details. Are you using font ligatures? Do you like them? See sample. Thanks to vhanla for contributing the ligature support.
-
PyScripter, an Open Source, freely available Python IDE written in Delphi, has reached 1 million downloads from Sourceforge. This is in addition to many millions of downloads from its earlier home at the now defunct Google Code and an unknown number of downloads from other distribution channels. Historic note: The initial motivation was to build a good scripting solution for Delphi applications. About 20 years ago Microsoft was still promoting ActiveX scripting and Windows Script Engines (such as vbScript and jScript) as the way of building scripting solutions for Windows applications (one of many Microsoft technologies that was all but abandoned). At that time Python was relatively unknown, but it so happened that it was available as a Windows Script Engine and I looked into it. I loved the clean syntax, the expressiveness and conciseness of the language. Other things I liked were duck typing, batteries included, strong object orientation (everything is an object) etc.. The first iteration was an IDE (editor/debugger) for ActiveX Script Engines. But there were many bugs and limitations of Active Scripting both on the Microsoft/Windows side and the Python side. I then came across Python4Delphi which at the time was maintained by a Canadian developer Morgan Martinet. I started contributing to that project and later become its main maintainer, when Morgan's interested shifted to other things. I also developed a simple Python IDE which was named PyScripter and was originally distributed alongside Python4Delphi. There was very few Python IDEs available at the time and somehow the project became known in the Python community and instantly popular. For me, developing PyScripter was just a hobby, but I received a lot of encouragement and kept on improving it. I was also making some income from donations and Google AdSense. Both PyScripter and Python4Delphi were later moved to Google Code. Python popularity was steadily increasing and at the peak of PyScripter's popularity around 2010, there were hundreds of thousands of downloads the days following each new release. More recently as we all know Python became one of the most popular programming languages, but at the same time there was strong competition to PyScripter from freely available commercial grade IDE's such as Jetbrains PyCharm and Microsoft's Visual Studio and Visual Studio Code. PyScripter was almost abandoned when Google Code closed down due to my frustration, but after a couple of years of inactivity the project was moved to Github and development resumed. Downloads are available through Sourceforge, since 2016. Through the years PyScripter has kept a large and loyal group of followers. I get many comments along the lines "I have tried VSCode, I have tried PyCharm, but I keep going back to PyScripter". PyScripter is also quite widely used in many Universities for introducing Python to students. And almost 20 years after its first release, PyScripter is still going strong...
-
PyScripter reached 1 million downloads from Sourceforge
pyscripter replied to pyscripter's topic in I made this
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. -
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?
-
How can globals be shared amongst multiple modules?
pyscripter replied to RSG's topic in Python4Delphi
Could you post a sample project that demonstrates the issue? -
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.
-
How can globals be shared amongst multiple modules?
pyscripter replied to RSG's topic in Python4Delphi
If you want to preserve globals in script execution you need to use the ExecString(s) overload with the locals, globals parameters. -
Handling Python indented blocks with ExecString()
pyscripter replied to RSG's topic in Python4Delphi
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. -
How can globals be shared amongst multiple modules?
pyscripter replied to RSG's topic in Python4Delphi
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. -
In an earlier thread I presented an Interface-based access to native Windows (Direct2D) SVG support for Delphi applications. This has now been integrated into the SVGIconImageList components by @Carlo Barazzetta. Carlo is a kind of master of ImageLists (among other things). Have a look at his IconFontsImageList for instance. His SVGIconImageList component was based on the work of Martin Walter who must be a great programmer. His SVG component covered almost every SVG element and was well structured and cleanly written. There were numerous bugs and issues though, which, to a large extent, were fixed over the last few weeks and the code was refactored and optimized. Finally, @Vincent Parrett contributed a virtual version of the Image List, mirroring Delphi's VirtualImageList. So in its current form the component features: An SVGImageCollection component that inherits from Delphi's CustomImageCollection and thus is compatible with VirtualImageList A choice of SVG engines: the pascal one based on Martin's work which is using GDI+ and the native Windows one which is using Direct2D. Other SVG engines can be plugged-in with minimum effort. Excellent design support with a nice and effective SVGImageCollection editor developed by Carlo and the built-in VirtualImageList editor. Support for changing the opacity and color of the SVGs including using GrayScale. If you adopt Material Design for example and you use VCL styles, you can adjust the icon color to the style. Compatibility with older Delphi versions going back to XE6. It is free and open-source Svgs are vastly superior to bitmaps because they are typically tiny text files and scale perfectly. So, you do not need to ship with your application multiple resolutions of your images to match the DPI of the monitors. And there is a vast number of free SVGs to cover most needs. IMHO the combination of SVGImageCollection with Delphi's VirtualImageList is the best available solution (commercial ones included) for building DPI-aware Windows applications. Give it a try.
-
Calling python scripts. Returning python output.
pyscripter replied to marcovth's topic in Python4Delphi
See Demo1. -
Demo32 demonstrates how to use PyArg_ParseTupleAndKeywords.
-
Not so simple: python - Overriding __setattr__ at runtime - Stack Overflow
-
function TPyPoint.SetAttr(key : PAnsiChar; value : PPyObject) : Integer is 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.
-
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;
-
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
-
Dictionaries are downloaded via Windows Language preferences. You just select the language as in the demo.
-
The KeyboardInterrupt is the correct way to terminate a thread from the main thread. This is because print statement executes without clearing the KeyboardInterrupt exception. You need to trap the KeyboardInterrupt exception either in Python or Delphi code. You can also add to your PythonInputOutput1SendUniData with GetPythonEngine do if PyErr_Occurred <> nil then begin PyErr_Clear; Exit; end;
-
How are you exiting the thread? Are you raising a KeyboardInterrupt as in demo 33? Then why are you surprised that an exception is raised, when the print statement executes. You can modify your script as follows (not tested): while True: try: time.sleep(0.1) print(datetime.now()) except KeyboardInterrupt: break or handle the exception in your Delphi code
-
You are producing output at a high speed from a thread. You need to buffer the output in a way similar to that in python4delphi/Unit1.pas at master · pyscripter/python4delphi (github.com).
-
Yes indeed! P4D makes it quite easy. The TStrings wrapper does that for instance.