Fix PrintPreview behavior
authorlaurent
Thu, 15 Sep 2011 22:29:32 +0200
changeset 559 984c51d1bf6b
parent 558 01e2c3d58a27
child 560 3757f0de0d07
Fix PrintPreview behavior
PLCOpenEditor.py
--- a/PLCOpenEditor.py	Wed Sep 14 23:06:47 2011 +0200
+++ b/PLCOpenEditor.py	Thu Sep 15 22:29:32 2011 +0200
@@ -319,8 +319,8 @@
               kind=wx.ITEM_NORMAL, text=_(u'Undo\tCTRL+Z'))
         AppendMenu(parent, help='', id=wx.ID_REDO,
               kind=wx.ITEM_NORMAL, text=_(u'Redo\tCTRL+Y'))
-        AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO,
-              kind=wx.ITEM_CHECK, text=_(u'Enable Undo/Redo'))
+        #AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO,
+        #      kind=wx.ITEM_CHECK, text=_(u'Enable Undo/Redo'))
         parent.AppendSeparator()
         AppendMenu(parent, help='', id=wx.ID_CUT,
               kind=wx.ITEM_NORMAL, text=_(u'Cut\tCTRL+X'))
@@ -947,10 +947,14 @@
             preview = wx.PrintPreview(printout, printout2, data)
 
             if preview.Ok():
-                preview_frame = wx.PreviewFrame(preview, self, _("Print preview"))
+                preview_frame = wx.PreviewFrame(preview, self, _("Print preview"), style=wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT)
 
                 preview_frame.Initialize()
                 
+                preview_canvas = preview.GetCanvas()
+                preview_canvas.SetMinSize(preview_canvas.GetVirtualSize())
+                preview_frame.Fit()
+                
                 preview_frame.Show(True)
 
     def OnPrintMenu(self, event):
@@ -965,7 +969,7 @@
             printer = wx.Printer(dialog_data)
             printout = GraphicPrintout(window, page_size, margins)
             
-            if not printer.Print(self, printout, True):
+            if not printer.Print(self, printout, True) and printer.GetLastError() != wx.PRINTER_CANCELLED:
                 self.ShowErrorMessage(_("There was a problem printing.\nPerhaps your current printer is not set correctly?"))
             printout.Destroy()