[Pythonmac-SIG] printing in a PyObjC Document-based app

Tom Elliott telliott99 at mac.com
Thu Nov 30 15:06:42 CET 2006


I have a PyObjC Document-based Application set up by Xcode (2.4).   
When I build the default project, but and then change the document  
window to contain an NSTableView, the app prints the data from the  
TableView.  I would like to take charge of the print operation to  
print a modified version of the view.

According to the docs, for a Cocoa app, my "NSDocument subclass must  
override printShowingPrintPanel: to create and run the print  
operation for the document."  A Cocoa Document-based Application will  
not print if you don't do this, whereas the PyObjC one doesn't need  
to do this (and in fact won't call the method if I do override it in  
my NSDocument subclass).

I thought of adding a modified Print item to the File menu, but I  
don't know how to connect the new menu item to my NSDocument  
subclass.  In MainMenu.nib, File's Owner's class is NSApplication.  I  
can set my NSDocument to be the App delegate, but there doesn't seem  
to be an appropriate delegate method for printing.

I thought of trying to put my document at the front of the responder  
chain, but I can't get to the window.  File's owner in the  
document.nib file has an outlet set to the window, but when I do  
"print self.window" from the document I get "None."

What's the right way to do this?

Thanks.

Tom Elliott


More information about the Pythonmac-SIG mailing list