activex Crystal Report problem

I'm pulling my hair out on this one...

I want to embed the Crystal Report viewer in my wxPython app. I have it
close to working, but the problem is that one of the properties of the
Report Viewer object is another object:

import wx
from wxPython.lib.activexwrapper import MakeActiveXClass
import win32com.client.gencache
import win32com.client

import crviewer

class CrystalPanel(wx.Panel):
  def __init__(self, parent):
     wx.Panel.__init__(self, parent, -1)

     sizer = wx.BoxSizer(wx.VERTICAL)
     crViewClass = MakeActiveXClass(crviewer.CRViewer9, eventObj = self)
     self.crView = crViewClass(self, -1)
     print str(self.crView)

     sizer.Add(self.crView, 1, wx.EXPAND)
     cr = win32com.client.Dispatch("CrystalRuntime.Application")
     report = cr.OpenReport("AllergyList.rpt",1)

     print repr(report)
     print repr(cr)

     self.crView.__setattr__( "ReportSource", report )
     self.crView.EnableToolbar = 1
     self.crView.ViewReport()
     self.SetSizer(sizer)
     self.SetAutoLayout(1)

Now cr and report both seem to be OK -- in that if I screw something up -
for example putting in a bad file name for the OpenReport call, then I get
an exception at that point.

The problem I have when I call ViewReport is:
<wx.lib.activexwrapper.AXControl_CRViewer9; proxy of C++ wxWindow instance
at _784bdb01_p_wxWindow>
<COMObject OpenReport>
<COMObject CrystalRuntime.Application>
Traceback (most recent call last):
  File "C:\Projects\inman\MainWindow.py", line 155, in OnItemActivated
    titleString)
  File "C:\Projects\inman\PatientNotebookFrame.py", line 42, in __init__
    panel1 = PatientObservations(self.notebook, self.newBackColor)
  File "C:\Projects\inman\PatientObservations.py", line 243, in __init__
    self.cPanel = CrystalPanel(self)
  File "C:\Projects\inman\CrystalPanel.py", line 29, in __init__
    self.crView.ViewReport()
  File "C:\Projects\inman\crviewer.py", line 307, in ViewReport
    return self._oleobj_.InvokeTypes(265, LCID, 1, (24, 0), (),)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0,
'CRViewer9.CRViewer.9.2', 'No report to view.', None, 0, -2147467259),
None)

So it seems like the CRViewer object doesn't know that I just set its
ReportSource property.

I have attached the crviewer.py file generated from makepy.py....

How do set a property like this? (One would think that the Crystal Viewer
would have a method like SetReportFile: but it does not, sigh).

Thanks!
Hubert Hickman

crviewer.py (42.8 KB)

Hello !

I didn't find how to change the font or the style (bold, italic, etc.) of a StaticText. I suppose it is possible easily, but how ?

Thanks
Thomas Zuliani

Check out wxPython demo.

        str = "This is a different font."
        text = wx.StaticText(self, -1, str, (20, 120))
        font = wx.Font(18, wx.SWISS, wx.NORMAL, wx.NORMAL)
        text.SetFont(font)

Thursday, May 27, 2004, 3:31:27 PM, you wrote:

···

Hello !

I didn't find how to change the font or the style (bold, italic, etc.)
of a StaticText. I suppose it is possible easily, but how ?

Thanks
Thomas Zuliani