Skip to content

Commit

Permalink
fix ExplainCanvas
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-p committed Apr 19, 2022
1 parent 82cc236 commit e47bd74
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion modPg/Database.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The Admin4 Project
# (c) 2013-2014 Andreas Pflug
# (c) 2013-2022 Andreas Pflug
#
# Licensed under the Apache License,
# see LICENSE.TXT for conditions of usage
Expand Down
35 changes: 19 additions & 16 deletions modPg/_explain.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The Admin4 Project
# (c) 2013-2014 Andreas Pflug
# (c) 2013-2022 Andreas Pflug
#
# Licensed under the Apache License,
# see LICENSE.TXT for conditions of usage
Expand Down Expand Up @@ -66,7 +66,7 @@ def GetAverageCost(self):

def OnDraw(self, dc):
bmp=self.GetBitmap()
if not bmp.Ok():
if not bmp.IsOk():
return
x=int(self.GetX() - bmp.GetWidth()/2)
y=int(self.GetY() - bmp.GetHeight()/2)
Expand Down Expand Up @@ -97,7 +97,7 @@ def OnLeftClick(self, _x, _y, _keys, _attachment):

@staticmethod
def Create(level, last, desc):
costPos=str.find("(cost=");
costPos=desc.find("(cost=");
if costPos>0:
descr=desc[0:costPos]
else:
Expand Down Expand Up @@ -160,12 +160,12 @@ def Create(level, last, desc):
s.level = level

if costPos > 0:
actPos = str.find("(actual")
actPos = desc.find("(actual")
if actPos > 0:
s.actual = str[actPos:]
s.cost = str[costPos:actPos-costPos]
s.actual = desc[actPos:]
s.cost = desc[costPos:actPos-costPos]
else:
s.cost = str[costPos:]
s.cost = desc[costPos:]

w=50
h=20
Expand All @@ -185,7 +185,7 @@ def Create(level, last, desc):
s.kidNo = 0

if costPos > 0:
cl=str[costPos+6:-1].split(' ')
cl=desc[costPos+6:-1].split(' ')
costs=cl[0].split('..')
s.costLow=float(costs[0])
s.costHigh=float(costs[1])
Expand Down Expand Up @@ -215,8 +215,8 @@ def __init__(self, fromShape, toShape):

def OnDraw(self, dc):
if self._lineControlPoints:
dc.SetPen(wx.ThePenList.FindOrCreatePen(wx.BLACK, 1, wx.SOLID))
dc.SetBrush(wx.TheBrushList.FindOrCreateBrush(wx.LIGHT_GREY, wx.SOLID))
dc.SetPen(wx.BLACK_PEN)
dc.SetBrush(wx.LIGHT_GREY_BRUSH)
p0x,p0y=self.startPoint
p3x,p3y=self.endPoint

Expand Down Expand Up @@ -271,21 +271,23 @@ def SetData(self, rowset):
maxLevel=0

while rowset.HasMore():
tmp=rowset.Next()[0]
self.result.append(tmp)
line=tmp.strip()
row1=rowset.Next()[0]
self.result.append(row1)
line=row1.strip()

while True:
if line.count('(') > line.count(')') and rowset.HasMore():
line = "%s %s" % (line, rowset.Next()[0])
row=rowset.Next()[0]
self.result.append(row)
line = "%s %s" % (line, row)
else:
break

level = (len(tmp) - len(line) +4) / 6
level = int((len(row1) - len(line) +4) / 6)

if last:
if level:
if line[:4] == "-> ":
if line.startswith("-> "):
line=line[4:]
else:
last.condition=line
Expand Down Expand Up @@ -341,6 +343,7 @@ def SetData(self, rowset):
h=(self.rootShape.totalShapes * yoffs + y0*2 + PIXPERUNIT - 1) / PIXPERUNIT

self.SetScrollbars(PIXPERUNIT, PIXPERUNIT, w, h)
self.SendSizeEvent()


def OnMouseMove(self, evt):
Expand Down

0 comments on commit e47bd74

Please sign in to comment.