Comments (11)
Issue 18 has been merged into this issue.
Original comment by pyscripter
on 2 Nov 2011 at 1:45
from python4delphi.
Have you looked into WrapDelphi and the relevant demos? This is exactly what
WrapDelphi does, although it does not use the improvements in RTTI since Delphi
2009. However it does make it very easy to expose Delphi objects to Python.
Original comment by pyscripter
on 8 Nov 2011 at 9:27
from python4delphi.
Thanks for the hint! It's much easier then Demo08.
Original comment by [email protected]
on 10 Nov 2011 at 1:21
from python4delphi.
I've changed wrapdelphi.pas to use TRttiContext when delphi version is
DELPHIXE_OR_HIGHER. How I can contribute with this project?
Original comment by [email protected]
on 28 Jan 2012 at 4:52
Attachments:
from python4delphi.
Thanks, I will review the changes and merge them.
Original comment by pyscripter
on 28 Jan 2012 at 4:43
from python4delphi.
Now, python code like "Form1.Memo1.Lines.Add('New line')" is working!
But "print Form1.Memo1.Text" is not working.
Please add 'tkUString' to line 1551.
Original comment by [email protected]
on 4 Feb 2012 at 10:12
from python4delphi.
Sounds great!
Original comment by [email protected]
on 5 Mar 2012 at 9:00
from python4delphi.
@ pyscripter,
Have you merged WrapDelphi.pas by Alexandre into the python4delphi project
already? Thanks!
Original comment by [email protected]
on 26 May 2012 at 8:53
from python4delphi.
Sorry about the delay in getting back to you on this. I have tried merging the new RTTI staff, but after some effort, I still cannot get demo 31 to work without errors. The attached file contains the modified WrapDelphi.pas. If anyone can bring this to a state where all the tests of demo 31 pass, I will happily merge it.
from python4delphi.
i download the wrapdelphi.pas
found some error
1γ
procedure TPyDelphiWrapper.CreatePyFunc(AModule: TPythonModule; AMethodDef: PPyMethodDef);
var
d : PPyObject;
begin
if Assigned(FModule) and FModule.Initialized then
with GetPythonEngine do
begin
d := PyModule_GetDict(FModule.Module);
Assert(Assigned(d));
if IsPython3000 then
PyDict_SetItemString( d, AMethodDef^.ml_name, PyCFunction_NewEx(AMethodDef, nil, nil))
else
PyDict_SetItemString( d, AMethodDef^.ml_name, PyCFunction_New(AMethodDef, nil));
end;
end;
2 γwhen triiger draw ,report accesse error .
def grdTestDrawCell(self, Sender, Col, Row, Rect, State):
Sender.Canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2, "%d " % (Col))
from python4delphi.
Implemented:
- Major refactoring and clean-up
- In Delhi version newer than XE, enhanced RTTI is used to provide access to
methods, fields and properties. So in most cases you no longer need to
create wrapping classes. - published property was replaced with the implementation of the dir()
method, so that you can do for example dir(MainForm) to inspect the
methods, fields and properties of MainForm. - Demo 31 has been updated to test/showcase some of the new features.
Study the updated demo 31 to see the improvements.
For example with the following definitions:
type
TFruit = (Apple, Banana, Orange);
TFruits = set of TFruit;
TTestRTTIAccess = class
private
FFruit: TFruit;
FFruits: TFruits;
public
FruitField :TFruit;
FruitsField: TFruits;
StringField: string;
DoubleField: double;
ObjectField : TObject;
procedure BuyFruits(AFruits: TFruits);
procedure SetFormCaption(Form: TForm; ACaption: string);
property Fruit: TFruit read FFruit write FFruit;
property Fruits: TFruits read FFruits write FFruits;
end;
and the code:
p := PyDelphiWrapper.Wrap(TTestRTTIAccess.Create, soOwned);
PythonModule.SetVar( 'rtti_var', p );
PyEngine.Py_DecRef(p);
You can do in Python:
def testRttiAccess(self):
if DelphiVersion >= 15:
rtti_var.Fruit = 'Apple'
self.assertTrue(rtti_var.Fruit == 'Apple')
rtti_var.Fruits = ['Apple', 'Banana']
self.assertTrue(rtti_var.Fruits == ['Apple', 'Banana'])
rtti_var.BuyFruits(['Apple', 'Orange'])
self.assertTrue(rtti_var.Fruits == ['Apple', 'Orange'])
rtti_var.SetFormCaption(MainForm, 'From TTestRTTIAccess')
self.assertEqual(MainForm.Caption, 'From TTestRTTIAccess')
rtti_var.FruitField = 'Apple'
self.assertTrue(rtti_var.FruitField == 'Apple')
rtti_var.FruitsField = ['Apple', 'Banana']
self.assertTrue(rtti_var.FruitsField == ['Apple', 'Banana'])
rtti_var.StringField = 'Hi'
self.assertTrue(rtti_var.StringField == 'Hi')
rtti_var.DoubleField = 3.14
self.assertTrue(rtti_var.DoubleField == 3.14)
rtti_var.ObjectField = MainForm
MainForm.Caption = 'From TTestRTTIAccess.ObjectField'
self.assertTrue(MainForm.Caption == 'From TTestRTTIAccess.ObjectField')
from python4delphi.
Related Issues (20)
- Running Demos from Delphi-12 HOT 1
- Pagecontrol.ActivePage wrapper function causes AV error HOT 8
- "demo33 -- three interpreter" causes the thread to hang. HOT 7
- floating point division by zero HOT 1
- python dll HOT 1
- VarPyIterate raises EPyStopIteration exception with message 'Stop Iteration' HOT 2
- numpy and TTask HOT 8
- Running python code in Delphi threads issue HOT 1
- Pyhton4Delphi and streamlit HOT 3
- How to specify the path to Python libraries? HOT 4
- Run the .py file immediately with parameters HOT 8
- How can I output the results of a py script? HOT 9
- OnSendUniData event does not work HOT 4
- Wrongly throwing an exception from the wrapping object HOT 2
- A little problem HOT 2
- Error in ExtractPythonObjectFrom when creating Enum? HOT 1
- [dcc64 fatal error] PythonVcl.dpk: F2084 Internal Error on RAD Studio 12.1 HOT 6
- Minor: Typo in error message
- Pandas with Python 3.12 HOT 12
- using python4delphi via compiled DLL, avoids reading variables from python to delphi HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python4delphi.