Notes on upgrading a mid-size package to 2.5

I'm about 1/5th of the way through converting wxoo to use wxPython 2.5 (also doing some minimal cleanup along the way)

    * With 2.5.x there are apparently new dependencies on a running App
      object, for instance; you can't initialise the colour database
      until there's a running app (which means every module that relies
      on colour-database names has to do funky bookkeeping checks around
      each attempt to use the functionality to make sure that the init
      is called at least once).
    * You have to arrange to run all unit tests under a running wxApp
      (since any code which uses the newly App-dependent functionality
      is now going to fail). The following *doesn't* work (memory
      access violation), suggestions appreciated:
      if __name__ == "__main__":
          class TestApp( wxPySimpleApp ):
              def OnInit( self ):
                  frame = wxFrame( None, -1, "Some frame")
                  self.SetTopWindow( frame )
                  unittest.TextTestRunner().run( suite )
                  frame.Close()
          app = TestApp()
          app.MainLoop()
    * Watch out for any sub-packages/modules you've created that are
      named "wx", as they can shadow the wxPython module for other
      modules in those packages, so for instance, wxoo.wx and
      basictypes.wx both caused problems, all such packages/modules must
      be renamed (and then all uses of them changed, of course).
    * wxScrollEvent no longer takes a keyword "orientation" argument? Docs seem to suggest it still does.

Well, that's all for the first 17 modules. Only another 65 modules in wxoo and another 30 in conflict solver, given 6 hours for the first 17 it should only take about 30 hours for the whole conversion. Longer than I was hoping, but not killingly long.

BTW, I'd thought there was (somewhere) an upgrade script for those converting old modules to the new wx.* form, but I don't see it anywhere in the wx or wxPython directories on my 2.5.1 install.

Have fun all. Night,
Mike

···

_______________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://members.rogers.com/mcfletch/

Mike C. Fletcher wrote:

I'm about 1/5th of the way through converting wxoo to use wxPython 2.5 (also doing some minimal cleanup along the way)

   * With 2.5.x there are apparently new dependencies on a running App
     object,

Yes. See the MigrationGuide.

for instance; you can't initialise the colour database
     until there's a running app (which means every module that relies
     on colour-database names has to do funky bookkeeping checks around
     each attempt to use the functionality to make sure that the init
     is called at least once).

Or don't precreate the wx.Colour objects. Instead just use strings and let wxPython convert them to wx.Colours as you pass them to wx functions.

   * You have to arrange to run all unit tests under a running wxApp
     (since any code which uses the newly App-dependent functionality
     is now going to fail). The following *doesn't* work (memory
     access violation), suggestions appreciated:
     if __name__ == "__main__":
         class TestApp( wxPySimpleApp ):
             def OnInit( self ):
                 frame = wxFrame( None, -1, "Some frame")
                 self.SetTopWindow( frame )
                 unittest.TextTestRunner().run( suite )
                 frame.Close()
         app = TestApp()
         app.MainLoop()

What does your test suite do? This works here:

from wxPython.wx import *
print wxVERSION_STRING
if __name__ == "__main__":
     class TestApp( wxPySimpleApp ):
         def OnInit( self ):
             frame = wxFrame( None, -1, "Some frame")
             self.SetTopWindow( frame )
             print "running tests"
             #unittest.TextTestRunner().run( suite )
             frame.Close()
             return True
     app = TestApp()
     app.MainLoop()

   * Watch out for any sub-packages/modules you've created that are
     named "wx", as they can shadow the wxPython module for other
     modules in those packages, so for instance, wxoo.wx and
     basictypes.wx both caused problems, all such packages/modules must
     be renamed (and then all uses of them changed, of course).

Yep.

   * wxScrollEvent no longer takes a keyword "orientation" argument? Docs seem to suggest it still does.

I don't recall why it changed, but it is called "orient" now.

>>> import wx
>>> print wx.ScrollEvent.__init__.__doc__

         __init__(wxEventType commandType=wxEVT_NULL, int winid=0, int pos=0,
             int orient=0) -> ScrollEvent

···

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

Now that I'm in the middle of converting over all of the PythonCard code to 2.5.x I'm looking for more info on what did and didn't change in the namespace. It seems like the only thing that kept the wx prefix are the event constants which would otherwise conflict with the event function wrappers. For example wx.EVT_KEY_UP() and wx.wxEVT_KEY_UP.

I think this needs to be described in more detail in the migration guide.

ka

···

On Apr 4, 2004, at 5:08 AM, Joe Brown wrote:

I wrote this script a while back in effort to help Robin convert the Demo to the import wx format.

Dunno if he used it or not. It's not a very elegant solution, but can shorten the work from wxPython.wx import *

If'n I was a more experienced Pythong programmer, it might be more complete. This was/is capable of converting over 90% of the demo. To my supprise many of the modules actually ran after being forcibly rewritten.

This script doesn't backup old work, so it's probably a good idea to do-so b4 running it.

-Joe

Mike C. Fletcher wrote:

I'm about 1/5th of the way through converting wxoo to use wxPython 2.5 (also doing some minimal cleanup along the way)

   * With 2.5.x there are apparently new dependencies on a running App
     object, for instance; you can't initialise the colour database
     until there's a running app (which means every module that relies
     on colour-database names has to do funky bookkeeping checks around
     each attempt to use the functionality to make sure that the init
     is called at least once).
   * You have to arrange to run all unit tests under a running wxApp
     (since any code which uses the newly App-dependent functionality
     is now going to fail). The following *doesn't* work (memory
     access violation), suggestions appreciated:
     if __name__ == "__main__":
         class TestApp( wxPySimpleApp ):
             def OnInit( self ):
                 frame = wxFrame( None, -1, "Some frame")
                 self.SetTopWindow( frame )
                 unittest.TextTestRunner().run( suite )
                 frame.Close()
         app = TestApp()
         app.MainLoop()
   * Watch out for any sub-packages/modules you've created that are
     named "wx", as they can shadow the wxPython module for other
     modules in those packages, so for instance, wxoo.wx and
     basictypes.wx both caused problems, all such packages/modules must
     be renamed (and then all uses of them changed, of course).
   * wxScrollEvent no longer takes a keyword "orientation" argument? Docs seem to suggest it still does.

Well, that's all for the first 17 modules. Only another 65 modules in wxoo and another 30 in conflict solver, given 6 hours for the first 17 it should only take about 30 hours for the whole conversion. Longer than I was hoping, but not killingly long.

BTW, I'd thought there was (somewhere) an upgrade script for those converting old modules to the new wx.* form, but I don't see it anywhere in the wx or wxPython directories on my 2.5.1 install.

Have fun all. Night,
Mike

_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

