hi,
From: wxpython-users@googlegroups.com [mailto:wxpython-
users@googlegroups.com] On Behalf Of picon
Sent: Thursday, October 07, 2010 5:38 AM
To: wxPython-users
Subject: [wxPython-users] GetValue from TextCtrl by hitting a button
All i want to do is get the TextCtrl data when i hit the Co button.
I dont know why this doesnt work. I think i am missing something.
So i need some help
import wx
class Loud(wx.Frame):
def __init__(self,parent,id,title):
wx.Frame.__init__(self,parent,id,title,size=(300,200))
txtu = wx.TextCtrl(self, -1 )
btnco = wx.Button(self, -1,"Co",pos=(0,30))
self.Bind(wx.EVT_BUTTON, self.OnCo(txtu.GetValue()), id =
btnco.GetId())
def OnCo(self,event,txt):
print txt
app = wx.App()
frame = Loud(None,-1,"Loud")
frame.Show()
app.MainLoop()
--
To unsubscribe, send email to wxPython-
users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en
[alm>]
Minimum changes to make it go:
import wx
class Loud(wx.Frame):
def __init__(self,parent,id,title):
wx.Frame.__init__(self,parent,id,title,size=(300,200))
self.txtu = wx.TextCtrl(self, -1 )
btnco = wx.Button(self, -1,"Co",pos=(0,30))
self.Bind(wx.EVT_BUTTON, self.OnCo, id = btnco.GetId() )
def OnCo(self,event):
txt = self.txtu.GetValue()
print txt
app = wx.App()
frame = Loud(None,-1,"Loud")
frame.Show()
app.MainLoop()
···
-----Original Message-----