-
Content Count
151 -
Joined
-
Last visited
Posts posted by softtouch
-
-
I have a TComboBoxEx with items in it. Each item has an icon assigned, so far so good.
When I click into the editbox to enter a new item name, there is no icon of course, but instead a weird space to the left (see attached image).
Is there any way to have a default icon displayed in the editbox of the TComboBoxEx?
-
If command
in VCL
... the :='True' should be ='True'...
-
2 hours ago, PeterPanettone said:Click the Requests button.
Yes, that will just return "We couldn’t find any requests"
-
7 hours ago, Ian Branch said:Reported - RSS-475 in the new Quality Portal.
Just wanted to read and comment on it, but that weird new portal does not list any report for me.
-
It uninstalled my 12 update 1 version and I had to reinstall all components again 😞
-
7 minutes ago, pyscripter said:Note that if you get the PyObject corresponding to the function by using for instance
var PyMainModule: PPyObject; PyFunc: PPyObject; PyMainModule := GetPythonEngine.GetMainModule; PyFunc := GetPythonEngine.PyObject_GetAttrString (PyMainModule, PAnsiChar(AnsiString(method_name))); // When you finish with PyFunc you need to decrease the refcount
You can then call the function in a number of different ways including the relatively high level:
function EvalFunction(pyfunc:PPyObject; const args: array of const): Variant;
Thank you! This is actually working just fine!
-
I did, but I cant get it to work unfortunately. Anyway, thanks for your help.
-
7 hours ago, pyscripter said:@Remy Lebeau approach should work. (not tested)
Alternatively you can use the more efficient:
var PyMainModule: PPyObject; PyMainModule := GetPythonEngine.GetMainModule; GetPythonEngine.PyObject_CallMethod (PyMainModule, PAnsiChar(AnsiString(method_name)), nil);
Thank you, but how can I provide parameter to the call when using this approach like result:=MainModule.ClickElement_ByXPATH(param1,param2,param3...)
-
6 minutes ago, Remy Lebeau said:How are you calling Python functions from Delphi code to begin with?
Via MainModule.<pythonfunction name here> (TPythonModule of P4D)
If the python function ClickElement_ByXPATH exist, I call it like MainModule.ClickElement_ByXPATH();
-
1 hour ago, Remy Lebeau said:Are you wanting to call a Python function dynamically from Delphi code? Or call a Delphi function dynamically from Python code? Its not clear what you are looking for. Can you provide an example?
I want to call python functions. Their names are in a stringlist.
With other words, how could I call a python function when the function name is a string?
Example: var s:='ClickElement_ByXPATH';
How can I call the corresponding python function, which has exactly that name?
-
Lets say I have an array with the following 2 strings in it:
ClickElement_ByXPATH
ClickElement_ByCSSSelector
I have Python function with the same name, so I could call MainModule.ClickElement_ByXPATH or MainModule.ClickElement_ByCSSSelector, which works.
Is there any way to create the funcname in the call MainModule.<funcname> based on the strings in the stringlist?
For example, when I get the first item in the stringlist (ClickElement_ByXPATH), how could I create a call to MainModule.<here the element from the stringlist>, similar I can do with rtti and delphi functions, so it would call MainModule.ClickElement_ByXPATH? With other words, creating the call based on the text in a stringlist.
-
1 minute ago, Stano said:Isn't it enough to just make it inaccessible?
I just set DefaultDraw to false in onCustomDrawItem for that dummy item, and I have now the group header with an invisible item and no checkbox for that, so thats all fine so far.
-
55 minutes ago, Remy Lebeau said:Unfortunately no. Empty groups are not displayed, that is simply how Microsoft implemented it. So, the only option would be to add a blank item to the group just to keep it visible, and then remove that item later when it is no longer needed.
Thanks for the hint with the blank item. Now I just need to find a way to hide the checkbox for that blank item.
-
I have a listview with groups and items. User can drag/drop items between groups. But when they move the last item of a group to another group, that group become invisible, so they cant move items back to that group.
Is there any way to keep groups visible at all time, even they have no items assigned to them?
-
Sorry for the late replay. I believe I found the issue, its related to selenium somehow. Once I use selenium, freeing the module takes 5 seconds, even the selenium driver was already closed earlier.
-
A minimum example, which works just fine but cause the delay, and I cant figure out why that is.
In form create:
procedure TfrmTest.FormCreate(Sender: TObject); begin eng:=TPythonEngine.Create(nil); eng.DllName:='python312.dll'; eng.DllPath:=pythonhome; module:=TPythonModule.Create(nil); module.Engine:=eng; module.ModuleName:='delphicallback'; module.OnInitialization:=InitPythonModule; eng.LoadDll; end;
In form close:procedure TfrmTest.FormClose(Sender: TObject; var Action: TCloseAction); begin eng.Free; // Takes 5 seconds to return once the python script called the delphi method end;
The InitPythonModule has just this one line:procedure TfrmTest.InitPythonModule(Sender: TObject); begin TPythonModule(Sender).AddDelphiMethod('callback',delphi_callback,'callback(name, value)->value'); end;
The delphi method "delphi_callback" only does this for testing:function TfrmTest.delphi_callback(pself, args: PPyObject): PPyObject; var key:pansichar; value:PPyObject; begin with GetPythonEngine do begin if PyArg_ParseTuple(args, 'sO:callback', @key, @value) <> 0 then begin result:=PyUnicodeFromString('Test'); end; end; end;
Calling the python scriptprocedure Tfrmtest.btntestClick(Sender: TObject); begin eng.ExecFile(<the script file path here>); s:=MainModule.Test('Hello world'); end;
The python script does this for testing:import delphicallback def Test(s:str)->str: delphicallback.callback('testing',s)
-
I stopped the time and it takes around 5 second until the .free returns. If I dont free it and just free the pythonengine, that will take 5 seconds (I guess for releasing the module). It definitely only take so long when the delphi function was called once from python, even the delphi function does not do anything. If I dont call the delphi function from python, there is no delay at all.
-
I create a TPythonModule, and add a delphi methode in the OnInitialization event of the module with TPythonModule(Sender).AddDelphiMethod('....') to it.
If I dont call the method from Python, module.free is instantly, but once I have called this delphi method, even the method does noting, it takes a couple of seconds for module.free to return.
Is there something I need to do to prevent this delay?
-
A TEdgeBrowser is on a form and has a webpage loaded, and the devtools windows is open also. Is there any way to get a notification when the user right-click in the devtools window an element and select "copy->XPATH"? I need to close in that case the browser form and get the text from the clipboard to process is further.
-
-
35 minutes ago, Cristian Peța said:That would be Delphi4Python.
Otherwise you need a inter-process communication. For example your Delphi code can run in REST server.
I know, I use P4D...
I can call python funtions from delphi, but this time, I need it the other way around, calling a delphi function from python.
-
I have a python script which does some website work, and at one point in that script, it has to call a Delphi function with a byte array as parameter, and will have to get a string back from the Delphi function and continue the script execution.
How can I realize that? I googled but its mostly the other way around, calling a python function from delphi.
-
1 hour ago, pyscripter said:uses VarPyth; ... var Res, S: string; PythonEngine1.ExecStrings(sl); Res := MainModule.Parser(S);
It would help to watch the tutorial videos and play with the Demos.
Ok, that seems to work as expected. Thanks.
-
I am playing for the first time a little with Python4Delphi.
When I have a python function, for example:
def Parser(src:str) -> str: s = "Test " + src return s
How do I call this from Delphi?
I have this script in a stringlist, and can call
PythonEngine1.ExecStrings(sl);
But how do I set the parameter "src" before calling the script, and how do I get the "s" value back after the call?
RAD Studio 12.1 Athens Patch 1 Available
in Delphi IDE and APIs
Posted
The patch is available via getit, I just installed it.