freelanceprogrammers.org Forum Index » Delphi

free object in demo31


View user's profile Post To page top
tocer_deng Posted: Wed May 17, 2006 5:56 pm


Joined: 17 May 2006

Posts: 32
free object in demo31
Hi:

I found some python code I don`t understand in demo31.such as:

myform = CreateComponent(`TForm`,None)

but I don`t found myform is destroyed. but other code is different,such as:

f = TTestForm(Application)
try:
print f.ShowModal()
finally:
f.Free()

why?

--tocer
Reply with quote
Send private message
View user's profile Post To page top
morgan_martinet Posted: Wed May 17, 2006 7:50 pm


Joined: 29 Apr 2005

Posts: 103
free object in demo31
CreateComponent is a helper function that creates a Delphi object if it was
properly registered with the VCL API RegisterClass.
f = TTestForm(Application) is a special notation that will instanciate an
existing form which class is TTestForm. This is a way to extend a form you
already designed for your application.
You mus subclass the Form type and name your class with the exact same name
as the Delphi type:

class TTestForm(Form):
def __init__(self, Owner):
self.Caption = self.Caption + ` - changed by Python subclass`
self.BindMethodsToEvents()

f.Free() will simply make sure that your form is destroyed immediately,
without relying on Python garbage collector. Note that this can be used only
if the wrapper owns the object.

> -----Original Message-----
> From: pythonfordelphi@yahoogroups.com
> [mailto:pythonfordelphi@yahoogroups.com] On Behalf Of tocer
> Sent: Wednesday, May 17, 2006 8:57 AM
> To: pythonfordelphi@yahoogroups.com
> Subject: [pythonfordelphi] free object in demo31
>
> Hi:
>
> I found some python code I don`t understand in demo31.such as:
>
> myform = CreateComponent(`TForm`,None)
>
> but I don`t found myform is destroyed. but other code is different,such
> as:
>
> f = TTestForm(Application)
> try:
> print f.ShowModal()
> finally:
> f.Free()
>
> why?
>
> --tocer
>
>
>
>
>
> To Post a message, send it to: pythonfordelphi@eGroups.com
>
> To Unsubscribe, send a blank message to: pythonfordelphi-
> unsubscribe@eGroups.com
> Yahoo! Groups Links
>
>
>
>
Reply with quote
Send private message
View user's profile Post To page top
tocer_deng Posted: Wed May 17, 2006 8:41 pm


Joined: 17 May 2006

Posts: 32
free object in demo31
Thanks Morgan, I understand more and more.

now I also another simple question. what is "__bound__" in demo31?

I wish I don`t bother you.

--tocer

Morgan Martinet wrote::
> CreateComponent is a helper function that creates a Delphi object if it was
> properly registered with the VCL API RegisterClass.
> f = TTestForm(Application) is a special notation that will instanciate an
> existing form which class is TTestForm. This is a way to extend a form you
> already designed for your application.
> You mus subclass the Form type and name your class with the exact same name
> as the Delphi type:
>
> class TTestForm(Form):
> def __init__(self, Owner):
> self.Caption = self.Caption + ` - changed by Python subclass`
> self.BindMethodsToEvents()
>
> f.Free() will simply make sure that your form is destroyed immediately,
> without relying on Python garbage collector. Note that this can be used only
> if the wrapper owns the object.
Reply with quote
Send private message
View user's profile Post To page top
morgan_martinet Posted: Thu May 18, 2006 4:40 pm


Joined: 29 Apr 2005

Posts: 103
free object in demo31
Hi,

If you look at the version history in WrapDelphi.pas, you`ll find:
- added property __bound__ to TPyDelphiObject, to know if the wrapper is
still bound to the instance.
- added property __owned__ to the base Delphi wrapper, to know if the
wrapper owns the underlying
object or not.

Bye,

Morgan

