How to retrieve multiple numbers from TextCtrl?

I have following set of TextCtrl which I edit when needed.

import wx class MyCheckBox(wx.Frame):
   def __init__(self): wx.Frame.__init__(self, None, -1, 'Values', size=(490, 450))
       panel = wx.Panel(self, -1)

       List = [(70, 55), (170, 55), (270, 55), (370, 55),
               (70, 85), (170, 85), (270, 85), (370, 85)]

       for p,v in zip(List,val):
           self.value = wx.TextCtrl(panel, -1, value=str(v), pos=pos, size=(60,25))

       self.btnOK = wx.Button(panel, label="OK", pos=(190, 355))
       self.Bind(wx.EVT_BUTTON, self.OnOK, id = self.btnOK.GetId())

   def OnOK(self, event):
       self.Show(False)

Currently, default value for all of them is '-999'. How can I retrieve them to a list at the end of process when I press OK?

In the init have a self.textctrls = then
self.textctrls.append(wx.TextCtrl… then in OnOk you can access
them.

···

On 22/12/13 06:49, Ibraheem Khan wrote:

I have following set of TextCtrl which I edit when needed.

import wx class MyCheckBox
span>(wx.Frame):
   def __init__(self): wx.Frame.__init__(self,
None, -1, 'Values', size=(490, 450))
       panel = wx.Panel(self, -1)

       List = [(70, 55), (170, 55), (270, 55), (370, 55),
               (70, 85), (170, 85), (270, 85), (370, 85)]

       for p,v in zip(List,val):
           self.value = wx.TextCtrl(panel, -1, value
span>=str(v), pos=pos, size=(60,25))

       self.btnOK = wx.Button(panel, label="OK", pos
span>=(190, 355))
       self.Bind(wx.EVT_BUTTON, self.OnOK, id = sel
f.btnOK.GetId())

   def OnOK(self, event):
       self.Show(False)


Currently, default value for all of them is '-999'. How can I retrieve them to a list at the end of process when I press OK?

  You received this message because you are subscribed to the Google

Groups “wxPython-users” group.

  To unsubscribe from this group and stop receiving emails from it,

send an email to .
For more options, visit .

wxpython-users+unsubscribe@googlegroups.com
https://groups.google.com/groups/opt_out

thanks for reply. I don’t have much experience with wxPython and that is why your answer isn’t clear to me. Please help me understand.

···

On Sunday, December 22, 2013 1:49:52 AM UTC-5, Ibraheem Khan wrote:

I have following set of TextCtrl which I edit when needed.

import wx class MyCheckBox(wx.Frame):
   def __init__(self): wx.Frame.__init__(self, None, -1, 'Values', size=(490, 450))
       panel = wx.Panel(self, -1)

       List = [(70, 55), (170, 55), (270, 55), (370, 55),
               (70, 85), (170, 85), (270, 85), (370, 85)]

       for p,v in zip(List,val):
           self.value = wx.TextCtrl(panel, -1, value=str(v), pos=pos, size=(60,25))

       self.btnOK = wx.Button(panel, label="OK", pos=(190, 355))
       self.Bind(wx.EVT_BUTTON, self.OnOK, id = self.btnOK.GetId())

   def OnOK(self, event):
       self.Show(False)


Currently, default value for all of them is '-999'. How can I retrieve them to a list at the end of process when I press OK?

I’ve added those changes to your code, but note you have not used p and val & pos have not been defined

import wx

class MyCheckBox(wx.Frame):
def init(self):
wx.Frame.init(self, None, -1, ‘Values’, size=(490, 450))
panel = wx.Panel(self, -1)

    List = [(70, 55), (170, 55), (270, 55), (370, 55),
            (70, 85), (170, 85), (270, 85), (370, 85)]

    self.textctrls = []

    for p, v in zip(List, val):
        self.textctrls.append(wx.TextCtrl(panel, -1, value=str(v), pos=pos,
                                          size=(60, 25)))

    self.btnOK = wx.Button(panel, label="OK", pos=(190, 355))
    self.btnOK.Bind(wx.EVT_BUTTON, self.OnOK)

def OnOK(self, event):
    self.Show(False)
    for ctrl in self.textctrls:
        print ctrl.GetValue()
···

On Sunday, December 22, 2013 7:54:35 AM UTC, Ibraheem Khan wrote:

thanks for reply. I don’t have much experience with wxPython and that is why your answer isn’t clear to me. Please help me understand.

On Sunday, December 22, 2013 1:49:52 AM UTC-5, Ibraheem Khan wrote:

I have following set of TextCtrl which I edit when needed.

import wx class MyCheckBox(wx.Frame):
   def __init__(self): wx.Frame.__init__(self, None, -1, 'Values', size=(490, 450))
       panel = wx.Panel(self, -1)

       List = [(70, 55), (170, 55), (270, 55), (370, 55),
               (70, 85), (170, 85), (270, 85), (370, 85)]

       for p,v in zip(List,val):
           self.value = wx.TextCtrl(panel, -1, value=str(v), pos=pos, size=(60,25))

       self.btnOK = wx.Button(panel, label="OK", pos=(190, 355))
       self.Bind(wx.EVT_BUTTON, self.OnOK, id = self.btnOK.GetId())

   def OnOK(self, event):
       self.Show(False)


Currently, default value for all of them is '-999'. How can I retrieve them to a list at the end of process when I press OK?

@Yoriz: Thanks for reply. I have it working and solution is here:
http://stackoverflow.com/questions/20726759/how-to-retrieve-multiple-numbers-from-textctrl/20728574?noredirect=1#20728574

···

On Sunday, December 22, 2013 1:49:52 AM UTC-5, Ibraheem Khan wrote:

I have following set of TextCtrl which I edit when needed.

import wx class MyCheckBox(wx.Frame):
   def __init__(self): wx.Frame.__init__(self, None, -1, 'Values', size=(490, 450))
       panel = wx.Panel(self, -1)

       List = [(70, 55), (170, 55), (270, 55), (370, 55),
               (70, 85), (170, 85), (270, 85), (370, 85)]

       for p,v in zip(List,val):
           self.value = wx.TextCtrl(panel, -1, value=str(v), pos=pos, size=(60,25))

       self.btnOK = wx.Button(panel, label="OK", pos=(190, 355))
       self.Bind(wx.EVT_BUTTON, self.OnOK, id = self.btnOK.GetId())

   def OnOK(self, event):
       self.Show(False)


Currently, default value for all of them is '-999'. How can I retrieve them to a list at the end of process when I press OK?

Ibraheem Khan wrote:

thanks for reply. I don't have much experience with wxPython and that
is why your answer isn't clear to me. Please help me understand.

You have stored all of your text controls in the class variable
"value". So, in your OnOK handler, you can run through that list:
        for ctrl in self.value:
            print ctrl.GetValue()

The question becomes, what do you want to DO with these values? Do you
need to write them to a file? Save them in the registry?

Note that there are other issues here. The default value for your
controls is NOT "-999". You are loading values into each of your text
controls from your list called "List". Also, you are placing all of
your controls at the exact same position, right on top of each other.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.