__author__ = "Joe Brown <joebrown@rclooke.com>"
__cvsid__ = "$Id: demo_convert.py,v 1.8 2003/04/01 09:03:29 joebrown Exp $"
__revision__ = "$Revision: 1.8 $"[11:-2]

from __future__ import generators
import os, sys, re

#globals used for counting changes
replacements = 0
files = 0

#needs_wart = {
# "module":[{"import statement to replace":"import replace with"} ,
# ["list of kewords to add a module.prefix"]],
# "AnotherModule":...
# }

needs_wart = {
    "wx":
    [
    {r"from[\s]*wxPython.wx[\s]*import[\s]*\*" : "from wxPython import wx"},
    [
    "EVT_BUTTON",
    "EVT_CHAR",
    "EVT_CHECKBOX",
    "EVT_CHILD_FOCUS",
    "EVT_CHOICE",
    "EVT_CLOSE",
    "EVT_COMBOBOX",
    "EVT_COMMAND_FIND",
    "EVT_COMMAND_FIND_CLOSE",
    "EVT_COMMAND_FIND_NEXT",
    "EVT_COMMAND_FIND_REPLACE",
    "EVT_COMMAND_FIND_REPLACE_ALL",
    "EVT_COMMAND_RIGHT_CLICK",
    "EVT_COMMAND_SCROLL",
    "EVT_END_PROCESS",
    "EVT_ENTER_WINDOW",
    "EVT_ERASE_BACKGROUND",
    "EVT_ICONIZE",
    "EVT_IDLE",
    "EVT_JOYSTICK_EVENTS",
    "EVT_KEY_DOWN",
    "EVT_KEY_UP",
    "EVT_KILL_FOCUS",
    "EVT_LEAVE_WINDOW",
    "EVT_LEFT_DCLICK",
    "EVT_LEFT_DOWN",
    "EVT_LEFT_UP",
    "EVT_LISTBOX",
    "EVT_LISTBOX_DCLICK",
    "EVT_LIST_COL_BEGIN_DRAG",
    "EVT_LIST_COL_CLICK",
    "EVT_LIST_COL_DRAGGING",
    "EVT_LIST_COL_END_DRAG",
    "EVT_LIST_COL_RIGHT_CLICK",
    "EVT_LIST_DELETE_ITEM",
    "EVT_LIST_ITEM_ACTIVATED",
    "EVT_LIST_ITEM_DESELECTED",
    "EVT_LIST_ITEM_SELECTED",
    "EVT_MAXIMIZE",
    "EVT_MENU",
    "EVT_MENU_RANGE",
    "EVT_MOTION",
    "EVT_MOUSEWHEEL",
    "EVT_MOUSE_EVENTS",
    "EVT_MOVE",
    "EVT_NOTEBOOK_PAGE_CHANGED",
    "EVT_NOTEBOOK_PAGE_CHANGING",
    "EVT_PAINT",
    "EVT_RADIOBOX",
    "EVT_RADIOBUTTON",
    "EVT_RIGHT_DOWN",
    "EVT_RIGHT_UP",
    "EVT_SASH_DRAGGED_RANGE",
    "EVT_SCROLL",
    "EVT_SCROLLWIN",
    "EVT_SET_FOCUS",
    "EVT_SIZE",
    "EVT_SPIN",
    "EVT_SPLITTER_SASH_POS_CHANGED",
    "EVT_SPLITTER_SASH_POS_CHANGING",
    "EVT_TASKBAR_LEFT_DCLICK",
    "EVT_TASKBAR_RIGHT_UP",
    "EVT_TEXT",
    "EVT_TEXT_ENTER",
    "EVT_TIMER",
    "EVT_TOGGLEBUTTON",
    "EVT_TOOL",
    "EVT_TOOL_ENTER",
    "EVT_TOOL_RCLICKED",
    "EVT_TREE_BEGIN_LABEL_EDIT",
    "EVT_TREE_END_LABEL_EDIT",
    "EVT_TREE_ITEM_ACTIVATED",
    "EVT_TREE_ITEM_COLLAPSED",
    "EVT_TREE_ITEM_EXPANDED",
    "EVT_TREE_SEL_CHANGED",
    "EVT_WINDOW_DESTROY",
    "ID_X_Position_Ctrl",
    "ID_Y_Position_Ctrl",
    "ID_V_Max_Ctrl",
    "ID_V_Min_Ctrl",
    "ID_Rudder_Max_Ctrl",
    "ID_Rudder_Min_Ctrl",
    "ID_Max_Axes_Ctrl",
    "ID_Max_Buttons_Ctrl",
    "ID_Z_Max_Ctrl",
    "ID_Y_Max_Ctrl",
    "ID_Y_Min_Ctrl",
    "ID_X_Min_Ctrl",
    "ID_Num_Sticks_Ctrl",
    "ID_Has_POV_CTS_Ctrl",
    "ID_Has_V_Ctrl",
    "ID_Has_U_Ctrl",
    "ID_V_Position_Ctrl",
    "ID_U_Position_Ctrl",
    "ID_POV_Position_Ctrl",
    "ID_Button_State_Ctrl",
    "ID_U_Max_Ctrl",
    "ID_U_Min_Ctrl",
    "ID_Polling_Max_Ctrl",
    "ID_Polling_Min_Ctrl",
    "ID_Num_Axes_Ctrl",
    "ID_Num_Buttons_Ctrl",
    "ID_X_Max_Ctrl",
    "ID_Z_Min_Ctrl",
    "ID_Prod_Name_Ctrl",
    "ID_Mfg_ID_Ctrl",
    "ID_Has_POV_4DIR_Ctrl",
    "ID_Has_POV_Ctrl",
    "ID_Has_Z_Ctrl",
    "ID_Has_Rudder_Ctrl",
    "ID_Rudder_Pos_Ctrl",
    "ID_POV_CTS_Pos_Ctrl",
    "ID_Z_Position_Ctrl",
    "NewId",
    "WXK_ADD",
    "WXK_ALT",
    "WXK_BACK",
    "WXK_CANCEL",
    "WXK_CAPITAL",
    "WXK_CLEAR",
    "WXK_CONTROL",
    "WXK_DECIMAL",
    "WXK_DELETE",
    "WXK_DIVIDE",
    "WXK_DOWN",
    "WXK_END",
    "WXK_ESCAPE",
    "WXK_EXECUTE",
    "WXK_F1",
    "WXK_F10",
    "WXK_F11",
    "WXK_F12",
    "WXK_F13",
    "WXK_F14",
    "WXK_F15",
    "WXK_F16",
    "WXK_F17",
    "WXK_F18",
    "WXK_F19",
    "WXK_F2",
    "WXK_F20",
    "WXK_F21",
    "WXK_F22",
    "WXK_F23",
    "WXK_F24",
    "WXK_F3",
    "WXK_F4",
    "WXK_F5",
    "WXK_F6",
    "WXK_F7",
    "WXK_F8",
    "WXK_F9",
    "WXK_HELP",
    "WXK_HOME",
    "WXK_INSERT",
    "WXK_LBUTTON",
    "WXK_LEFT",
    "WXK_MBUTTON",
    "WXK_MENU",
    "WXK_MULTIPLY",
    "WXK_NEXT",
    "WXK_NUMLOCK",
    "WXK_NUMPAD0",
    "WXK_NUMPAD1",
    "WXK_NUMPAD2",
    "WXK_NUMPAD3",
    "WXK_NUMPAD4",
    "WXK_NUMPAD5",
    "WXK_NUMPAD6",
    "WXK_NUMPAD7",
    "WXK_NUMPAD8",
    "WXK_NUMPAD9",
    "WXK_NUMPAD_ADD",
    "WXK_NUMPAD_BEGIN",
    "WXK_NUMPAD_DECIMAL",
    "WXK_NUMPAD_DELETE",
    "WXK_NUMPAD_DIVIDE",
    "WXK_NUMPAD_DOWN",
    "WXK_NUMPAD_END",
    "WXK_NUMPAD_ENTER",
    "WXK_NUMPAD_EQUAL",
    "WXK_NUMPAD_F1",
    "WXK_NUMPAD_F2",
    "WXK_NUMPAD_F3",
    "WXK_NUMPAD_F4",
    "WXK_NUMPAD_HOME",
    "WXK_NUMPAD_INSERT",
    "WXK_NUMPAD_LEFT",
    "WXK_NUMPAD_MULTIPLY",
    "WXK_NUMPAD_NEXT",
    "WXK_NUMPAD_PAGEDOWN",
    "WXK_NUMPAD_PAGEUP",
    "WXK_NUMPAD_PRIOR",
    "WXK_NUMPAD_RIGHT",
    "WXK_NUMPAD_SEPARATOR",
    "WXK_NUMPAD_SPACE",
    "WXK_NUMPAD_SUBTRACT",
    "WXK_NUMPAD_TAB",
    "WXK_NUMPAD_UP",
    "WXK_PAGEDOWN",
    "WXK_PAGEUP",
    "WXK_PAUSE",
    "WXK_PRINT",
    "WXK_PRIOR",
    "WXK_RBUTTON",
    "WXK_RETURN",
    "WXK_RIGHT",
    "WXK_SCROLL",
    "WXK_SELECT",
    "WXK_SEPARATOR",
    "WXK_SHIFT",
    "WXK_SNAPSHOT",
    "WXK_SPACE",
    "WXK_START",
    "WXK_SUBTRACT",
    "WXK_TAB",
    "WXK_UP",
    "wxACCEL_ALT",
    "wxACCEL_CTRL",
    "wxACCEL_NORMAL",
    "wxADJUST_MINSIZE",
    "wxALIGN_BOTTOM",
    "wxALIGN_CENTER",
    "wxALIGN_CENTER_HORIZONTAL",
    "wxALIGN_CENTER_VERTICAL",
    "wxALIGN_CENTRE", ### WHAT'S THIS???
    "wxALIGN_LEFT",
    "wxALIGN_RIGHT",
    "wxALIGN_TOP",
    "wxALL",
    "wxAND",
    "wxAND_INVERT",
    "wxAND_REVERSE",
    "wxART_ADD_BOOKMARK",
    "wxART_CMN_DIALOG",
    "wxART_CROSS_MARK",
    "wxART_DEL_BOOKMARK",
    "wxART_ERROR",
    "wxART_EXECUTABLE_FILE",
    "wxART_FILE_OPEN",
    "wxART_FOLDER",
    "wxART_FRAME_ICON",
    "wxART_GO_BACK",
    "wxART_GO_DIR_UP",
    "wxART_GO_DOWN",
    "wxART_GO_FORWARD",
    "wxART_GO_HOME",
    "wxART_GO_TO_PARENT",
    "wxART_GO_UP",
    "wxART_HELP",
    "wxART_HELP_BOOK",
    "wxART_HELP_BROWSER",
    "wxART_HELP_FOLDER",
    "wxART_HELP_PAGE",
    "wxART_HELP_SETTINGS",
    "wxART_HELP_SIDE_PANEL",
    "wxART_INFORMATION",
    "wxART_LIST_VIEW",
    "wxART_MENU",
    "wxART_MESSAGE_BOX",
    "wxART_NEW_DIR",
    "wxART_NORMAL_FILE",
    "wxART_OTHER",
    "wxART_PRINT",
    "wxART_QUESTION",
    "wxART_REPORT_VIEW",
    "wxART_TICK_MARK",
    "wxART_TIP",
    "wxART_TOOLBAR",
    "wxART_WARNING",
    "wxAcceleratorTable",
    "wxApp",
    "wxApp_SetMacAboutMenuItemId",
    "wxApp_SetMacExitMenuItemId",
    "wxArtProvider",
    "wxArtProvider_GetBitmap",
    "wxBITMAP_TYPE_BMP",
    "wxBITMAP_TYPE_GIF",
    "wxBITMAP_TYPE_JPEG",
    "wxBITMAP_TYPE_PNG",
    "wxBLACK",
    "wxBLACK_BRUSH",
    "wxBLACK_PEN",
    "wxBLUE",
    "wxBLUE_BRUSH",
    "wxBOLD",
    "wxBOTH",
    "wxBOTTOM",
    "wxBU_EXACTFIT",
    "wxBeginBusyCursor",
    "wxBell",
    "wxBitmapButton",
    "wxBitmapDataObject",
    "wxBitmapFromImage",
    "wxBottom",
    "wxBoxSizer",
    "wxBrush",
    "wxBufferedDC",
    "wxBufferedPaintDC",
    "wxBusyInfo",
    "wxButton",
    "wxCANCEL",
    "wxCAP_BUTT",
    "wxCB_DROPDOWN",
    "wxCB_READONLY",
    "wxCB_SIMPLE",
    "wxCENTER",
    "wxCHANGE_DIR",
    "wxCLEAR",
    "wxCLIP_CHILDREN",
    "wxCOPY",
    "wxCURSOR_ARROW",
    "wxCURSOR_HAND",
    "wxCURSOR_PENCIL",
    "wxCYAN",
    "wxCallAfter",
    "wxCentreX",
    "wxCentreY",
    "wxCheckBox",
    "wxCheckListBox",
    "wxChoice",
    "wxClientDC",
    "wxColor",
    "wxColour",
    "wxColourDialog",
    "wxComboBox",
    "wxCreateFileTipProvider",
    "wxCustomDataFormat",
    "wxCustomDataObject",
    "wxDD_DEFAULT_STYLE",
    "wxDD_NEW_DIR_BUTTON",
    "wxDEFAULT",
    "wxDEFAULT_DIALOG_STYLE",
    "wxDEFAULT_FRAME_STYLE",
    "wxDIRCTRL_DIR_ONLY",
    "wxDIRCTRL_SHOW_FILTERS",
    "wxDLG_PNT",
    "wxDLG_SZE",
    "wxDOT",
    "wxDOT_DASH",
    "wxDS_DRAG_CORNER",
    "wxDS_MANAGE_SCROLLBARS",
    "wxDataObjectComposite",
    "wxDefaultPosition",
    "wxDefaultSize",
    "wxDefaultValidator",
    "wxDialog",
    "wxDirDialog",
    "wxDragCopy",
    "wxDragImage",
    "wxDragLink",
    "wxDragMove",
    "wxDrag_AllowMove",
    "wxDropSource",
    "wxEAST",
    "wxEQUIV",
    "wxEVT_CHAR",
    "wxEXEC_ASYNC",
    "wxEXPAND",
    "wxEmptyBitmap",
    "wxEndBusyCursor",
    "wxExecute",
    "wxFRAME_NO_TASKBAR",
    "wxFR_NOMATCHCASE",
    "wxFR_NOUPDOWN",
    "wxFR_NOWHOLEWORD",
    "wxFR_REPLACEDIALOG",
    "wxFileDialog",
    "wxFileDropTarget",
    "wxFileHistory",
    "wxFileSystem_AddHandler",
    "wxFindReplaceData",
    "wxFindReplaceDialog",
    "wxFlexGridSizer",
    "wxFont",
    "wxFontData",
    "wxFontDialog",
    "wxFontEnumerator",
    "wxFrame",
    "wxGA_HORIZONTAL",
    "wxGA_SMOOTH",
    "wxGREEN",
    "wxGREEN_BRUSH",
    "wxGREEN_PEN",
    "wxGREY_PEN",
    "wxGridSizer",
    "wxGROW",
    "wxGauge",
    "wxGenericDirCtrl",
    "wxGetApp",
    "wxHORIZONTAL",
    "wxHSCROLL",
    "wxHeight",
    "wxICON_INFORMATION",
    "wxID_CANCEL",
    "wxID_CLOSE",
    "wxID_FILE1",
    "wxID_FILE2",
    "wxID_FILE3",
    "wxID_FILE4",
    "wxID_FILE5",
    "wxID_FILE6",
    "wxID_FILE7",
    "wxID_FILE8",
    "wxID_FILE9",
    "wxID_NEW",
    "wxID_OK",
    "wxID_OPEN",
    "wxID_SAVE",
    "wxID_SAVEAS",
    "wxIMAGE_LIST_SMALL",
    "wxINVERT",
    "wxITALIC",
    "wxITEM_CHECK",
    "wxITEM_NORMAL",
    "wxITEM_RADIO",
    "wxImage",
    "wxImageFromStream",
    "wxImageList",
    "wxInitAllImageHandlers",
    "wxJoystick",
    "wxKeyEvent",
    "wxLANGUAGE_FRENCH",
    "wxLAYOUT_BOTTOM",
    "wxLAYOUT_HORIZONTAL",
    "wxLAYOUT_LEFT",
    "wxLAYOUT_TOP",
    "wxLAYOUT_VERTICAL",
    "wxLB_EXTENDED",
    "wxLB_SINGLE",
    "wxLB_HSCROLL",
    "wxLB_SORT",
    "wxLC_HRULES",
    "wxLC_NO_HEADER",
    "wxLC_REPORT",
    "wxLC_VIRTUAL",
    "wxLC_VRULES",
    "wxLEFT",
    "wxLIGHT_GREY",
    "wxLIGHT_GREY_BRUSH",
    "wxLIGHT_GREY_PEN",
    "wxLIST_AUTOSIZE",
    "wxLIST_AUTOSIZE_USEHEADER",
    "wxLIST_FORMAT_RIGHT",
    "wxLIST_HITTEST_ONITEM",
    "wxLIST_MASK_FORMAT",
    "wxLIST_MASK_IMAGE",
    "wxLIST_MASK_TEXT",
    "wxLIST_STATE_SELECTED",
    "wxLI_HORIZONTAL",
    "wxLONG_DASH",
    "wxLayoutAlgorithm",
    "wxLayoutConstraints",
    "wxLeft",
    "wxListBox",
    "wxListCtrl",
    "wxListItem",
    "wxListItemAttr",
    "wxLogMessage",
    "wxLogTextCtrl",
    "wxLog_SetActiveTarget",
    "wxLog_SetTraceMask",
    "wxMDIParentFrame",
    "wxMEDIUM_GREY_PEN",
    "wxMODERN",
    "wxMULTIPLE",
    "wxMask",
    "wxMaskColour",
    "wxMemoryDC",
    "wxMemoryFSHandler",
    "wxMemoryFSHandler_AddFile",
    "wxMenu",
    "wxMenuBar",
    "wxMenuItem",
    "wxMessageBox",
    "wxMessageDialog",
    "wxMiniFrame",
    "wxNAND",
    "wxNB_BOTTOM",
    "wxNOR",
    "wxNORTH",
    "wxNORMAL",
    "wxNO_3D",
    "wxNO_BORDER",
    "wxNO_FULL_REPAINT_ON_RESIZE",
    "wxNO_OP",
    "wxNamedColor",
    "wxNamedColour",
    "wxNewEventType",
    "wxNewId",
    "wxNotebook",
    "wxNullBitmap",
    "wxNullColour",
    "wxOK",
    "wxOPEN",
    "wxOR",
    "wxOR_INVERT",
    "wxOR_REVERSE",
    "wxPD_APP_MODAL",
    "wxPD_CAN_ABORT",
    "wxPAPER_LETTER",
    "wxPreviewFrame",
    "wxPrintData",
    "wxPrintDialog",
    "wxPrintDialogData",
    "wxPrintPreview",
    "wxPROCESS_ENTER",
    "wxValidator_IsSilent",
    "wxPageSetupDialog",
    "wxPageSetupDialogData",
    "wxPaintDC",
    "wxPanel",
    "wxPen",
    "wxPlatform",
    "wxPoint",
    "wxPopupTransientWindow",
    "wxPopupWindow",
    "wxPostEvent",
    "wxPreDialog",
    "wxPrintDialog",
    "wxPrintDialogData",
    "wxPrinter",
    "wxPrintout",
    "wxProcess",
    "wxProgressDialog",
    "wxPyCommandEvent",
    "wxPyDefaultPosition",
    "wxPyDefaultSize",
    "wxPyDropTarget",
    "wxPyEvent",
    "wxPyLog",
    "wxPyTimer",
    "wxPyTipProvider",
    "wxPyTypeCast",
    "wxPyValidator",
    "wxRAISED_BORDER",
    "wxRA_SPECIFY_COLS",
    "wxRB_GROUP",
    "wxRED",
    "wxRED_BRUSH",
    "wxRED_PEN",
    "wxRegion",
    "wxRegionFromBitmap",
    "wxRIGHT",
    "wxROMAN",
    "wxRadioBox",
    "wxRadioButton",
    "wxRect",
    "wxRight",
    "wxSASH_BOTTOM",
    "wxSASH_RIGHT",
    "wxSASH_STATUS_OUT_OF_RANGE",
    "wxSASH_TOP",
    "wxSB_HORIZONTAL",
    "wxSET",
    "wxSHAPED",
    "wxSHORT_DASH",
    "wxSIMPLE_BORDER",
    "wxSIZE_ALLOW_MINUS_ONE",
    "wxSL_AUTOTICKS",
    "wxSL_HORIZONTAL",
    "wxSL_LABELS",
    "wxSOLID",
    "wxSOUTH",
    "wxSPLASH_CENTRE_ON_SCREEN",
    "wxSPLASH_TIMEOUT",
    "wxSP_3D",
    "wxSP_3DBORDER",
    "wxSP_VERTICAL",
    "wxSRC_INVERT",
    "wxSTANDARD_CURSOR",
    "wxSTAY_ON_TOP",
    "wxST_NO_AUTORESIZE",
    "wxST_SIZEGRIP",
    "wxSUNKEN_BORDER",
    "wxSWISS",
    "wxSW_3D",
    "wxSYS_COLOUR_3DLIGHT",
    "wxSafeYield",
    "wxSashLayoutWindow",
    "wxScrollBar",
    "wxScrolledWindow",
    "wxShowTip",
    "wxSingleChoiceDialog",
    "wxSize",
    "wxSleep",
    "wxSlider",
    "wxSpinButton",
    "wxSpinCtrl",
    "wxSplashScreen",
    "wxSplitterWindow",
    "wxStaticBitmap",
    "wxStaticBox",
    "wxStaticBoxSizer",
    "wxStaticLine",
    "wxStaticText", # import wxGenStaticText as wxStaticText gets choked
    "wxStatusBar",
    "wxStockCursor",
    "wxSystemSettings_GetSystemColour",
    "wxTAB_TRAVERSAL",
    "wxTB_FLAT",
    "wxTB_HORIZONTAL",
    "wxTB_TEXT",
    "wxTE_MULTILINE",
    "wxTE_NOHIDESEL",
    "wxTE_PASSWORD",
    "wxTE_PROCESS_ENTER",
    "wxTE_READONLY",
    "wxTE_RICH",
    "wxTE_RICH2",
    "wxTINY_CAPTION_HORIZ",
    "wxTOP",
    "wxTRANSPARENT",
    "wxTRANSPARENT_BRUSH",
    "wxTRANSPARENT_PEN",
    "wxTR_EDIT_LABELS",
    "wxTR_HAS_BUTTONS",
    "wxTR_HAS_VARIABLE_ROW_HEIGHT",
    "wxTR_HIDE_ROOT",
    "wxTR_MULTIPLE",
    "wxTR_NO_LINES",
    "wxTR_ROW_LINES",
    "wxTaskBarIcon",
    "wxTextAttr",
    "wxTextCtrl",
    "wxTextDataObject",
    "wxTextDropTarget",
    "wxTextEntryDialog",
    "wxTheClipboard",
    "wxTheMimeTypesManager",
    "wxTimer",
    "wxToggleButton",
    "wxToolTip",
    "wxTop",
    "wxTraceMessages",
    "wxTreeCtrl",
    "wxTreeItemIcon_Expanded",
    "wxTreeItemIcon_Normal",
    "wxTreeItemIcon_Selected",
    "wxURLDataObject",
    "wxUSER_DASH",
    "wxUSE_UNICODE",
    "wxVERTICAL",
    "wxVSCROLL",
    "wxWANTS_CHARS",
    "wxWEST",
    "wxWHITE",
    "wxWHITE_BRUSH",
    "wxWS_EX_VALIDATE_RECURSIVELY",
    "wxWave",
    "wxWidth",
    "wxWindow",
    "wxWindow_FindFocus",
    "wxXOR",
    "wxYield",
    #"NewId",
    ]],

    "intctrl" :
    [
    {r"from wxPython.lib.intctrl import \*" : "from wxPython.lib import intctrl"},
    [
    "EVT_INT",
    "wxIntCtrl",
    ]],

    "imagebrowser" :
    [
    {r"from wxPython.lib.imagebrowser import \*" : "from wxPython.lib import imagebrowser"},
    [
    "ImageDialog",
    ]],

    "grid":
    [
    {r"from wxPython.grid import \*" : "from wxPython import grid"},
    [
    "EVT_GRID_CELL_LEFT_CLICK",
    "EVT_GRID_CELL_LEFT_DCLICK",
    "EVT_GRID_CELL_RIGHT_CLICK",
    "EVT_GRID_CELL_RIGHT_DCLICK",
    "EVT_GRID_LABEL_LEFT_CLICK",
    "EVT_GRID_LABEL_LEFT_DCLICK",
    "EVT_GRID_LABEL_RIGHT_CLICK",
    "EVT_GRID_LABEL_RIGHT_DCLICK",
    "EVT_GRID_ROW_SIZE",
    "EVT_GRID_COL_SIZE",
    "EVT_GRID_RANGE_SELECT",
    "EVT_GRID_CELL_CHANGE",
    "EVT_GRID_SELECT_CELL",
    "EVT_GRID_EDITOR_SHOWN",
    "EVT_GRID_EDITOR_HIDDEN",
    "EVT_GRID_EDITOR_CREATED",
    "wxGRIDTABLE_NOTIFY_COLS_DELETED",
    "wxGRIDTABLE_NOTIFY_ROWS_DELETED",
    "wxGRID_VALUE_BOOL",
    "wxGRID_VALUE_CHOICE",
    "wxGRID_VALUE_FLOAT",
    "wxGRID_VALUE_NUMBER",
    "wxGRID_VALUE_STRING",
    "wxGrid",
    "wxGridCellAttr",
    "wxGridCellBoolEditor",
    "wxGridCellBoolRenderer",
    "wxGridCellChoiceEditor",
    "wxGridCellFloatEditor",
    "wxGridCellFloatRenderer",
    "wxGridCellNumberEditor",
    "wxGridCellNumberRenderer",
    "wxGridCellStringRenderer",
    "wxGridCellTextEditor",
    "wxPyGridCellEditor",
    "wxPyGridCellRenderer",
    "wxPyGridTableBase",
# "wxGridTableMessage", #???
    ]],

    "ErrorDialogs" :
    [
    {r"from wxPython.lib.ErrorDialogs import \*" : "from wxPython.lib import ErrorDialogs"},
    [
    "wxPyFatalError",
    "wxPyFatalErrorDialog",
    "wxPyFatalErrorDialogWithTraceback",
    "wxPyNonFatalError",
    "wxPyNonFatalErrorDialog",
    "wxPyNonFatalErrorDialogWithTraceback",
    ]],

    "wizard" :
    [
    {r"from wxPython.wizard import \*" : "from wxPython import wizard"},
    [
    "EVT_WIZARD_CANCEL",
    "EVT_WIZARD_PAGE_CHANGED",
    "EVT_WIZARD_PAGE_CHANGING",
    "wxPyWizardPage",
    "wxWizard",
    "wxWizardPageSimple",
    "wxWizardPageSimple_Chain",
    ]],

    "help" :
    [
    {r"from wxPython.help import \*" : "from wxPython import help"},
    [
    "EVT_HELP",
    "wxContextHelpButton",
    "wxDIALOG_EX_CONTEXTHELP",
    "wxHelpProvider_Set",
    "wxSimpleHelpProvider",
    ]],

    "stc" :
    [
    {r"from[\s]*wxPython.stc[\s]*import[\s]*\*" : "from wxPython import stc"},
    [
    "EVT_STC_DO_DROP",
    "EVT_STC_DRAG_OVER",
    "EVT_STC_MARGINCLICK",
    "EVT_STC_MODIFIED",
    "EVT_STC_START_DRAG",
    "EVT_STC_UPDATEUI",
    "wxSTC_CMD_ZOOMIN",
    "wxSTC_CMD_ZOOMOUT",
    "wxSTC_EDGE_BACKGROUND",
    "wxSTC_FOLDLEVELBASE",
    "wxSTC_FOLDLEVELHEADERFLAG",
    "wxSTC_FOLDLEVELNUMBERMASK",
    "wxSTC_INDIC0_MASK",
    "wxSTC_INDIC1_MASK",
    "wxSTC_INDIC2_MASK",
    "wxSTC_INDICS_MASK",
    "wxSTC_INDIC_DIAGONAL",
    "wxSTC_INDIC_SQUIGGLE",
    "wxSTC_INDIC_STRIKE",
    "wxSTC_LASTSTEPINUNDOREDO",
    "wxSTC_LEX_PYTHON",
    "wxSTC_MARGIN_NUMBER",
    "wxSTC_MARGIN_SYMBOL",
    "wxSTC_MARKNUM_FOLDER",
    "wxSTC_MARKNUM_FOLDEREND",
    "wxSTC_MARKNUM_FOLDERMIDTAIL",
    "wxSTC_MARKNUM_FOLDEROPEN",
    "wxSTC_MARKNUM_FOLDEROPENMID",
    "wxSTC_MARKNUM_FOLDERSUB",
    "wxSTC_MARKNUM_FOLDERTAIL",
    "wxSTC_MARK_ARROW",
    "wxSTC_MARK_ARROWDOWN",
    "wxSTC_MARK_BACKGROUND",
    "wxSTC_MARK_BOXMINUS",
    "wxSTC_MARK_BOXMINUSCONNECTED",
    "wxSTC_MARK_BOXPLUS",
    "wxSTC_MARK_BOXPLUSCONNECTED",
    "wxSTC_MARK_CIRCLE",
    "wxSTC_MARK_LCORNER",
    "wxSTC_MARK_ROUNDRECT",
    "wxSTC_MARK_SHORTARROW",
    "wxSTC_MARK_TCORNER",
    "wxSTC_MARK_VLINE",
    "wxSTC_MASK_FOLDERS",
    "wxSTC_MOD_BEFOREDELETE",
    "wxSTC_MOD_BEFOREINSERT",
    "wxSTC_MOD_CHANGEFOLD",
    "wxSTC_MOD_CHANGEMARKER",
    "wxSTC_MOD_CHANGESTYLE",
    "wxSTC_MOD_DELETETEXT",
    "wxSTC_MOD_INSERTTEXT",
    "wxSTC_PERFORMED_REDO",
    "wxSTC_PERFORMED_UNDO",
    "wxSTC_PERFORMED_USER",
    "wxSTC_P_CHARACTER",
    "wxSTC_P_CLASSNAME",
    "wxSTC_P_COMMENTBLOCK",
    "wxSTC_P_COMMENTLINE",
    "wxSTC_P_DEFAULT",
    "wxSTC_P_DEFNAME",
    "wxSTC_P_IDENTIFIER",
    "wxSTC_P_NUMBER",
    "wxSTC_P_OPERATOR",
    "wxSTC_P_STRING",
    "wxSTC_P_STRINGEOL",
    "wxSTC_P_TRIPLE",
    "wxSTC_P_TRIPLEDOUBLE",
    "wxSTC_P_WORD",
    "wxSTC_SCMOD_CTRL",
    "wxSTC_STYLE_BRACEBAD",
    "wxSTC_STYLE_BRACELIGHT",
    "wxSTC_STYLE_CONTROLCHAR",
    "wxSTC_STYLE_DEFAULT",
    "wxSTC_STYLE_LINENUMBER",
    "wxStyledTextCtrl",
    ]],

    "glcanvas" :
    [
    {r"from wxPython.glcanvas import \*" : "from wxPython import glcanvas"},
    [
    "GL_AMBIENT",
    "GL_COLOR_BUFFER_BIT",
    "GL_DEPTH_BUFFER_BIT",
    "GL_DEPTH_TEST",
    "GL_DIFFUSE",
    "GL_FRONT",
    "GL_LESS",
    "GL_LIGHT0",
    "GL_LIGHTING",
    "GL_LIGHT_MODEL_AMBIENT",
    "GL_MODELVIEW",
    "GL_POSITION",
    "GL_PROJECTION",
    "GL_QUADS",
    "GL_SHININESS",
    "GL_SPECULAR",
    "glBegin",
    "glClear",
    "glDepthFunc",
    "glEnd",
    "glFrustum",
    "glLight",
    "glLightModel",
    "glMaterial",
    "glMatrixMode",
    "glNormal3f",
    "glPopMatrix",
    "glRotate",
    "glRotatef",
    "glTranslate",
    "glTranslatef",
    "glVertex3f",
    "glViewport",
    "glutSolidCone",
    "wxGLCanvas",
    "wxRealPoint",
    ]],

    "iewin" :
    [
    {r"from wxPython.iewin import \*" : "from wxPython import iewin"},
    [
    "EVT_MSHTML_BEFORENAVIGATE2",
    "EVT_MSHTML_DOCUMENTCOMPLETE",
    "EVT_MSHTML_NEWWINDOW2",
    "EVT_MSHTML_PROGRESSCHANGE",
    "EVT_MSHTML_STATUSTEXTCHANGE",
    "EVT_MSHTML_TITLECHANGE",
    "wxIEHTML_REFRESH_COMPLETELY",
    "wxIEHtmlWin",
    ]],

    "calendar" :
    [
    {r"from wxPython.calendar import \*" : "from wxPython import calendar"},
    [
    "EVT_CALENDAR",
    "EVT_CALENDAR_DAY",
    "EVT_CALENDAR_MONTH",
    "wxCAL_SHOW_HOLIDAYS",
    "wxCAL_SUNDAY_FIRST",
    "wxCalendarCtrl",
    "wxDateTime_Now",
    "wxDateTime_Today",
    ]],

    "gizmos" :
    [
    {r"from wxPython.gizmos import \*" : "from wxPython import gizmos"},
    [
    "EVT_DYNAMIC_SASH_SPLIT",
    "EVT_DYNAMIC_SASH_UNIFY",
    "wxDynamicSashWindow",
    "wxEL_ALLOW_DELETE",
    "wxEL_ALLOW_EDIT",
    "wxEL_ALLOW_NEW",
    "wxEditableListBox",
    "wxLEDNumberCtrl",
    "wxLED_ALIGN_CENTER",
    "wxLED_ALIGN_RIGHT",
    "wxLED_DRAW_FADED",
    "wxRemotelyScrolledTreeCtrl",
    "wxSplitterScrolledWindow",
    "wxThinSplitterWindow",
    "wxTreeCompanionWindow",
    ]],

    "html" :
    [
    {r"from[\s]*wxPython.html[\s]*import[\s]*\*" : "from wxPython import html"},
    [
    "wxHtmlEasyPrinting",
    "wxHtmlFilter",
    "wxHtmlWindow",
    "wxHtmlWindow_AddFilter",
    ]],

    "buttons" :
    [
    {r"from wxPython.lib.buttons import \*" : "from wxPython.lib import buttons"},
    [
    "wxGenBitmapButton",
    "wxGenBitmapTextButton",
    "wxGenBitmapToggleButton",
    "wxGenButton",
    "wxGenToggleButton",
    ]],

    "colourselect" :
    [
    {r"from wxPython.lib.colourselect import \*" : "from wxPython.lib import colourselect"},
    [
    "ColourSelect",
    "EVT_COLOURSELECT",
    ]],

    "floatbar" :
    [
    {r"from wxPython.lib.floatbar import \*" : "from wxPython.lib import floatbar"},
    [
    "wxFloatBar",
    ]],

    "infoframe" :
    [
    {r"from wxPython.lib.infoframe import \*" : "from wxPython.lib import infoframe"},
    [
    "wxPyInformationalMessagesFrame",
    ]],

    "mvctree" :
    [
    {r"from wxPython.lib.mvctree import \*" : "from wxPython.lib import mvctree"},
    [
    "EVT_MVCTREE_ADD_ITEM",
    "EVT_MVCTREE_DELETE_ITEM",
    "EVT_MVCTREE_ITEM_COLLAPSED",
    "EVT_MVCTREE_ITEM_EXPANDED",
    "EVT_MVCTREE_KEY_DOWN",
    "EVT_MVCTREE_SEL_CHANGED",
    "EVT_MVCTREE_SEL_CHANGING",
    "LateFSTreeModel",
    "wxMVCTree",
    ]],

    "timectrl" :
    [
    {r"from wxPython.lib.timectrl import \*" : "from wxPython.lib import timectrl"},
    [
    "EVT_TIMEUPDATE",
    "wxTimeCtrl",
    ]],

    "wxPlotCanvas" :
    [
    {r"from wxPython.lib.wxPlotCanvas import \*" : "from wxPython.lib import wxPlotCanvas"},
    [
    "PlotCanvas",
    "PlotGraphics",
    "PolyLine",
    "PolyMarker",
    ]],

    "ogl" :
    [
    {r"from wxPython.ogl import \*" : "from wxPython import ogl"},
    [
    "ARROW_ARROW",
    "FORMAT_CENTRE_HORIZ",
    "FORMAT_CENTRE_VERT",
    "FORMAT_NONE",
    "wxBitmapShape",
    "wxCircleShape",
    "wxDiagram",
    "wxDividedShape",
    "wxLineShape",
    "wxOGLCleanUp",
    "wxOGLInitialize",
    "wxPolygonShape",
    "wxRectangleShape",
    "wxShapeCanvas",
    "wxShapeEvtHandler",
    "wxShapeRegion",
    ]],

## "utils" :
## [
## {r"from wxPython.utils import \*" : "from wxPython import utils"},
## [
## ]],

    "xrc" :
    [
    {r"from wxPython.xrc import \*" : "from wxPython import xrc"},
    [
    "wxXmlResource",
    "wxEmptyXmlResource",
    "wxXmlResourceHandler",
    ]],

## "GL" :
## [
## {r"from OpenGL.GL import \*" : "from OpenGL import GL"},
## [
## ]],

## "GLUT" :
## [
## {r"from OpenGL.GLUT import \*" : "from OpenGL import GLUT"},
## [
## ]],

    "joystick" :
    [
    {r"from joystick_wdr import \*" : "import joystick_wdr as joystick"},
    [
    "MakeJoystickTestPanel",
    ]],

    "mimetypes_wdr" :
    [
    {r"from mimetypes_wdr import \*" : "import mimetypes_wdr"},
    [
    "ID_ICON_INDEX_TXT",
    "ID_ICON_FILE_TXT",
    "ID_MIME_BTN",
    "ID_LISTBOX",
    "ID_LOOKUP_BTN",
    "ID_EXTENSION_Btn",
    "ID_ALL_CMDS_TXT",
    "ID_PRINT_CMD_TXT",
    "ID_OPEN_CMD_TXT",
    "ID_DESCRIPTION_TXT",
    "ID_EXTENSIONS_TXT",
    "ID_MIME_TYPES_TXT",
    "ID_MIME_TYPE_TXT",
    "ID_ICON_BMP",
    "ID_INPUT_TEXT",
    "MakeMimeTypesTestPanel",
    ]],

# "viewer_basics" :
# [
# {r"from viewer_basics import \*" : "import viewer_basics"},
# [
# ]]
    }