> -----Original Message-----
> From: pythonfordelphi@yahoogroups.com
> [mailto:pythonfordelphi@yahoogroups.com] On Behalf Of tocer
> Sent: Wednesday, May 17, 2006 11:41 AM
> To: pythonfordelphi@yahoogroups.com
> Subject: Re: [pythonfordelphi] free object in demo31
>
> Thanks Morgan, I understand more and more.
>
> now I also another simple question. what is "__bound__" in demo31?
>
> I wish I don`t bother you.
>
> --tocer
>
> Morgan Martinet wrote::
> > CreateComponent is a helper function that creates a Delphi object if it
> was
> > properly registered with the VCL API RegisterClass.
> > f = TTestForm(Application) is a special notation that will instanciate
> an
> > existing form which class is TTestForm. This is a way to extend a form
> you
> > already designed for your application.
> > You mus subclass the Form type and name your class with the exact same
> name
> > as the Delphi type:
> >
> > class TTestForm(Form):
> > def __init__(self, Owner):
> > self.Caption = self.Caption + ` - changed by Python subclass`
> > self.BindMethodsToEvents()
> >
> > f.Free() will simply make sure that your form is destroyed immediately,
> > without relying on Python garbage collector. Note that this can be used
> only
> > if the wrapper owns the object.
>
>
>
>
>
> To Post a message, send it to: pythonfordelphi@eGroups.com
>
> To Unsubscribe, send a blank message to: pythonfordelphi-
> unsubscribe@eGroups.com
> Yahoo! Groups Links
>
>
>
>
Reply with quote
Send private message
View user's profile Post To page top
tocer_deng Posted: Thu May 18, 2006 6:57 pm


Joined: 17 May 2006

Posts: 32
free object in demo31
Thank you very much. I have to read source code more.

But be honest, office document an manual of P4D is too leak. I think P4D
is a excellent software. But it seems not enough folk know it. I think
that leak of document is main reason. I wish there is more and more
document by and by :)

thank your good job.

--tocer

Morgan Martinet wrote::
> Hi,
>
> If you look at the version history in WrapDelphi.pas, you`ll find:
> - added property __bound__ to TPyDelphiObject, to know if the wrapper is
> still bound to the instance.
> - added property __owned__ to the base Delphi wrapper, to know if the
> wrapper owns the underlying
> object or not.
>
> Bye,
>
> Morgan
Reply with quote
Send private message
View user's profile Post To page top
morgan_martinet Posted: Sat May 20, 2006 7:50 am


Joined: 29 Apr 2005

Posts: 103
free object in demo31
>Thank you very much. I have to read source code more.
You`re welcome.

>But be honest, office document an manual of P4D is too leak.
I know.

>I think P4D is a excellent software. But it seems not enough folk know it.
>I think that leak of document is main reason. I wish there is more and more
>document by and by :)
This was already discussed. This is open source and I have really no time
nor interest for writing/maintaining good and accurate documentation. Andy`s
tutorials are a good start and he did an excellent job. I`m just waiting
that someone interested contributes...
You can`t always take ;-)
In fact, I received many excellent contributions but only at the source code
level ;-) It`s obvious that nobody`s interested in this kind of work.
I just hope that the 32 demos are a good start, even if it`s a little
complex sometimes. And there is the forum...

>thank your good job.
Thanks!

Morgan
Reply with quote
Send private message
View user's profile Post To page top
oliverbock Posted: Sat May 20, 2006 8:21 am


Joined: 15 Sep 2005

Posts: 12
free object in demo31
>> I think P4D is a excellent software. But it seems not enough folk
>> know it.
>> I think that leak of document is main reason. I wish there is more
>> and more
>> document by and by :)
> This was already discussed. This is open source and I have really
> no time
> nor interest for writing/maintaining good and accurate
> documentation. Andy`s
> tutorials are a good start and he did an excellent job. I`m just
> waiting
> that someone interested contributes...

When a person finds a bug then it`s in his interest to have it fixed
for future versions. When the documentation is inadequate (leak?)
there is less motivation to help. So documentation will always get
less attention than code. However if we can make it easier for
people to contribute to documentation then perhaps we can get somewhere.

I suggest that we need a Wiki. I noticed that http://pbwiki.com/
yahoo/ will provide a Wiki for a Yahoo group. I don`t know how this
is different to their other free wikis, nor do I know if their spam
control is good. But perhaps it`s worth a try?


Regards,

Oliver
Reply with quote
Send private message
View user's profile Post To page top
tocer_deng Posted: Sat May 20, 2006 1:16 pm


Joined: 17 May 2006

Posts: 32
free object in demo31
Hi Morgan:

I wish I could do some job for p4d. But be honest, I`m newbie in python
and Delphi. I couldn`t understand completely p4d code and English is not
my Native language. But I`ll try it. If my job isn`t
good enough, don`t laugh me :)

--tocer




Morgan Martinet wrote::
>> Thank you very much. I have to read source code more.
> You`re welcome.
>
>> But be honest, office document an manual of P4D is too leak.
> I know.
>
>> I think P4D is a excellent software. But it seems not enough folk know it.
>> I think that leak of document is main reason. I wish there is more and more
>> document by and by :)
> This was already discussed. This is open source and I have really no time
> nor interest for writing/maintaining good and accurate documentation. Andy`s
> tutorials are a good start and he did an excellent job. I`m just waiting
> that someone interested contributes...
> You can`t always take ;-)
> In fact, I received many excellent contributions but only at the source code
> level ;-) It`s obvious that nobody`s interested in this kind of work.
> I just hope that the 32 demos are a good start, even if it`s a little
> complex sometimes. And there is the forum...
>
>> thank your good job.
> Thanks!
>
> Morgan
Reply with quote
Send private message
View user's profile Post To page top
morgan_martinet Posted: Sat May 20, 2006 8:22 pm


Joined: 29 Apr 2005

