On Mon, Aug 11, 2008 at 12:26 PM,  <[EMAIL PROTECTED]> wrote:
> I have created a wx.grid.Grid attached to a panel which is attached to a
> frame within one method (Method #1). Inside this method I also created a
> combobox.
>
> When an item is selected in the combobox another method is called (i.e.
> When the event is called the method is run…)
> Inside this method I want to fill the grid created in Method #1 with data
> generated/calculated from within Method #2 based on which item was
> selected from the combobox.
>
> How do I reference the grid from method #1 when I am in method #2?
>
> Currently I am receving this error message:
> "NameError: global name 'myGrid' is not defined."
>
> It's an error against this statement in method #2:
> myGrid.SetCellValue(i, 0, myValue)

If method1 and method2 are both methods of the same class, just save
myGrid as an attribute of the class rather than having it as a local
variable in method1. I.e.

def method1(self):
  self.myGrid = ...

def method2(self):
  self.myGrid.SetCellValue(...)

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to