Skip to content

Commit

Permalink
wxGUI: Fixed bare 'except' for psmap/ (#4623)
Browse files Browse the repository at this point in the history
  • Loading branch information
arohanajit authored Nov 6, 2024
1 parent 760d763 commit 98bccea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ per-file-ignores =
gui/scripts/d.wms.py: E501
gui/wxpython/image2target/g.gui.image2target.py: E501
gui/wxpython/photo2image/g.gui.photo2image.py: E501
gui/wxpython/psmap/*: E501, E722
gui/wxpython/psmap/*: E501
gui/wxpython/vdigit/*: F841, E722, F405, F403
gui/wxpython/animation/g.gui.animation.py: E501
gui/wxpython/tplot/frame.py: F841, E722
Expand Down
18 changes: 4 additions & 14 deletions gui/wxpython/psmap/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,19 +1045,9 @@ def makePSFont(self, textDict):
if "Bold" in fontstyle:
weight = wx.FONTWEIGHT_BOLD

try:
fn = wx.Font(
pointSize=fontsize, family=family, style=style, weight=weight, face=face
)
except:
fn = wx.Font(
pointSize=fontsize,
family=wx.FONTFAMILY_DEFAULT,
style=wx.FONTSTYLE_NORMAL,
weight=wx.FONTWEIGHT_NORMAL,
)

return fn
return wx.Font(
pointSize=fontsize, family=family, style=style, weight=weight, faceName=face
)

def getTextExtent(self, textDict):
"""Estimates bounding rectangle of text"""
Expand All @@ -1071,7 +1061,7 @@ def getTextExtent(self, textDict):
dc.SetFont(fn)
w, h, lh = dc.GetFullMultiLineTextExtent(textDict["text"])
return (w, h)
except:
except (wx.PyAssertionError, ValueError, KeyError):
return (0, 0)

def getInitMap(self):
Expand Down

0 comments on commit 98bccea

Please sign in to comment.