falconindy
October 12th, 2009, 11:52 PM
Scenario: I've written a bash script that logs into the NY times website and pulls down the daily puzzle. Once I've got the puzzle, I'd like to be able to print it without any user input. I've looked at the code from XWord, and I'm able to essentially borrow that code to print it, but I'm unable to skip the print dialog box.
Below is the relevant code from xword.
def do_print(self, dialog, res, job):
config = job.get_config()
if res == gnomeprint.ui.DIALOG_RESPONSE_CANCEL:
dialog.destroy()
elif res == gnomeprint.ui.DIALOG_RESPONSE_PREVIEW:
self.do_preview(config, dialog)
elif res == gnomeprint.ui.DIALOG_RESPONSE_PRINT:
dialog.destroy()
self.gpc = job.get_context()
self.draw(config)
job.close()
job.print_()
def print_puzzle(self, win):
job = gnomeprint.Job(gnomeprint.config_default())
dialog = gnomeprint.ui.Dialog(job, "Print...", 0)
dialog.connect('response', self.do_print, job)
dialog.set_transient_for(win)
dialog.show()
def print_puzzle_now(self, win):
job = gnomeprint.Job(gnomeprint.config_default())
job.print_()
I added in print_puzzle_now() so as not to disturb the other functionality.
Calling print_() brings up the print dialog box, and based on the pyGTK reference for gnomeprint (http://www.pygtk.org/pygnomeprint/class-gnomeprintjob.html), it's not clear to me how to avoid the dialog box.
Anyone know how to accomplish this?
Below is the relevant code from xword.
def do_print(self, dialog, res, job):
config = job.get_config()
if res == gnomeprint.ui.DIALOG_RESPONSE_CANCEL:
dialog.destroy()
elif res == gnomeprint.ui.DIALOG_RESPONSE_PREVIEW:
self.do_preview(config, dialog)
elif res == gnomeprint.ui.DIALOG_RESPONSE_PRINT:
dialog.destroy()
self.gpc = job.get_context()
self.draw(config)
job.close()
job.print_()
def print_puzzle(self, win):
job = gnomeprint.Job(gnomeprint.config_default())
dialog = gnomeprint.ui.Dialog(job, "Print...", 0)
dialog.connect('response', self.do_print, job)
dialog.set_transient_for(win)
dialog.show()
def print_puzzle_now(self, win):
job = gnomeprint.Job(gnomeprint.config_default())
job.print_()
I added in print_puzzle_now() so as not to disturb the other functionality.
Calling print_() brings up the print dialog box, and based on the pyGTK reference for gnomeprint (http://www.pygtk.org/pygnomeprint/class-gnomeprintjob.html), it's not clear to me how to avoid the dialog box.
Anyone know how to accomplish this?