def dirwalk(dir):
    "walk a directory tree, using a generator"
    for f in os.listdir(dir):
        fullpath = os.path.join(dir,f)
        if os.path.isdir(fullpath) and not os.path.islink(fullpath):
            for x in dirwalk(fullpath): # recurse into subdir
                yield x
        else:
            yield fullpath

def replaceImports(data, wart, needswhat):
    global replacements
    keys = needswhat[0].keys()
    for key in keys:
        p = re.compile(key)
        if p.search(data):
            sys.stdout.write('*')
            data = p.sub(needswhat[0][key], data)
            needswhat[1].sort(lambda a,b: len(b)-len(a)) #reverse length
            for nose in needswhat[1]:
                data = addWart(data, wart, nose)
            replacements += 1

    return data

def addWart(data, wart, nose):
    global replacements
    p = re.compile(r"(?<![\w'\".])" + nose + r"\b")
    #p = re.compile(r"(?<=[\s(){}\]!@$%^&=,\\[+\-\*])" + nose + r"\b")
    if p.search(data):
        sys.stdout.write('.')
        data = p.sub(wart+'.'+nose, data)
        replacements += 1
    return data

def Usage():
    print """
    demo_convert.py [--doit] dir

    converts wx.py files from using the convention
    from wxPython.wx import *
    to
    from wxPythone import wx

    It recurses subdirectories and rewrites all .py files found
    Use with extreme caution.

    --doit rewrites files, otherwise it only counts replacments.
    """
    sys.exit(1)

