First app, thanks people

Cyril Bazin cyril.bazin at gmail.com
Mon Jul 25 12:48:15 EDT 2005


In case you want some advises for your code: 

-backslashes are not necesseary when you declare list or dict on many lines.

I didn't pay attention at the semantic of your code, but after giving a 
quick look, you can simplify things like:

BRUSHSTYLENAMES = ['Transparent', 'Solid', 'BDiagonalHatch', 'CrossDiagHatch', \
	'FDiagonalHatch', 'CrossHatch', 'HorizontalHatch', 'VerticalHatch' ]

BSTYLES = { BRUSHSTYLENAMES[0]: wxTRANSPARENT, \
	BRUSHSTYLENAMES[1]: wxSOLID, \
	BRUSHSTYLENAMES[2]: wxBDIAGONAL_HATCH, \
	BRUSHSTYLENAMES[3]: wxCROSSDIAG_HATCH, \
	BRUSHSTYLENAMES[4]: wxFDIAGONAL_HATCH, \
	BRUSHSTYLENAMES[5]: wxCROSS_HATCH, \
	BRUSHSTYLENAMES[6]: wxHORIZONTAL_HATCH, \
	BRUSHSTYLENAMES[7]: wxVERTICAL_HATCH }

BRUSHSTYLES = [ wxTRANSPARENT, wxSOLID, wxBDIAGONAL_HATCH, wxCROSSDIAG_HATCH, \
	wxFDIAGONAL_HATCH, wxCROSS_HATCH, wxHORIZONTAL_HATCH, wxVERTICAL_HATCH ]


By writing something like :

BRUSHSTYLENAMES = ['Transparent', 'Solid', 'BDiagonalHatch', 'CrossDiagHatch', 
	'FDiagonalHatch', 'CrossHatch', 'HorizontalHatch', 'VerticalHatch' ]

BRUSHSTYLES = [ wxTRANSPARENT, wxSOLID, wxBDIAGONAL_HATCH, wxCROSSDIAG_HATCH, 
	wxFDIAGONAL_HATCH, wxCROSS_HATCH, wxHORIZONTAL_HATCH, wxVERTICAL_HATCH ]

BSTYLES = dict(zip(BRUSHSTYLENAMES, BRUSHSTYLES))

Or by declaring the dict BSTYLES first and then doing "BRUSHSTYLENAMES, 
BRUSHSTYLES=BSTYLES.items()" (In this case, the lists will not be ordered)

Moreover, wxPython should be better called wx.Python now. ;-)
You shouldn't use:

from wxPython.wx import *

But 

 import wx

and then calling wx.Brush instead of wxBrush, wx.SOLID instead of wxSOLID, 
etc

Except these little things, if your code works, it's perfect! 
I told you these advises to improve your way of coding in Python ;-)

Cyril
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20050725/186d3466/attachment.html>


More information about the Python-list mailing list