DC band-aid (please test)

Hi all,

Attached is a module that will fiddle with the attributes of the wx.DC class to make the methods be like they will be in the next release. All you need to do is import it in your app and then the DC draw methods with the "normal" names will have the 2.4 semantics, he new methods taking point and/or size will have a new set of names, and the XY names will be removed. See the module docstring for more info and a warning. I would appreciate it if some of you can please test it.

fixdc.py (3.01 KB)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

It seems a bit silly to use abbreviations like PtSz when some of the methods spell out Point and Rect. Yes it is more typing, but why not just use PointSize?

Unless you're in a hurry I'll test the code out tomorrow with changes to my own code.

ka

···

On Apr 29, 2004, at 2:42 PM, Robin Dunn wrote:

Hi all,

Attached is a module that will fiddle with the attributes of the wx.DC class to make the methods be like they will be in the next release. All you need to do is import it in your app and then the DC draw methods with the "normal" names will have the 2.4 semantics, he new methods taking point and/or size will have a new set of names, and the XY names will be removed. See the module docstring for more info and a warning. I would appreciate it if some of you can please test it.

Kevin Altis wrote:

Hi all,

Attached is a module that will fiddle with the attributes of the wx.DC class to make the methods be like they will be in the next release. All you need to do is import it in your app and then the DC draw methods with the "normal" names will have the 2.4 semantics, he new methods taking point and/or size will have a new set of names, and the XY names will be removed. See the module docstring for more info and a warning. I would appreciate it if some of you can please test it.

It seems a bit silly to use abbreviations like PtSz when some of the methods spell out Point and Rect. Yes it is more typing, but why not just use PointSize?

No real reason, it just looked too long. I'll change it.

Unless you're in a hurry I'll test the code out tomorrow with changes to my own code.

Thanks.

fixdc.py (3.06 KB)

···

On Apr 29, 2004, at 2:42 PM, Robin Dunn wrote:

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

It seems to work fine. Please reorder the names list so it is in alphabetical order to simplify scanning the list when fixing code.

It is a bit odd to see the TypeError message when you are using the 2.5.1.5 forms since of course it still says _gdi.DC_DrawLineXY ... so you should probably give a specific example of that in the comments so people know what to expect.

ka

···

On Apr 30, 2004, at 6:18 PM, Robin Dunn wrote:

Kevin Altis wrote:

On Apr 29, 2004, at 2:42 PM, Robin Dunn wrote:

Hi all,

Attached is a module that will fiddle with the attributes of the wx.DC class to make the methods be like they will be in the next release. All you need to do is import it in your app and then the DC draw methods with the "normal" names will have the 2.4 semantics, he new methods taking point and/or size will have a new set of names, and the XY names will be removed. See the module docstring for more info and a warning. I would appreciate it if some of you can please test it.

It seems a bit silly to use abbreviations like PtSz when some of the methods spell out Point and Rect. Yes it is more typing, but why not just use PointSize?

No real reason, it just looked too long. I'll change it.

_names = [
    ("FloodFillXY", "FloodFill", "FloodFillPoint"),
    ("GetPixelXY", "GetPixel", "GetPixelPoint"),
    ("DrawLineXY", "DrawLine", "DrawLinePoint"),
    ("CrossHairXY", "CrossHair", "CrossHairPoint"),
    ("DrawArcXY", "DrawArc", "DrawArcPoint"),
    ("DrawCheckMarkXY", "DrawCheckMark", "DrawCheckMarkRect"),
    ("DrawEllipticArcXY", "DrawEllipticArc", "DrawEllipticArcPointSize"),
    ("DrawPointXY", "DrawPoint", "DrawPointPoint"),
    ("DrawRectangleXY", "DrawRectangle", "DrawRectanglePointSize"),
    ("DrawRoundedRectangleXY", "DrawRoundedRectangle", "DrawRoundedRectanglePointSize"),
    ("DrawCircleXY", "DrawCircle", "DrawCirclePoint"),
    ("DrawEllipseXY", "DrawEllipse", "DrawEllipsePointSize"),
    ("DrawIconXY", "DrawIcon", "DrawIconPoint"),
    ("DrawBitmapXY", "DrawBitmap", "DrawBitmapPoint"),
    ("DrawTextXY", "DrawText", "DrawTextPoint"),
    ("DrawRotatedTextXY", "DrawRotatedText", "DrawRotatedTextPoint"),
    ("BlitXY", "Blit", "BlitPointSize"),

Kevin Altis wrote:

It seems to work fine. Please reorder the names list so it is in alphabetical order to simplify scanning the list when fixing code.

Done.

It is a bit odd to see the TypeError message when you are using the 2.5.1.5 forms since of course it still says _gdi.DC_DrawLineXY ... so you should probably give a specific example of that in the comments so people know what to expect.

How's the attached?

I found some cookbook code to allow changing the name of the function in the code object so I've grafted that in. It will make the next to last level in the traceback have the right name. I've also added a note about the internal names.

fixdc.py (5.26 KB)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Kevin Altis wrote:

It seems to work fine. Please reorder the names list so it is in alphabetical order to simplify scanning the list when fixing code.

Done.

It is a bit odd to see the TypeError message when you are using the 2.5.1.5 forms since of course it still says _gdi.DC_DrawLineXY ... so you should probably give a specific example of that in the comments so people know what to expect.

How's the attached?

Seems fine.

<snip>

"""
This module will do surgery on the wx.DC class in wxPython 2.5.1.5 to
make it act like the wx.DC class in later versions will. To use this
module simply import it in one of your program's modules before you
use any DC's. It does its work upon import and then is done.

I would add one more line that emphasizes that importing fixdc.py will only impact wxPython 2.5.1.5 regardless of which version of wxPython you're running. That makes it safe to include as an intermediate fix in other packages, though they may not want to in order to force users to upgrade from wxPython 2.5.1.5.

For example, I've already checked it into PythonCard cvs and importing it in model.py. Depending on when the next version of wxPython is available I may end up putting it out with release 0.8.

<snip>

ka

···

On May 1, 2004, at 11:35 AM, Robin Dunn wrote:

Kevin Altis wrote:

I would add one more line that emphasizes that importing fixdc.py will only impact wxPython 2.5.1.5 regardless of which version of wxPython you're running. That makes it safe to include as an intermediate fix in other packages, though they may not want to in order to force users to upgrade from wxPython 2.5.1.5.

For example, I've already checked it into PythonCard cvs and importing it in model.py. Depending on when the next version of wxPython is available I may end up putting it out with release 0.8.

Good point. That was definitly my intention in making this module, so I'll make that explicit in the docstring.

Thanks!

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!