def Main(*args):
    global files, replacements
    global needs_wart
    replaceFiles = False
    if len(args) == 2:
        if args[0] == '--doit':
            replaceFiles = True
            dir = args[1]
        else:
            Usage()
    elif len(args) == 1 and not args[0] in ['--help','/h','-h']:
        dir = args[0]
    else:
        Usage()

    for file in dirwalk(dir):
        if file[-3:] == '.py':
            print "%-30s" % file,
            files += 1
            sourceFile = open(file)
            sourceText = sourceFile.read()
            sourceFile.close()
            for wart in needs_wart.keys():
                sourceText = replaceImports(sourceText, wart, needs_wart[wart])
            print
            if replaceFiles:
                newFile = open(file, 'w')
                newFile.write(sourceText)
                newFile.close()
    print "files %d, replacements %d" % (files, replacements)

if __name__ == "__main__":
    Main(*sys.argv[1:])

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Attached script should give you a listing of the changes, basically it just loads the two modules and sees which things compare equal that are likely to be wx names. Planning to integrate this into an auto-conversion script as soon as I get some time. My version of the script automates the stripping of the wx prefixes based on two lists of "strip" and "nostrip", so it should be able to use the generated lists.

Have fun,
Mike

Kevin Altis wrote:

simplemapping.py (1.06 KB)

