No worries! We will get to it! Most likely it will be you! I will
continue to test.
Listen, I have a close friend I convinced into using Dabo about five
years ago (maybe longer - can't really remember). Without the work
being done on Dabo3 he would have been forced to buy a $100,000.00 +
package from some other guy. And that might have closed his shop - he
doesn't have the money. Mind you he has been very happy with the Dabo
program that he is using today and he certainly has got his money out of
the program. The programmer he used has moved on (actually I think the
programmer ended up in jail for drugs). So, when I told him that Dabo3
was real he almost jumped out of the phone. So the fact that in general
Dabo3 is working is fantastic!
My old code below converts a bool from the database to a string and
changes the background color (but like I said it does not get called):
class AttenRedGreenBoolRenderer(wx.grid.GridCellRenderer):
def Draw(self, grid, attr, dc, rect, row, col, isSelected):
futuredate = False
resched = grid.DataSet[row]['resched']
miss_resched = False
myval = grid.cell(row,col).Value #grid.GetCellValue(row, col)
if resched:
test_date = datetime.date(1900, 1, 1) if
(grid.DataSet[row]['resched_date'] is None) else
grid.DataSet[row]['resched_date']
if grid.DataSet[row]['course_date'] < test_date:
text = u'miss-resched'
miss_resched = True
else:
text = u'Re-sched'
#elif grid.GetCellValue(row,2) is None or "None" in
grid.GetCellValue(row,2):
elif grid.cell(row,2).Value is None or "None" in
grid.cell(row,2).Value:
text = u'Auto Sched'
futuredate= True
else:
#not a good thing to use a hard coded value:
#futuredate = datetime.date.today() <=
dabo.lib.dates.getDateFromString(grid.GetCellValue(row,2))
#below should be faster
futuredate = datetime.date.today() <=
grid.DataSet[row]['course_date']
if myval:
text = u'Present'
else:
if futuredate :
text = u'Scheduled'
else:
if grid.DataSet[row]['attentaken']:
text = u'Missed'
else:
text = u'TBD'
hAlign, vAlign = attr.GetAlignment()
dc.SetFont( attr.GetFont() )
if miss_resched:
bg = "red"
fg = 'white'
elif not myval and not futuredate and not resched:
bg = "red"
fg = 'white'
else:
bg = 'green'
fg = 'black'
if resched and not miss_resched:
bg = 'yellow'
fg = 'black'
dc.SetTextBackground(bg)
dc.SetTextForeground(fg)
dc.SetBrush(wx.Brush(bg, wx.SOLID))
dc.SetPen(wx.TRANSPARENT_PEN)
dc.DrawRectangleRect(rect)
grid.DrawTextRectangle(dc, text, rect, hAlign, vAlign)
def Clone(self):
return AttenRedGreenBoolRenderer()
Johnf
On 7/10/19 3:49 PM, Ed Leafe wrote:
On Jul 10, 2019, at 11:12 AM, johnf <[email protected]> wrote:
I reviewed what was done in dGrid but that was a CustomEditorClass (also used a
method makeGridEditor). So is the thinking that a CustomRendererClass is not
needed. wxPython provides several types of renderers.
The CustomRendererClass *is* called, but it doesn't seem to be working
correctly. Note that if you set the CustomRendererClass for a column, it tends
to just show as blank, which means that it is having an effect, but not the one
we want.
In general, the low-level drawing with DCs in wxPython 4 seems to be very
different. Many of the the features of Dabo that rely on it give erratic
results. I wish I had time to dive into it deeper, but...
-- Ed Leafe
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: https://leafe.com/archives
This message:
https://leafe.com/archives/byMID/[email protected]