Hey All,
I have some code here, the problem is in line 82-83:
import smtplib
import wx
window=wx.App()
class pymailer(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,-1,"Py-mailer",size=(500,700))
try:
self.s=smtplib.SMTP("smtp.gmail.com",587)
self.s.starttls()
except:
wx.MessageBox("Error 001: Could not connect to the internet, please try again later.","Internet Connection Error")
self.panel=wx.Panel(self,-1)
menubar=wx.MenuBar()
filem=wx.Menu()
filem.Append(201,"Quit")
self.Bind(wx.EVT_MENU,self.Quit,id=201)
viewm=wx.Menu()
viewm.Append(202,"About")
self.Bind(wx.EVT_MENU,self.About,id=202)
menubar.Append(filem,"File")
menubar.Append(viewm,"Help")
self.SetMenuBar(menubar)
wx.StaticText(self.panel,-1,"Welcome to Py-mailer.\n\nLogin with your Gmail credentials and you can send a text-only email to anyone quickly and easily.",pos=(10,10))
wx.StaticText(self.panel,-1,"Please enter your Gmail login ID: ",pos=(10,100))
wx.StaticText(self.panel,-1,"Please enter your Gmail login password:\n(will not be stored)",pos=(10,130))
self.username=wx.TextCtrl(self.panel,101,"Login ID",pos=(220,100))
self.password=wx.TextCtrl(self.panel,102,"Password",style=(wx.TE_PASSWORD),pos=(220,130))
login=wx.Button(self.panel,103,label="Login",pos=(10,170))
self.Bind(wx.EVT_BUTTON,self.Login,id=103)
wx.StaticText(self.panel,-1,"To:",pos=(10,250))
wx.StaticText(self.panel,-1,"Subject:",pos=(10,280))
wx.StaticText(self.panel,-1,"Message:",pos=(10,310))
self.to_info=wx.TextCtrl(self.panel,104,pos=(80,250),size=(240,20))
self.sub_info=wx.TextCtrl(self.panel,105,pos=(80,280),size=(240,20))
self.msg_info=wx.TextCtrl(self.panel,106,pos=(80,310),size=(240,150))
send=wx.Button(self.panel,107,"Send",pos=(245,470))
self.Bind(wx.EVT_BUTTON,self.Send,id=107)
self.Centre()
self.Show()
def Quit(self,event):
self.Close()
def About(self,event):
about=wx.AboutDialogInfo()
about.SetName("Py-Mailer")
about.SetCopyright("(c) 2009 Sravan")
about.SetWebSite("http://www.uberpix.wordpress.com")
about.AddDeveloper("Sravan")
about.AddDeveloper("Daniel Pacheco")
wx.AboutBox(about)
def Login(self,event):
self.user=self.username.GetValue()
self.passw=self.password.GetValue()
if(self.user=="" and self.passw==""):
wx.MessageBox("Error 002: You did not enter your username and/or password","Enter Login Details")
try:
self.s.login(self.user,self.passw)
wx.StaticText(self.panel,-1,"Logged in...",pos=(10,200))
except:
wx.StaticText(self.panel,-1,"Failed",pos=(10,200))
def Send(self,event):
self.to=self.to_info.GetValue()
self.subject=self.sub_info.GetValue()
self.message=self.msg_info.GetValue()
self.msg="To: "+self.to+"\nSubject: "+self.subject+"\n"+self.message
self.s.sendmail(self.user,self.to,self.msg)
self.s.quit()
wx.StaticText(self.panel,-1,"Your message has been sent!",pos=(175,500))
pymailer()
window.MainLoop()
- because once I login successfully, if I again login with wrong details, the "Failed" text doesn't overwrite the "Logged in..." text fully.... so what do I do?
Thanks a load