Accessing Python stuff thru OLE...

jurberg Last Name jurberg at my-deja.com
Thu Mar 22 17:12:26 EST 2001


Hi all,

We are looking for ways to move away from PowerBuilder.  I have identified ways to use Java thru OLE but I would also like to try using Python (cause it's much better than Java IMHO).  Here is what I am trying to do (and have already done with a Java example):

1) Call functions on a Python object 
-- works great

2) Get events back to PowerBuilder from Python 
-- Can sort of do on Java by using ActiveX bridge.  Don't know how in Python.

3) Open a window from a Python object thru OLE.
-- Can sort of do with wxPython.  How to do with Tkinter?

I used the example code at the end of this post.  I took the MyAboutBox from the wxPython demo and tried opening it thru my OLE object.  Works great the first time, but I get the only 1 instance of wxApp allowed per thread exception afterwords.  Anyway to fix this?  

I also tried using tk.  It worked when the OLE object was created from PythonWin but not from PowerBuilder.  Is there a python path thing I am missing?

Thanks,
John Urberg

# PowerBuilderGuiTest.py
from   wxPython.wx       import *
from   wxPython.html     import *
import wxPython.lib.wxpTag

class MyAboutBox(wxDialog):
    <... wxPython Demo About Box code ...>

class MyApp(wxApp):
    def OnInit(self):
        frame = MyAboutBox(None)
        frame.Show(true)
        self.SetTopWindow(frame)
        self.ShowTip(frame)
        return true

class PowerBuilderGuiTest:
   _public_methods_ = ['openFrame', 'openTkFrame', 'throwException']
   _reg_progid_ = "Python.PowerBuilder.Gui.Test"
   _reg_clsid_ = "{7934BD91-1E00-11D5-848F-0050DAC2AA7E}"

   def openFrame(self):
        app = MyApp(0)
        app.MainLoop()

   def openTkFrame(self):
        from Tkinter import *
        root = Tk()
        w = Label(root, text="Hello, world!")
        w.pack()
        root.mainloop()
        
   def throwException(self):
        raise Exception, 'Hello from Python'
       
if __name__ == '__main__':
   import win32com.server.register
   win32com.server.register.UseCommandLine(PowerBuilderGuiTest)


------------------------------------------------------------
--== Sent via Deja.com ==--
http://www.deja.com/



-- 
Posted from [12.24.248.70] by way of mail20.bigmailbox.com [209.132.220.51] 
via Mailgate.ORG Server - http://www.Mailgate.ORG



More information about the Python-list mailing list