[Tutor] Get user input in wxpython

_ Dan _ danf_1979 at yahoo.es
Sat Aug 6 10:40:21 CEST 2005


Hi:
I'm new to python and wxpython, and I'm trying to make
a program to send mail. I'm using what follows:
class MyFrame1(wx.Frame):
    def __init__(self, *args, **kwds):
    ...
    self.message = wx.TextCtrl(self.panel_1, -1, "")
    self.button_1 = wx.Button(self.panel_1, -1, "SEND
Mail")
    ...
    # And then:
    wx.EVT_BUTTON(self,self.button_1.GetId(),
self.Mail)

    # The Mail method is:
    def Mail(self,event):
       self.from = "dquepal at hotmail.com"
       self.host = "localhost"
       self.to = "danf_1979 at yahoo.es"

       self.body = self.message

       server = smtplib.SMTP(self.host)
       server.sendmail(self.from, [self.to],
self.body)
       server.quit()

But when pressing the Send Mail button I only get:
TypeError: len() of unsized object

Anybody knows what I'm doing wrong? Maybe I'm not
getting the user input, or just dont know how to use
that input in the Mail method...

Because if I use:
def Mail(self,event):
   self.from = "dquepal at hotmail.com"
   self.host = "localhost"
   self.to = "danf_1979 at yahoo.es"

   self.body = "any message" #as string everything
works fine.

   server = smtplib.SMTP(self.host)
   server.sendmail(self.from, [self.to], self.body)
   server.quit()

Thanks in advanced.
Daniel Queirolo.




		
______________________________________________ 
Renovamos el Correo Yahoo! 
Nuevos servicios, más seguridad 
http://correo.yahoo.es


More information about the Tutor mailing list