When I'm printing there's a annoying Printing dialog with a Cancel button on top of my application. I don't want it but I haven't found how disable it in the docs.
Here the code which explain the issue:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import wx
class DemoPrintout( wx.Printout ):
def HasPage(self, page):
return page == 1
def GetPageInfo(self):
return (1, 2, 1, 2)
def OnPrintPage(self, page):
dc = self.GetDC()
size = dc.GetSize()
dc.SetPen( wx.RED_PEN )
dc.SetBrush( wx.GREEN_BRUSH )
dc.DrawCircle(
size.width / 2, size.height / 2,
min( [ size.width, size.height ] ) / 4
)
time.sleep( 2 )
return True
class DemoFrame( wx.Frame ):
def __init__(self, *args, **kwds):
wx.Frame.__init__( self, *args, **kwds )
self.Center( wx.BOTH )
# Add button
self.btnPrint = wx.Button( self, -1, label="Print", size=wx.Size( 72, 32 ) )
# Events
self.btnPrint.Bind( wx.EVT_BUTTON, self.OnPrintButton )
def OnPrintButton(self, event):
printData = wx.PrintData()
printData.SetPaperId( wx.PAPER_A4 )
printData.SetPrintMode( wx.PRINT_MODE_PRINTER )
pdd = wx.PrintDialogData( printData )
pdd.SetToPage( pdd.GetMaxPage() )
printer = wx.Printer( pdd )
printout = DemoPrintout()
printer.Print( None, printout, prompt=False )
printout.Destroy()
class DemoApp(wx.App):
def OnInit(self):
frame = DemoFrame( None, -1, "Test" )
frame.Show( True )
self.SetTopWindow( frame )
return True
if __name__ == '__main__':
app = DemoApp( 0 )
app.MainLoop()