Posts: 103
free object in demo31
--- In pythonfordelphi@yahoogroups.com, Oliver Bock <oliver@...>
wrote:
>
> >> I think P4D is a excellent software. But it seems not enough
folk
> >> know it.
> >> I think that leak of document is main reason. I wish there is
more
> >> and more
> >> document by and by :)
> > This was already discussed. This is open source and I have
really
> > no time
> > nor interest for writing/maintaining good and accurate
> > documentation. Andy`s
> > tutorials are a good start and he did an excellent job. I`m
just
> > waiting
> > that someone interested contributes...
>
> When a person finds a bug then it`s in his interest to have it
fixed
> for future versions. When the documentation is inadequate
(leak?)
> there is less motivation to help. So documentation will always
get
> less attention than code. However if we can make it easier for
> people to contribute to documentation then perhaps we can get
somewhere.
>
> I suggest that we need a Wiki. I noticed that http://pbwiki.com/
> yahoo/ will provide a Wiki for a Yahoo group. I don`t know how
this
> is different to their other free wikis, nor do I know if their
spam
> control is good. But perhaps it`s worth a try?

That`s an excellent suggestion! I`ve just created it but we`ll have
to organize the content...
Reply with quote
Send private message
View user's profile Post To page top
oliverbock Posted: Sun May 21, 2006 12:44 pm


Joined: 15 Sep 2005

Posts: 12
free object in demo31
>> I suggest that we need a Wiki. I noticed that http://pbwiki.com/
>> yahoo/ will provide a Wiki for a Yahoo group. I don`t know how this
>> is different to their other free wikis, nor do I know if their spam
>> control is good. But perhaps it`s worth a try?
>
> That`s an excellent suggestion! I`ve just created it but we`ll have
> to organize the content...

Great! What is it called? How do we connect to it?


Oliver


P.S. Strangely, the biggest problem I had when I started using Python
for Delphi was finding the real home page. I kept running into
membres.lycos.fr and Andy`s tutorial page. I suggest that the Python
for Delphi page at mmm-experts.com should have "Python for Delphi" as
its title. This would make it more obvious in Google results and
might help it take the top spot. (As might a link from the Yahoo
Groups page, if this is possible.)
Reply with quote
Send private message
View user's profile Post To page top
morgan_martinet Posted: Sun May 21, 2006 9:04 pm


Joined: 29 Apr 2005

Posts: 103
free object in demo31
> > That`s an excellent suggestion! I`ve just created it but we`ll have
> > to organize the content...
>
> Great! What is it called? How do we connect to it?
It`s available at http://py4d.pbwiki.com/
I thought it was automatically advertised when I created it!

It`s public for viewing it but you need a password for editing the
pages. Anybody interested in doing it can simply send me a mail at
morgan (at) mmm-experts.com and i will send him the password.

> P.S. Strangely, the biggest problem I had when I started using
Python
> for Delphi was finding the real home page. I kept running into
> membres.lycos.fr and Andy`s tutorial page. I suggest that the
Python
> for Delphi page at mmm-experts.com should have "Python for Delphi"
as
> its title. This would make it more obvious in Google results and
> might help it take the top spot. (As might a link from the Yahoo
> Groups page, if this is possible.)
Ok. Will try it... The problem is that I don`t have access to the old
page anymore to link it to the new page!

Morgan
Reply with quote
Send private message
View user's profile Post To page top
oliverbock Posted: Mon May 22, 2006 3:51 am


Joined: 15 Sep 2005

Posts: 12
free object in demo31
Morgan Martinet wrote:
> It`s public for viewing it but you need a password for editing the
> pages. Anybody interested in doing it can simply send me a mail at
> morgan (at) mmm-experts.com and i will send him the password.
>
Password please!

Do you mind if I give the password to somebody who works with me? I`ll
instruct him to post some material since he`s recently had to learn to
use Python for Delphi.


Regards,

Oliver
Reply with quote
Send private message
View user's profile Post To page top
tocer_deng Posted: Mon May 22, 2006 6:13 am


Joined: 17 May 2006

Posts: 32
free object in demo31
password too

I`ll try it.

Morgan Martinet wrote::
>>> That`s an excellent suggestion! I`ve just created it but we`ll have
>>> to organize the content...
>> Great! What is it called? How do we connect to it?
> It`s available at http://py4d.pbwiki.com/
> I thought it was automatically advertised when I created it!
>
> It`s public for viewing it but you need a password for editing the
> pages. Anybody interested in doing it can simply send me a mail at
> morgan (at) mmm-experts.com and i will send him the password.
>
>> P.S. Strangely, the biggest problem I had when I started using
> Python
>> for Delphi was finding the real home page. I kept running into
>> membres.lycos.fr and Andy`s tutorial page. I suggest that the
> Python
>> for Delphi page at mmm-experts.com should have "Python for Delphi"
> as
>> its title. This would make it more obvious in Google results and
>> might help it take the top spot. (As might a link from the Yahoo
>> Groups page, if this is possible.)
> Ok. Will try it... The problem is that I don`t have access to the old
> page anymore to link it to the new page!
>
> Morgan
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help