[Go to site: main page, start]

Introduction

/!\ As of 2017, below info is quite outdated. /!\

Hints on how to change the generated code sections of a Boa 0.3.1 (or earlier) file to make it work under Boa 0.4.0-pre.

Currently code generated with Boa 0.3.1 or earlier will not work with Boa 0.4.0-pre as it is using the wxPython 2.5.x code style. The following is a start in documenting what is needed and what tools are available to help.

This is in no way complete, but hopefully it will help someone. I also hope that over time we can make this much more complete so that the transition will become very easy and painless.

Steps to convert a module

* Run the wx25upgrade.py

  • In the latest Boa 0.4.0 from CVS this is available from the Tools menu

* Review import statements

  • Many of the standard ones are converted
    • Check "self.importNames" in wx25upgrade.py in boa/ExternalLib
  • Cases not shown in "self.importNames" need to be changed by hand, e.g.

* Try to open the file in the Boa Designer, and fix problems as they are reported.

Tools

The "upgrade.py" tool written by PaulSorenson has been renamed to "wx25upgrade.py" and is now distributed with the latest Boa 0.4.0 pre version.

You can run the tool from the Boa "Tools" menu by selecting the option "wxPython 2.4 to 2.5 code upgrader".

It allows you to convert a single file or all .py files in a folder/directory.

  • When converting a single file the updated version has "Upg" appended to its name.
  • When converting a folder/directory it creates a folder/directory with "Upgraded" appended to the original name and the updated versions of the files are placed in it.

The tool converts the following:

  • EVT_xxx change from wxPython 2.4 style to 2.5 style
  • Append for menu, changes 'helpString' to 'help', 'item' to 'text' and wxITEM to wx.ITEM
  • changes the 'map(lambda _init_whatever: wxNewId()' to the new format
  • changes the classes from wxName to wx.Name
    • check "self.specialNames" to see which special cases are handled
  • changes the 'init' from wxName.init to wx.Name.init

  • changes imports
    • check "self.importNames" to see which imports are handled
  • true and false to True and False
  • SetStatusText "(i=" keyword to "(number="

  • AddSpacer "n, n" to wx.Size(n, n)

  • flag= i.e. flag=wxALL
  • style= i.e. style=wxDEFAULT_DIALOG_STYLE
  • wxInitAllImageHandlers( to wx.InitAllImageHandlers(

  • orient=wx to orient=wx.
  • kind=wxITEM to kind=wx.ITEM
  • Following changes are handled, see "self.specialNames2"
    • wxIcon( to wx.Icon(
    • wxBITMAP to wx.BITMAP
    • wxBitmap( to wx.Bitmap(
    • wxSize( to wx.Size(
    • wxNullBitmap to wx.NullBitmap

    • wxPoint( to wx.Point(
    • wxNewID to wx.NewID (used elsewhere then in the lambda statement)
    • wxColour to wx.Colour
    • wxOPEN to wx.OPEN
    • wxID_OK to wx.ID_OK
    • wxRED to wx.RED
    • wxGREEN to wx.GREEN
    • wxBLUE to wx.BLUE
    • wxGrid.wxGrid to wx.grid.Grid.wxGrid
    • wxACCEL to wx.ACCEL
    • wxAcceleratorTable to wx.AcceleratorTable

    • wxTheClipboard to wx.TheClipboard

    • wxID_YES to wx.ID_YES
    • wxOK to wx.OK
    • wxICON_ to wx.ICON_
    • wxPySimpleApp to wx.PySimpleApp

    • wxYES_NO to wx.YES_NO
    • wxYES_DEFAULT to wx.YES_DEFAULT
    • wxNO_DEFAULT to wx.NO_DEFAULT
    • wxID_YES to wx.ID_YES
    • wxID_NO to wx.ID_NO
    • wxID_OK to wx.ID_OK
    • wxID_CANCEL to wx.ID_CANCEL
    • wxCallAfter to wx.CallAfter

    • wxDefault to wx.Default
    • wxNamedColor to wx.NamedColor

    • wxIMAGE to wx.IMAGE
    • wxLIST to wx.LIST
    • WXK_ to wx.WXK_
    • wxTL_ to wx.gizmos.TL_
    • wxBeginBusyCursor to wx.BeginBusyCursor

    • wxEndBusyCursor to wx.EndBusyCursor

    • wxMessageBox to wx.MessageBox

    • wxTreeList to wx.gizmos.TreeList

    • wxEmptyBitmap to wx.EmptyBitmap

    • wxCOPY to wx.COPY
    • wxImage to wx.Image
    • wxWave to wx.Sound
    • wxUsleep to wx.Usleep
    • wxSafeYield to wx.SafeYield

    • wxToolTip to wx.ToolTip

    • wxCAP_ to wx.CAP_
    • wxJOIN_ to wx.JOIN_
    • wxSHORT_DASH to wx.SHORT_DASH
    • wxDOT_DASH to wx.DOT_DASH
    • wxDOT to wx.DOT
    • wxSAVE to wx.SAVE
    • wxOVERWRITE_PROMPT to wx.OVERWRITE_PROMPT
    • wxCHANGE_DIR to wx.CHANGE_DIR
    • wxMULTIPLE to wx.MULTIPLE
    • wxSOLID to wx.SOLID
    • wxLIGHT to wx.LIGHT
    • wxNORMAL to wx.NORMAL
    • wxBOLD to wx.BOLD
    • wxTRANSPARENT to wx.TRANSPARENT
    • wxITALIC to wx.ITALIC
    • wxSLANT to wx.SLANT
    • wxSWISS to wx.SWISS
    • wxROMAN to wx.ROMAN
    • wxSCRIPT to wx.SCRIPT
    • wxDECORATIVE to wx.DECORATIVE
    • wxMODERN to wx.MODERN
    • wxCURSOR to wx.CURSOR_
    • wxPen to wx.Pen
  • wxFont, i.e. wxFont(8,wxSWISS,wxNORMAL,wxNORMAL to wx.Font(8,wx.SWISS,wx.NORMAL,wx.NORMAL
  • _custom_classes are changed

Other code changes

The following changes are not handled by the tool, i.e. you have to do them by hand - at least at this time. Whenever you find something which is not handled please update this section or send me an e-mail!

wx.Timer constructor change

  • "evtHandler=" to "owner="

wx.SplitterWindow change

  • wxSP_FULLSASH no longer supported

Troubleshooting

It some cases it has been necessary to re-indent the file before running it through the updater. You can do this by selecting in Boa the menu option File/Reindent whole file.

I believe that pyparsing gets confused and this shows that e.g. EVT_TEXT(.... gets converted to EVT_TEXself.bind etc or that the converted text does not show in the right place.

The latest version of wx25upgrade.py, delivered as of March 15, 2005 does the re-indent automatically. - Thanks to Riaan.

Note: Using the upgrader on a file which has been partially or totally converted to the 2.5 wx namespace might cause it to generate invalid code for certain things.

Note 2: You might have to get the most current version from CVS.

Comments

Please feel free to update this page or send changes you would like added to me at werner.bruhin@free.fr .

Boa040Upgrade (last edited 2017-06-05 19:13:53 by ffx)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.