···

Now that I'm in the middle of converting over all of the PythonCard code to 2.5.x I'm looking for more info on what did and didn't change in the namespace. It seems like the only thing that kept the wx prefix are the event constants which would otherwise conflict with the event function wrappers. For example wx.EVT_KEY_UP() and wx.wxEVT_KEY_UP.

I think this needs to be described in more detail in the migration guide.

ka

_______________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://members.rogers.com/mcfletch/

Thanks,
that appears to confirm that as far as lowercase wx prefixes go, only the event constants need to be left alone in the wx namespace. I already use 'from wxPython import wx' everywhere, so that is an easy change to 'import wx' except where I did something like 'from wxPython import wx, stc' so I'll change those manually.

To deal with the wx.wxEVT constants I planned to do a global case-sensitive replace in all files to something unique like

wx.wxEVT -> wx~TEMP~wxEVT

Then a global case-sensitive replace of

wx.wx -> wx.

should fix the items in the wx namespace that changed, then I do a global replace to fix the earlier temporary change.

wx~TEMP~wxEVT -> wx.wxEVT

Things are more difficult for everyone still using from wxPython.wx import * but if you use that style of import you deserve some pain <wink>

I want to manually look at all uses of the shadow classes like 'if isintance(bmp, (wx.wxBitmap, wx.wxBitmapPtr)' as I clean the code. I still have a lot of 'if' blocks for wxPython 2.3.x stuff that I have to toss as well.

