Updating an array of wxTextCtrls in a ScrolledPanel

Hi!

I'm Trying to update a scrolling panel from values I get from a file.
It looks like this:

···

==================================================
  Class [101] Title [Intro to Python] Teacher [Robin Dunn]

    Name Number Cell Phone Grade
-----------------------------------------------------------------------------------
^
  [John Doe ][ 121235] [111-333-4444] [A+] |_|
  [Jane Doe ][ 678891] [222-333-5555] [A- ] |_|
       : : : :

>

-----------------------------------------------------------------------------------
v

I started with:

class TestPanel(scrolled.ScrolledPanel)
          ... __init__ ...
self.LoadAll() # array fills with 30 values ie. n=30 Class="101",
Titile = "Intro to Python" Teacher="Robin Dunn"

panel = scrolled panel ...
class = wx.TextCtrl(... , Class,...) #First record contains this
data
title = wx.TextCtrl(... , Title,...)
teacher = wx.TextCtrl(... , Teacher,...)
  :
global Name, Number, CellPhone, Grade # These are used
in other parts of the app
global name, number, cellPhone, grade # These are
called in other classes
Name = ; Number = ; CellPhone = ; Grade= # These arrays are
loaded with the actual data
name = ; number = ; cellPhone = ; grade= # These arrays
are loaded with nulls to keep in sync w/ data.
  :
fgs1 = wx.FlexGridSizer(cols=4, vgap=4, hgap=4)
:
for i in range(len(name)) #Loop
thru array cells to load fields
      name[i] = wx.TextCtrl( panel, .. ,Name[i], ...)
      number[i] = wx.TextCtrl( panel, .. ,Number[i], ...)
      cellPhone[i] = wx.TextCtrl( panel, .. ,cellPhone[i], ...)
      grade[i] = wx.TextCtrl( panel, ... , Grade
[i],...,style=wx.TE_READONLY)

<< sizing >>
self.Refresh()

def LoadAll(self) #Called from Frame and Panel
     ...
def UpdateAll(self) #Called from Frame

      class .SetValue(Class)
      title.SetValue(Title)
      teacher.SetValue(Teacher)

      for i in range(len(name))
           name[i].SetValue(Name[i])
           number[i].SetValue(Number[i])
           cellPhone[i].SetValue(cellPhone[i])
           grade[i].SetValue(Grade[i])

When I run the app the first time it loads all the fields as expected.
But when I load another course file (ie. diffferent students) by an
event ( onOpen calls LoadAll() and then UpdateAll() ) Only the class,
title and teacher are updated and I always get an error on "name[i]"
saying it is not an attribute or something else. Can anyone see what I
am doing wrong. I tried dropping the globals and adding "self." in
front of all variables but I still get similar errors. Am I going to
have to use "GetChildren"?

RLRandallx

Sorry. Between your editing out unimportant things and the word wrapping and etc. being done my the mail system your code is almost unreadable. Please make a small, runnable sample that shows the problem you are having, and *attach* it to a mail message. Please read MakingSampleApps - wxPyWiki

···

On 1/16/10 1:09 PM, RLRandallx wrote:

Hi!

I'm Trying to update a scrolling panel from values I get from a file.
It looks like this:

==================================================
   Class [101] Title [Intro to Python] Teacher [Robin Dunn]

     Name Number Cell Phone Grade
-----------------------------------------------------------------------------------
^
   [John Doe ][ 121235] [111-333-4444] [A+] |_|
   [Jane Doe ][ 678891] [222-333-5555] [A- ] |_|
        : : : :
> >
-----------------------------------------------------------------------------------
v

I started with:

==========================================================================
When I run the app the first time it loads all the fields as expected.
But when I load another course file (ie. diffferent students) by an
event ( onOpen calls LoadAll() and then UpdateAll() ) Only the class,
title and teacher are updated and I always get an error on "name[i]"
saying it is not an attribute or something else. Can anyone see what I
am doing wrong. I tried dropping the globals and adding "self." in
front of all variables but I still get similar errors. Am I going to
have to use "GetChildren"?

--
Robin Dunn
Software Craftsman