reportWindow.py:
import wx
import wx.grid as gridlib
class SimpleGrid(gridlib.Grid):
def __init__(self, parent, log):
gridlib.Grid.__init__(self, parent, -1)
self.wxFont = "9, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL"
self.CreateGrid(3, 3)#, gridlib.Grid.SelectRows)
fontBold = wx.Font(9, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.BOLD)
self.Bind(gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.OnCellLeftDClick)
self.SetReadOnly(1, 1, True)
self.log = log
# test all the events
self.Bind(gridlib.EVT_GRID_CELL_LEFT_CLICK, self.OnCellLeftClick)
self.Bind(gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.OnCellLeftDClick)
self.Bind(gridlib.EVT_GRID_SELECT_CELL, self.OnSelectCell)
######## Get Left click value ##################
def OnCellLeftClick(self, evt):
self.log.write("OnCellLeftClick: (%d,%d,%s) %s\n" %
(evt.GetRow(), evt.GetCol(), self.GetCellValue(evt.GetRow(), evt.GetCol()), evt.GetPosition()) )
evt.Skip()
######## Get Left double click value ##################
def OnCellLeftDClick(self, evt):
print(self.GetCellValue(evt.GetRow(), 1))
print(self.GetCellValue(evt.GetRow(), 18))
font = wx.Font(self.wxFont)
evt.Skip()
def OnCellLeftDClick(self, evt):
print(self.GetCellValue(1, 1))
font = wx.Font(self.wxFont)
from publishers import TestFrame
frame = TestFrame(self, sys.stdout)
frame.Show()
#Select complete row
def OnSelectCell(self, evt):
self.log.write("OnSelectCell: (%d,%d) %s\n" %
(evt.GetRow(), evt.GetCol(), evt.GetPosition()))
self.SelectRow(evt.GetRow())
evt.Skip()
class TestFrame(wx.Frame):
def __init__(self, parent, log):
wx.Frame.__init__(self, parent, 0, "Report By Campaigns", size=(400,400))
self.grid = SimpleGrid(self, log)
#[...Some code...]
if __name__ == '__main__':
import sys
from wx.lib.mixins.inspection import InspectableApp
app = InspectableApp(False)
frame = TestFrame(None, sys.stdout)
frame.Show(True)
#import wx.lib.inspection
#wx.lib.inspection.InspectionTool().Show()
app.MainLoop()
publishers.py:
import wx
import wx.grid as gridlib
class SimpleGrid(gridlib.Grid):
def __init__(self, parent, log):
gridlib.Grid.__init__(self, parent, -1)
self.wxFont = "9, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL"
self.CreateGrid(7, 8)#, gridlib.Grid.SelectRows)
fontBold = wx.Font(9, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.BOLD)
self.Bind(gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.OnCellLeftDClick)
self.SetReadOnly(1, 1, True)
self.log = log
# test all the events
self.Bind(gridlib.EVT_GRID_CELL_LEFT_CLICK, self.OnCellLeftClick)
self.Bind(gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.OnCellLeftDClick)
self.Bind(gridlib.EVT_GRID_SELECT_CELL, self.OnSelectCell)
######## Get Left click value ##################
def OnCellLeftClick(self, evt):
self.log.write("OnCellLeftClick: (%d,%d,%s) %s\n" %
(evt.GetRow(), evt.GetCol(), self.GetCellValue(evt.GetRow(), evt.GetCol()), evt.GetPosition()) )
evt.Skip()
######## Get Left double click value ##################
def OnCellLeftDClick(self, evt):
print(self.GetCellValue(evt.GetRow(), 1))
print(self.GetCellValue(evt.GetRow(), 18))
font = wx.Font(self.wxFont)
#Select complete row
def OnSelectCell(self, evt):
self.log.write("OnSelectCell: (%d,%d) %s\n" %
(evt.GetRow(), evt.GetCol(), evt.GetPosition()))
self.SelectRow(evt.GetRow())
#evt.Skip()
class TestFrame(wx.Frame):
def __init__(self, parent, log):
wx.Frame.__init__(self, parent, 0, "Publishers", size=(400,400))
self.grid = SimpleGrid(self, log)
#[...Some code...]
if __name__ == '__main__':
import sys
from wx.lib.mixins.inspection import InspectableApp
app = InspectableApp(False)
frame = TestFrame(None, sys.stdout)
frame.Show(True)
#import wx.lib.inspection
#wx.lib.inspection.InspectionTool().Show()
app.MainLoop()