ka

···

On Apr 12, 2004, at 12:46 PM, Mike C. Fletcher wrote:

Attached script should give you a listing of the changes, basically it just loads the two modules and sees which things compare equal that are likely to be wx names. Planning to integrate this into an auto-conversion script as soon as I get some time. My version of the script automates the stripping of the wx prefixes based on two lists of "strip" and "nostrip", so it should be able to use the generated lists.

Have fun,
Mike

Kevin Altis wrote:

Now that I'm in the middle of converting over all of the PythonCard code to 2.5.x I'm looking for more info on what did and didn't change in the namespace. It seems like the only thing that kept the wx prefix are the event constants which would otherwise conflict with the event function wrappers. For example wx.EVT_KEY_UP() and wx.wxEVT_KEY_UP.

I think this needs to be described in more detail in the migration guide.

ka

_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/

from wxPython import wx as wxOld
import wx

def buildMapping( old, new ):
  """Create lists for translating old to new module"""
  strip,noStrip = ,
  prefixes = ['EVT','WXK','ID',]
  for key,value in old.__dict__.iteritems():
    if key == 'wx':
      continue
    for prefix in prefixes:
      if key.startswith( prefix ):
        if getattr(new, key, None ) == value:
          noStrip.append( key )
      elif key.startswith( 'wx' ) and not key=='wxDefaultDateTime':
        # wxDefaultDateTime raises fatal assertion error on compare!
        try:
          if getattr(new, key[2:], None ) == value:
            strip.append( key )
          elif getattr(new, key, None ) == value:
            noStrip.append( key )
        except wx.PyAssertionError:
          print '''WARNING: couldn't compare name %r'''%(key,)
  return noStrip, strip

if __name__ == "__main__":
  import sys
  def doPrint( ):
    wxNoStrip, wxStrip = buildMapping( wxOld, wx )
    wxNoStrip.sort()
    wxStrip.sort()
    print 'NoStrip'
    for no in wxNoStrip:
      print no
    print
    print 'Strip'
    for yes in wxStrip:
      print yes
    sys.stderr.write( 'Finished' )
    
  doPrint()

Kevin Altis wrote:

Now that I'm in the middle of converting over all of the PythonCard code to 2.5.x I'm looking for more info on what did and didn't change in the namespace. It seems like the only thing that kept the wx prefix are the event constants which would otherwise conflict with the event function wrappers. For example wx.EVT_KEY_UP() and wx.wxEVT_KEY_UP.

Correct, the only things that do not have a SWIG %rename directive generated for them are those that start with "wxEVT", everything else with a leading wx does get %rename'd. See this script for the ugly details:

http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/wxPython/distrib/build_renamers.py?rev=1.8&content-type=text/vnd.viewcvs-markup

(BTW, I think that only the libxml2 version of this is currently working correctly.)

···

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