Here's your own code rewritten so that it shows something:
----------------------------------------------------------------------
import wx
import wx.grid
class App(wx.App):
def __init__( self ):
self.frame = None
wx.App.__init__( self, 0 )
def OnInit(self):
self.frame = Frame()
self.frame.Show( wx.true )
self.SetTopWindow( self.frame )
return wx.true
class Frame(wx.Frame):
def __init__( self ):
wx.Frame.__init__(self, wx.NULL, -1, 'Grid Test',
wx.DefaultPosition,
wx.DefaultSize,
wx.DEFAULT_FRAME_STYLE )
self.grid_panel = wx.Panel(self, -1)
self.grid_id = wx.NewId()
g = self.grid_ctrl = wx.grid.Grid( self.grid_panel, self.grid_id,
wx.DefaultPosition,
wx.Size( 400, 300 ),
wx.LC_REPORT|wx.NO_BORDER )
g.CreateGrid( 2, 3 )
g.SetSelectionMode( 1 )
g.SetColLabelAlignment( wx.ALIGN_LEFT, wx.ALIGN_BOTTOM )
g.SetColLabelSize( 20 )
g.SetRowLabelSize( 0 )
g.SetColLabelValue( 0, 'Name' )
g.SetColLabelValue( 1, 'State' )
g.SetColLabelValue( 2, 'Type' )
g.SetCellValue( 0, 0, 'name 0' )
g.SetCellValue( 1, 0, 'name 1' )
g.SetCellValue( 0, 1, 'state 0' )
g.SetCellValue( 1, 1, 'state 1' )
g.SetCellValue( 0, 2, 'type 0' )
g.SetCellValue( 1, 2, 'type 1' )
g.SetReadOnly( 0, 0, wx.false )
g.SetReadOnly( 1, 0, wx.false )
g.SetReadOnly( 0, 1, wx.false )
g.SetReadOnly( 1, 1, wx.false )
g.SetReadOnly( 0, 2, wx.false )
g.SetReadOnly( 1, 2, wx.false )
wx.grid.EVT_GRID_CELL_RIGHT_CLICK( g, self.OnGridCellRightClick )
def OnGridCellRightClick( self, event ):
""" Added the print statement for the event and
the event.Method statements."""
print 'Events:', dir(event)
print 'OnGridCellRightClick --------------------'
print 'Cells:',self.grid_ctrl.GetSelectedCells(), event.GetSelection()
print 'Rows:',self.grid_ctrl.GetSelectedRows(), event.GetRow()
print 'Cols:',self.grid_ctrl.GetSelectedCols(), event.GetCol()
def main():
app = App()
app.frame.Show( 1 )
app.MainLoop()
if __name__ == '__main__':
main()
----------------------------------------------------------------------
The output should look like this:
----------------------------------------------------------------------
Events: ['Allow', 'AltDown', 'Checked', 'Clone', 'ControlDown', 'Destroy', 'GetClassName', 'GetClientData', 'GetCol', 'GetEventObject', 'GetEventType', 'GetExtraLong', 'GetId', 'GetInt', 'GetPosition', 'GetRow', 'GetSelection', 'GetSkipped', 'GetString', 'GetTimestamp', 'IsAllowed', 'IsChecked', 'IsSelection', 'MetaDown', 'Selecting', 'SetEventObject', 'SetEventType', 'SetExtraLong', 'SetId', 'SetInt', 'SetString', 'SetTimestamp', 'ShiftDown', 'Skip', 'Veto', '__del__', '__doc__', '__init__', '__module__', '__repr__', 'this', 'thisown']
OnGridCellRightClick --------------------
Cells: 0
Rows: 1
Cols: 0
----------------------------------------------------------------------
I hope I understood you correctly.
--
Godoy. <godoy@metalab.unc.edu>
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org