[python-win32] Multiple Instances of wxPython com object hangs VB

Dhruv Dhody dhruv_dhody@hotmail.com
Sat, 8 Mar 2003 12:05:08 +0530


This is a multi-part message in MIME format.

------=_NextPart_000_0018_01C2E56A.F6C847D0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

=20

I am working on python and VB. I have a com server on python which is a =
drawing application. I create an object in VB to start the application =
when I click on the menu in the form. If at a time only one instance of =
the application is crated then it works properly.   If I open multiple =
instances of the application without closing the previous windows then =
also everything works fine until I close the MDI Form. When i close the =
MDI Form, the MDI Form closes but VB hangs.

=20

VB Code :



Private Sub mnuHi_Click()

    Dim a As Object

    Set a =3D CreateObject("Python.Dhruv")

    a.make

    Set a =3D Nothing

End Sub



Python Code :



class Dhruv:
    _reg_clsid_ =3D "{37F1DE73-2DE8-49A9-B5FB-794439E2C618}"
    _reg_desc_  =3D "Dhruv"
    _reg_progid_ =3D "Python.Dhruv"
    _reg_clsctx_ =3D CLSCTX_INPROC
    _public_methods_ =3D ['make']
    _public_attrs_ =3D []
    _readonly_attrs_ =3D []
    _reg_class_spec_ =3D "d.Dhruv"
    def make(self):
        self.app =3D wxPySimpleApp()
        self.frame1 =3D DoodleFrame1(None)
        self.frame1.Show(true)
        self.app.MainLoop()

def RegisterMe():
    import win32com.server.register
    win32com.server.register.UseCommandLine(Dhruv)



RegisterMe()   =20



How can I prevent this??

=20

Dhruv

=20


------=_NextPart_000_0018_01C2E56A.F6C847D0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"><FONT=20
face=3DVerdana>Hi,</FONT></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><?xml:namespace =
prefix =3D o ns =3D=20
"urn:schemas-microsoft-com:office:office" /><o:p><FONT face=3DVerdana=20
size=3D3>&nbsp;</FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"><FONT face=3DVerdana>I am =
working on=20
python and VB. I have a com server on python which is a drawing =
application. I=20
create an object in VB to start the application when I click on the menu =
in the=20
form. If at a time only one instance of the application is crated then =
it works=20
properly.<SPAN style=3D"mso-spacerun: yes">&nbsp;&nbsp; </SPAN>If I open =
multiple=20
instances of the application without closing the previous windows then =
also=20
everything works fine until I close the MDI Form. When i close the MDI =
Form, the=20
MDI Form closes but VB hangs.</FONT></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3D"Times New Roman"=20
size=3D3>&nbsp;</FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Courier"><FONT color=3D#808080>VB =
Code=20
:</FONT></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT=20
color=3D#808080></FONT>&nbsp;</P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Courier"><FONT =
color=3D#808080>Private Sub=20
mnuHi_Click()</FONT></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Courier"><FONT =
color=3D#808080><SPAN=20
style=3D"mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>Dim a As=20
Object</FONT></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Courier"><FONT =
color=3D#808080><SPAN=20
style=3D"mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>Set a =3D=20
CreateObject("Python.Dhruv")</FONT></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Courier"><FONT =
color=3D#808080><SPAN=20
style=3D"mso-spacerun: yes">&nbsp;&nbsp;&nbsp; =
</SPAN>a.make</FONT></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Courier"><FONT =
color=3D#808080><SPAN=20
style=3D"mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>Set a =3D=20
Nothing</FONT></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Courier"><FONT =
color=3D#808080>End=20
Sub</FONT></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT=20
color=3D#808080></FONT>&nbsp;</P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Courier"><FONT =
color=3D#808080>Python Code=20
:</FONT></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT=20
color=3D#808080></FONT>&nbsp;</P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Courier"><FONT =
color=3D#808080>class=20
Dhruv:<BR>&nbsp;&nbsp;&nbsp; _reg_clsid_ =3D=20
"{37F1DE73-2DE8-49A9-B5FB-794439E2C618}"<BR>&nbsp;&nbsp;&nbsp; =
_reg_desc_&nbsp;=20
=3D "Dhruv"<BR>&nbsp;&nbsp;&nbsp; _reg_progid_ =3D=20
"Python.Dhruv"<BR>&nbsp;&nbsp;&nbsp; _reg_clsctx_ =3D=20
CLSCTX_INPROC<BR>&nbsp;&nbsp;&nbsp; _public_methods_ =3D=20
['make']<BR>&nbsp;&nbsp;&nbsp; _public_attrs_ =3D =
[]<BR>&nbsp;&nbsp;&nbsp;=20
_readonly_attrs_ =3D []<BR>&nbsp;&nbsp;&nbsp; _reg_class_spec_ =3D=20
"d.Dhruv"<BR>&nbsp;&nbsp;&nbsp; def=20
make(self):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.app =3D=20
wxPySimpleApp()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
self.frame1 =3D=20
DoodleFrame1(None)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
self.frame1.Show(true)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
self.app.MainLoop()</FONT></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-bidi-font-family: =
Arial"><FONT=20
color=3D#808080>def RegisterMe():<BR>&nbsp;&nbsp;&nbsp; import=20
win32com.server.register<BR>&nbsp;&nbsp;&nbsp;=20
win32com.server.register.UseCommandLine(Dhruv)</FONT></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"><FONT=20
color=3D#808080></FONT></SPAN>&nbsp;</P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"><FONT face=3DVerdana=20
color=3D#808080>RegisterMe()&nbsp;&nbsp;&nbsp;&nbsp;</FONT></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"><FONT face=3DVerdana=20
color=3D#808080></FONT></SPAN>&nbsp;</P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"><FONT face=3DVerdana>How =
can I prevent=20
this??</FONT></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DVerdana=20
size=3D3>&nbsp;</FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"><FONT=20
face=3DVerdana>Dhruv</FONT></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3D"Times New Roman"=20
size=3D3>&nbsp;</FONT></o:p></P></FONT></DIV></BODY></HTML>

------=_NextPart_000_0018_01C2E56A.F6C847D0--