ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> wxpython-users
wxpython-users
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved