Trouble with PageSetupDialog

Hello.

I'm having problems in my application to serialize the preferences of the printer dialog, margins, etc. Before going on a killing spree I decided to modify the wxPython print framework demo. Basically, in the TestPrintPanel.OnPageSetup() method, about line 135 once the copy of wx.PrintData is done, I add a logging of the paper id like this:

        self.printData = wx.PrintData(
            dlg.GetPageSetupData().GetPrintData())
        self.log.WriteText("paper id %r paper size %r\n" \
            % (self.printData.PaperId, self.printData.PaperSize))

I simply want to know what the paper id is after I accept the dialog, since on my tests I've been unable to select a paper size and get it back correctly. With this modification, going through the list of paper sizes and clicking on accept I get the following, where the element on the left is the list entry I selected, the second is the paper id and paper size as returned by wxPython, and the third entry is the selected item when I enter again the dialog without doing anything special.

You would guess that at least the dialog keeps the same selection...

92x92, id 0 wx.Size(0, 0), 92x92
A0, id 0 wx.Size(0, 0), A0
A1, id 0 wx.Size(0, 0), A1
A10, id 0 wx.Size(0, 0), A10
A2, id 64 wx.Size(420, 594), A2
A3, id 65 wx.Size(297, 420), A3
A4, id 13, wx.Size(210, 297), A3 <----
A4 small, id 0 wx.Size(0, 0), A4 Small
A5, id 59 wx.Size(148, 210), A3 <----
A6, id 68 wx.Size(105, 148), A6
A7, id 0 wx.Size(0, 0), A7
A8, id 0 wx.Size(0, 0), A8
A9, id 0 wx.Size(0, 0), A9
ANSI C, id 4 wx.Size(0, 0) A3 <----
ANSI D, id 5 wx.Size(0, 0) A3 <----
ANSI E, id 6 wx.Size(0, 0) A3 <----
ANSI F, id 0 wx.Size(0, 0) ANSI F
ARCH A, id 0 wx.Size(0, 0) ARCH A
ARCH B, id 0 wx.Size(0, 0) ARCH B
ARCH C, id 0 wx.Size(0, 0) ARCH C
ARCH D, id 0 wx.Size(0, 0) ARCH D
ARCH E, id 0 wx.Size(0, 0) ARCH E
ARCH E1, id 0 wx.Size(0, 0) ARCH E1
ARCH E2, id 0 wx.Size(0, 0) ARCH E2
ARCH E3, id 0 wx.Size(0, 0) ARCH E3
C0, id 0 wx.Size(0, 0) C0
C1, id 0 wx.Size(0, 0) C1
C2, id 0 wx.Size(0, 0) C2
C3, id 0 wx.Size(0, 0) C3
C4, id 0 wx.Size(0, 0) C4
C5, id 0 wx.Size(0, 0) C5
C6, id 0 wx.Size(0, 0) C6
...
HalfLetter, id 10 wx.Size(0, 0) A3 <---
...

Sorry, I got bored of typing. Note how wxPython returns an id of 13 for A3 when wx.PAPER_A4 is 3. Surprisingly, regardless of the attribuets of the PrintData object, the printing framework later prints using the selected paper size! So, if I pick A4 and then press the print button, the paper size is A4, even though going back to the page dialog it shows A3.

I have noticed this problem because instead of keeping the wx.PrintData alive as an attribute of the application I wanted to save/restore the attributes each time to a configuration file, ensuring that what the user selected would always be preserved. But I'm unable to do so, since the attributes are bogus.

Also, when a paper id other than 0 is passed to the page setup dialog and it doesn't recognise the paper id, it seems to pick A3 as default (which I've marked with a text arrow in the listing).

Is there any solution for this? AFAICS I have to ignore saving/restoring print preferences and make wx.PrintData an attribute of the application instance. Even if the latter means confusing users to death when they go back to the preferences and see another page size.

Running 2.8.7.1 msw-unicode, but 2.8.0.1 msw-unicode shows the same behaviour, so this behaviour might be even older than that.

···

--
Rastertech España S.A.
  Grzegorz Adam Hankiewicz
/Jefe de Producto TeraVial/

C/ Perfumería 21. Nave I. Polígono industrial La Mina
28770 Colmenar Viejo. Madrid (España)
Tel. +34 918 467 390 (Ext.17) *·* Fax +34 918 457 889
ghankiewicz@rastertech.es *·* www.rastertech.es <http://www.rastertech.es/>