Thanks Rob.
You've broken a number of "rules" code code formatting there ;-)
A big one is aligning things vertically, which, as a rule, I like. but this example does really push things out away from each other, so I'm not so sure.
I found that the original looked like heck when I first opened it in my editor -- once I made the window wide enough it was better, but still pretty stretched out.
Just for fun, here it is after being run through Black (which I don't usually use ....) -- but I think it looks better that way.
Also -- my first thought looking at that was that it could really benefit from the pattern matching :-)
And my second thought was that there could be a whole other pattern used here -- I usually find long chained elifs can be better expressed as a dict selection, or subclassing, or ...
But not seeing the rest of the application, maybe maybe not in this case.
if ch == "B":
self.ToggleBackgroundColour(event)
elif ch == "C":
self.ChangeCommonChars(event)
return
elif ch == "D" and len(Areas) > 1:
self.DeleteArea(event)
return
elif ch == "F" and __debug__:
self.Info(event)
return
elif ch == "I":
self.ChangeImagesToScroll(event)
return
elif ch == "J" and self.NUMBER_OF_IMAGES == 1:
self.ChangeJustification(event)
return
elif ch == "L":
self.ToggleShowLabels(event)
elif ch == "M" and MaxNumberOfImages > 1:
self.ChangeNumberOfImages(event)
elif ch == "N" and CanZapImage:
self.Rename(event)
elif ch == "R" and not (area.Dynamic | area.IsTour):
self.ToggleRandom(event, 1)
elif ch == "S":
self.ToggleSets(event, 1)
elif ch == "T":
self.ChangeTimer(event)
return
elif ch == "U" and not (area.Dynamic | area.Random):
self.ToggleIsTour(event, 1)
elif ch == "V" and OnAnImage:
self.WindowsPhotoViewer(event)
return
elif ch == "W":
self.ToggleWrap(event, 1)
elif ch == "Y" and not (area.Random | area.IsTour):
self.ToggleDynamic(event, 1)
elif ch == "Z" and CanZapImage:
self.Zap(event)
elif ch == "A" and not (area.Dynamic | area.IsTour):
self.ToggleRandom(event, 1)
# Alt-R doesn't always work for some reason, so we give Alt-A as an alternative
else:
event.Skip()
Christopher Barker, PhD (Chris)
Python Language Consulting
- Teaching
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython