how do I reference the value of a text control

Michael Barron barronmo at gmail.com
Wed Nov 14 12:41:05 PST 2007


Sorry about such basic question but I've been reading/searching for
the answer since lunch and haven't found anything I understand.  I'm
trying to lookup up a name in a database.  Here is the code so far:

class screen1(wx.Panel):
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id)

        # A button
        self.button =wx.Button(self, 10, "Search", wx.Point(200, 200))
        wx.EVT_BUTTON(self, 10, self.OnClick)
        # the edit control - one line version.
        self.lblname = wx.StaticText(self, -1, "Enter the first
letters of the last name:",wx.Point(40,60))
        self.editname = wx.TextCtrl(self, 20, "", wx.Point(300, 60),
wx.Size(140,-1))


    def OnClick(self,event):
        Repository(frame, -1, namefrag=self.editname.GetValue())


def main():
     app = wx.App()
     frame = wx.Frame(None, title='EMR', pos=(350,300), size=(850,500))
     #Repository(frame, -1)
     screen1(frame, -1)
     frame.Center()
     frame.Show()
     app.MainLoop()


if __name__ == '__main__':
     main()


The error I'm getting is 'global name frame not defined'.  Obviously I
thought I had defined it in main().  Also, I'm not sure how to
reference the value in a control.  Is 'self.editname.GetValue()'
correct?

Thanks in advance.

Mike




More information about the wxpython-users mailing list