Re: [Tutor] How to reference a wx.grid.Grid outside the method inwhich it was created?
<[EMAIL PROTECTED]> wrote 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) As a general rule when posting to the list include the full error trace not just a summary. The tracelback often has useful info. In this case it wasn't needed however. :-) Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to reference a wx.grid.Grid outside the method inwhich it was created?
It worked like a charm! Thank you so much!! Lauren > 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
Re: [Tutor] How to reference a wx.grid.Grid outside the method inwhich it was created?
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