Re: [wxpython-users] Simple scope question
by Raffaello other posts by this author
Jul 8 2008 12:32PM messages near this date
[wxpython-users] Simple scope question
|
Re: [wxpython-users] Simple scope question
Amend the line in __init__ as follows:
self.grid = wx.grid.Grid(etc...)
and then the grid will be visible all over the class as self.grid.
Or assign a specific name to the grid in the constructor, as follows:
grid = wx.grid.Grid(etc..., name = 'The Grid')
and then get back the grid wherever you need it with the function:
self.FindWindowByName('TheGrid').
This second solution lessens the overhead on memory, so it is to be
preferred for all controls that are called only now and then, which is not
normally the case with grids :-).
2008/7/8 John Dann <infolists@[...].uk> :
> Fairly new to Python and wxP so there's probably something simple
> that I haven't grasped yet about assigning the scope of objects:
>
> Problem is as follows:
>
> I've declared a grid object in my Frame's __init__:
>
> def __init__(self)
> ....
> grid = wx.grid.Grid(etc...)
>
> I then want to assign some values to various grid cells from within a
> different function but within the same frame class, ie
>
> def otherfunction(self)
> grid.SetCellValue(r, c, value)
>
> but I keep getting errors about the grid object being unrecognised whether
> I do
>
> grid.SetCellValue
>
> or
>
> self.grid.SetCellValue
>
> Is there something obvious that I'm missing?
>
>
>
> _______________________________________________
> wxpython-users mailing list
> wxpython-users@[...].org
> http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
>
Thread:
John Dann
Raffaello
Phil Mayes
Robin Dunn
Raffaello
Robin Dunn
Timothy Grant
Josiah Carlson
Christopher Barker
Raffaello
Kyle W Rickey
|