wxPython text overwrite problem...

Thread Solved

Join Date: May 2009
Posts: 231
Reputation: sravan953 has a little shameless behaviour in the past 
Solved Threads: 28
sravan953's Avatar
sravan953 sravan953 is online now Online
Posting Whiz in Training

wxPython text overwrite problem...

 
0
  #1
31 Days Ago
Hey All,

I have some code here, the problem is in line 82-83:
  1. import smtplib
  2. import wx
  3.  
  4. window=wx.App()
  5.  
  6. class pymailer(wx.Frame):
  7.  
  8. def __init__(self):
  9. wx.Frame.__init__(self,None,-1,"Py-mailer",size=(500,700))
  10.  
  11. try:
  12. self.s=smtplib.SMTP("smtp.gmail.com",587)
  13. self.s.starttls()
  14. except:
  15. wx.MessageBox("Error 001: Could not connect to the internet, please try again later.","Internet Connection Error")
  16.  
  17. self.panel=wx.Panel(self,-1)
  18.  
  19. menubar=wx.MenuBar()
  20.  
  21. filem=wx.Menu()
  22. filem.Append(201,"Quit")
  23. self.Bind(wx.EVT_MENU,self.Quit,id=201)
  24.  
  25. viewm=wx.Menu()
  26. viewm.Append(202,"About")
  27. self.Bind(wx.EVT_MENU,self.About,id=202)
  28.  
  29. menubar.Append(filem,"File")
  30. menubar.Append(viewm,"Help")
  31.  
  32. self.SetMenuBar(menubar)
  33.  
  34. 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))
  35. wx.StaticText(self.panel,-1,"Please enter your Gmail login ID: ",pos=(10,100))
  36. wx.StaticText(self.panel,-1,"Please enter your Gmail login password:\n(will not be stored)",pos=(10,130))
  37.  
  38. self.username=wx.TextCtrl(self.panel,101,"Login ID",pos=(220,100))
  39. self.password=wx.TextCtrl(self.panel,102,"Password",style=(wx.TE_PASSWORD),pos=(220,130))
  40.  
  41. login=wx.Button(self.panel,103,label="Login",pos=(10,170))
  42. self.Bind(wx.EVT_BUTTON,self.Login,id=103)
  43.  
  44. wx.StaticText(self.panel,-1,"To:",pos=(10,250))
  45. wx.StaticText(self.panel,-1,"Subject:",pos=(10,280))
  46. wx.StaticText(self.panel,-1,"Message:",pos=(10,310))
  47.  
  48. self.to_info=wx.TextCtrl(self.panel,104,pos=(80,250),size=(240,20))
  49. self.sub_info=wx.TextCtrl(self.panel,105,pos=(80,280),size=(240,20))
  50. self.msg_info=wx.TextCtrl(self.panel,106,pos=(80,310),size=(240,150))
  51.  
  52. send=wx.Button(self.panel,107,"Send",pos=(245,470))
  53. self.Bind(wx.EVT_BUTTON,self.Send,id=107)
  54.  
  55. self.Centre()
  56. self.Show()
  57.  
  58. def Quit(self,event):
  59. self.Close()
  60.  
  61. def About(self,event):
  62. about=wx.AboutDialogInfo()
  63.  
  64. about.SetName("Py-Mailer")
  65. about.SetCopyright("(c) 2009 Sravan")
  66. about.SetWebSite("http://www.uberpix.wordpress.com")
  67. about.AddDeveloper("Sravan")
  68. about.AddDeveloper("Daniel Pacheco")
  69.  
  70. wx.AboutBox(about)
  71.  
  72. def Login(self,event):
  73.  
  74. self.user=self.username.GetValue()
  75. self.passw=self.password.GetValue()
  76.  
  77. if(self.user=="" and self.passw==""):
  78. wx.MessageBox("Error 002: You did not enter your username and/or password","Enter Login Details")
  79.  
  80. try:
  81. self.s.login(self.user,self.passw)
  82. wx.StaticText(self.panel,-1,"Logged in...",pos=(10,200))
  83. except:
  84. wx.StaticText(self.panel,-1,"Failed",pos=(10,200))
  85.  
  86.  
  87. def Send(self,event):
  88. self.to=self.to_info.GetValue()
  89. self.subject=self.sub_info.GetValue()
  90. self.message=self.msg_info.GetValue()
  91. self.msg="To: "+self.to+"\nSubject: "+self.subject+"\n"+self.message
  92. self.s.sendmail(self.user,self.to,self.msg)
  93. self.s.quit()
  94.  
  95. wx.StaticText(self.panel,-1,"Your message has been sent!",pos=(175,500))
  96.  
  97. pymailer()
  98. 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
Last edited by sravan953; 31 Days Ago at 1:15 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,046
Reputation: jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough 
Solved Threads: 263
Sponsor
jlm699's Avatar
jlm699 jlm699 is offline Offline
Knows where his Towel is
 
0
  #2
31 Days Ago
How about instead of just generating an arbitrary StaticText object, assign it to a persistent member of your class (let's call it self.login_status_text ). Then instead of generating it each time, simply update the contents to the proper string (It's been years since messing with wxPython but if I remember correctly you might want to use SetLabel in this case).
1. Use Code Tags.
2. Homework? Show Effort.
3. Keep discussions on the forum: no PMs
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 148
Reputation: snippsat is an unknown quantity at this point 
Solved Threads: 46
snippsat snippsat is offline Offline
Junior Poster
 
0
  #3
31 Days Ago
You can set size so the text get overwrite.
And som color look better.
  1. try:
  2. self.s.login(self.user,self.passw)
  3. wx.StaticText(self.panel,-1,"Logged in...",pos=(10,200),size = (150,20)).SetForegroundColour('blue')
  4. except:
  5. wx.StaticText(self.panel,-1,"Failed",pos=(10,200),size = (150,20)).SetForegroundColour('red')

For me i have to have this put in this lines or it dont work for me.
  1. self.s.ehlo()
  2. self.s.starttls()
  3. self.s.ehlo()
And your design need some work,can give som tips later if you want that.
Last edited by snippsat; 31 Days Ago at 3:08 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 231
Reputation: sravan953 has a little shameless behaviour in the past 
Solved Threads: 28
sravan953's Avatar
sravan953 sravan953 is online now Online
Posting Whiz in Training
 
0
  #4
31 Days Ago
Originally Posted by snippsat View Post
You can set size so the text get overwrite.
And som color look better.
  1. try:
  2. self.s.login(self.user,self.passw)
  3. wx.StaticText(self.panel,-1,"Logged in...",pos=(10,200),size = (150,20)).SetForegroundColour('blue')
  4. except:
  5. wx.StaticText(self.panel,-1,"Failed",pos=(10,200),size = (150,20)).SetForegroundColour('red')

For me i have to have this put in this lines or it dont work for me.
  1. self.s.ehlo()
  2. self.s.starttls()
  3. self.s.ehlo()
And your design need some work,can give som tips later if you want that.
I would be glad to get some tips from you!
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 231
Reputation: sravan953 has a little shameless behaviour in the past 
Solved Threads: 28
sravan953's Avatar
sravan953 sravan953 is online now Online
Posting Whiz in Training
 
0
  #5
31 Days Ago
Originally Posted by jlm699 View Post
How about instead of just generating an arbitrary StaticText object, assign it to a persistent member of your class (let's call it self.login_status_text ). Then instead of generating it each time, simply update the contents to the proper string (It's been years since messing with wxPython but if I remember correctly you might want to use SetLabel in this case).
I changed lines 81-85 to this:
  1. try:
  2. self.s.login(self.user,self.passw)
  3. self.loginmsg.SetLabel("Logged in...")
  4. except:
  5. self.loginmsg.SetLabel("Failed to login, please try again...")

But it still doesn't overwrite properly... guess I will just have to settle on snippsat's opinion...
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 148
Reputation: snippsat is an unknown quantity at this point 
Solved Threads: 46
snippsat snippsat is offline Offline
Junior Poster
 
0
  #6
30 Days Ago
Hi here are som changes.
Done some work on this,i was thinking making somthing simelar as this for fun.
So helping you a little is no problem,set my self as co-developer in about box if you dont mind.

Here are changes.

----------| Change log |---------

* Change on size and design | New headerpicture

* Take away maximize window (wx.MINIMIZE_BOX)

* Ico for Frame and about box

* New about box style

* Picture buttons

* Bigger message Box and multiline enable(wx.TE_MULTILINE)

* Exception handling on mail sent with new StaticText message

* Better documentation of code

----------| idèe for future development |--------

* Email attachment(file)

* Contact list load

* Save default login

http://www.esnips.com/doc/c2e05e06-5...05ed/py-mailer

  1. import smtplib
  2. import time
  3. import os
  4. import wx
  5. from wx.lib.wordwrap import wordwrap
  6.  
  7. window = wx.App()
  8. class pymailer(wx.Frame):
  9. '''
  10. Program to send gmail message
  11. '''
  12. def __init__(self):
  13. wx.Frame.__init__(self, None, wx.ID_ANY,"Py-mailer",size=(330,520),
  14. style = wx.DEFAULT_DIALOG_STYLE | wx.MINIMIZE_BOX)
  15. #----| Window color |---#
  16. self.SetBackgroundColour("#d8d8bf")
  17.  
  18. #---| Add a panel so it looks the correct on all platforms |---#
  19. self.panel = wx.Panel(self, wx.ID_ANY)
  20.  
  21. #---| Ico for window |---#
  22. ico = wx.Icon('email1.ico', wx.BITMAP_TYPE_ICO)
  23. self.SetIcon(ico)
  24.  
  25. #----| Gmail server |---#
  26. self.info = {}
  27. self.s = smtplib.SMTP("smtp.gmail.com",587)
  28. self.s.ehlo()
  29. self.s.starttls()
  30. self.s.ehlo()
  31.  
  32. #---| Menu bar |---#
  33. menubar=wx.MenuBar()
  34. filem=wx.Menu()
  35. filem.Append(201,"Quit")
  36. self.Bind(wx.EVT_MENU,self.Quit,id=201)
  37. viewm = wx.Menu()
  38. viewm.Append(202,"About")
  39. self.Bind(wx.EVT_MENU,self.About,id=202)
  40. menubar.Append(filem,"File")
  41. menubar.Append(viewm,"Help")
  42. self.SetMenuBar(menubar)
  43.  
  44. #---| Picture Buttons |---#
  45. self.send = wx.BitmapButton(self.panel,107,wx.Bitmap("py_email1.png"),
  46. pos = (7,430), size = (65,26))
  47. self.Bind(wx.EVT_BUTTON,self.Send,id = 107)
  48. self.login = wx.BitmapButton(self.panel,103,wx.Bitmap("py_email2.png"),
  49. pos = (7,123), size = (65,26))
  50. self.Bind(wx.EVT_BUTTON,self.Login,id = 103)
  51.  
  52. #---| Standar Buttons |---#
  53. #login = wx.Button(self.panel,103,label = "Login", pos = (10,120))
  54. #self.Bind(wx.EVT_BUTTON,self.Login,id = 103)
  55. #send = wx.Button(self.panel, 107, "Send", pos = (50,400))
  56. #self.Bind(wx.EVT_BUTTON, self.Send,id = 107)
  57.  
  58. #---| Picture |---#
  59. self.bitmap_1 = wx.StaticBitmap(self, -1, wx.Bitmap("py1.png",
  60. wx.BITMAP_TYPE_ANY),pos = (43,5 ), size = (250,42))
  61.  
  62. #---| Label Text |---#
  63. wx.StaticText(self, -1, '---------------------------------------------------------------------------',
  64. pos = (10,107), size = (400,13 )).SetForegroundColour('blue')
  65. wx.StaticText(self, -1, '---------------------------------------------------------------------------',
  66. pos = (10,35), size = (400,13 )).SetForegroundColour('blue')
  67. wx.StaticText(self, -1, '---------------------------------------------------------------------------',
  68. pos = (10,150), size = (400,13 )).SetForegroundColour('blue')
  69. #wx.StaticText(self.panel,-1,"Welcome to Py-mailer.\nLogin with your Gmail credentials and you can send a text-only email to anyone quickly and easily.",pos=(10,10))
  70. wx.StaticText(self.panel,-1,"Enter your Gmail login ID: ",pos = (10,55))
  71. wx.StaticText(self.panel,-1,"Enter your Gmail password:\n(will not be stored)",pos = (10,80))
  72. wx.StaticText(self.panel,-1,"To:",pos = (10,180))
  73. wx.StaticText(self.panel,-1,"Subject:",pos = (10,210))
  74. wx.StaticText(self.panel,-1,"Message",pos = (135,240)).SetForegroundColour('brown')
  75.  
  76. #----| TextBox |---#
  77. self.username = wx.TextCtrl(self.panel,101,"tomlaa1@gmail.com",pos = (150,50),size = (160,20))
  78. self.password = wx.TextCtrl(self.panel,102,"qqqqqq11",style = (wx.TE_PASSWORD), pos = (150,80),size = (160,20))
  79. self.to_info = wx.TextCtrl(self.panel,104,pos = (70,180),size = (240,20))
  80. self.sbj_info = wx.TextCtrl(self.panel,105,pos = (70,210),size = (240,20))
  81. self.msg_info = wx.TextCtrl(self.panel,106,style = wx.TE_MULTILINE,pos = (13,265),size = (300,150))
  82.  
  83. self.Centre()
  84. self.Show()
  85.  
  86. def Quit(self,event):
  87. self.Close()
  88.  
  89. def Login(self,event):
  90. self.user=self.username.GetValue()
  91. self.passw=self.password.GetValue()
  92. try:
  93. self.s.login(self.user,self.passw)
  94. wx.StaticText(self.panel,-1,"You are logged in...",pos = (130,127)).SetForegroundColour('blue')
  95. except:
  96. wx.StaticText(self.panel,-1,"Login in failed",pos = (100,125)).SetForegroundColour('red')
  97.  
  98. def Send(self,event):
  99. self.info["To"] = self.to_info.GetValue()
  100. self.info["Subject"] = self.sbj_info.GetValue()
  101. self.info["Message"]= self.msg_info.GetValue()
  102.  
  103. self.to=self.info["To"]
  104. self.subject = self.info["Subject"]
  105. self.message = self.info["Message"]
  106. self.msg = "To: " + self.to + "\nSubject: " + self.subject+"\n" + self.message
  107.  
  108. try:
  109. self.s.sendmail(self.user,self.to,self.msg)
  110. wx.StaticText(self.panel,-1,"Mail send successfully",pos = (120,435)).SetForegroundColour('blue')
  111. self.s.quit()
  112. except:
  113. wx.StaticText(self.panel,-1,"Mail not sent",pos = (120,435)).SetForegroundColour('red')
  114.  
  115. def About(self,event):
  116. '''
  117. Show about window
  118. '''
  119. info = wx.AboutDialogInfo()
  120. info.Name = "Py-Mailer"
  121. info.Version = "version ?"
  122. info.Copyright = ""
  123. info.Description = wordwrap(
  124. 'info about this program......' ,
  125. 350, wx.ClientDC(self))
  126. info.WebSite = ("http://www.uberpix.wordpress.com", "Sravan home")
  127. info.Developers = [ "Dan Sravan\n"
  128. 'Co-developer:\n'
  129. 'Snippsat',]
  130. info.License = wordwrap(licenseText, 500, wx.ClientDC(self))
  131. wx.AboutBox(info)
  132. licenseText = 'Copyright(c) 2009 Sravan'
  133.  
  134. pymailer()
  135. window.MainLoop()
Last edited by snippsat; 30 Days Ago at 7:11 pm.
Attached Thumbnails
pymail.png   pymail1.png  
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 231
Reputation: sravan953 has a little shameless behaviour in the past 
Solved Threads: 28
sravan953's Avatar
sravan953 sravan953 is online now Online
Posting Whiz in Training

How'd you get the images?

 
0
  #7
27 Days Ago
Originally Posted by snippsat View Post
Hi here are som changes.
Done some work on this,i was thinking making somthing simelar as this for fun.
So helping you a little is no problem,set my self as co-developer in about box if you dont mind.

Here are changes.

----------| Change log |---------

* Change on size and design | New headerpicture

* Take away maximize window (wx.MINIMIZE_BOX)

* Ico for Frame and about box

* New about box style

* Picture buttons

* Bigger message Box and multiline enable(wx.TE_MULTILINE)

* Exception handling on mail sent with new StaticText message

* Better documentation of code

----------| idèe for future development |--------

* Email attachment(file)

* Contact list load

* Save default login

http://www.esnips.com/doc/c2e05e06-5...05ed/py-mailer

  1. import smtplib
  2. import time
  3. import os
  4. import wx
  5. from wx.lib.wordwrap import wordwrap
  6.  
  7. window = wx.App()
  8. class pymailer(wx.Frame):
  9. '''
  10. Program to send gmail message
  11. '''
  12. def __init__(self):
  13. wx.Frame.__init__(self, None, wx.ID_ANY,"Py-mailer",size=(330,520),
  14. style = wx.DEFAULT_DIALOG_STYLE | wx.MINIMIZE_BOX)
  15. #----| Window color |---#
  16. self.SetBackgroundColour("#d8d8bf")
  17.  
  18. #---| Add a panel so it looks the correct on all platforms |---#
  19. self.panel = wx.Panel(self, wx.ID_ANY)
  20.  
  21. #---| Ico for window |---#
  22. ico = wx.Icon('email1.ico', wx.BITMAP_TYPE_ICO)
  23. self.SetIcon(ico)
  24.  
  25. #----| Gmail server |---#
  26. self.info = {}
  27. self.s = smtplib.SMTP("smtp.gmail.com",587)
  28. self.s.ehlo()
  29. self.s.starttls()
  30. self.s.ehlo()
  31.  
  32. #---| Menu bar |---#
  33. menubar=wx.MenuBar()
  34. filem=wx.Menu()
  35. filem.Append(201,"Quit")
  36. self.Bind(wx.EVT_MENU,self.Quit,id=201)
  37. viewm = wx.Menu()
  38. viewm.Append(202,"About")
  39. self.Bind(wx.EVT_MENU,self.About,id=202)
  40. menubar.Append(filem,"File")
  41. menubar.Append(viewm,"Help")
  42. self.SetMenuBar(menubar)
  43.  
  44. #---| Picture Buttons |---#
  45. self.send = wx.BitmapButton(self.panel,107,wx.Bitmap("py_email1.png"),
  46. pos = (7,430), size = (65,26))
  47. self.Bind(wx.EVT_BUTTON,self.Send,id = 107)
  48. self.login = wx.BitmapButton(self.panel,103,wx.Bitmap("py_email2.png"),
  49. pos = (7,123), size = (65,26))
  50. self.Bind(wx.EVT_BUTTON,self.Login,id = 103)
  51.  
  52. #---| Standar Buttons |---#
  53. #login = wx.Button(self.panel,103,label = "Login", pos = (10,120))
  54. #self.Bind(wx.EVT_BUTTON,self.Login,id = 103)
  55. #send = wx.Button(self.panel, 107, "Send", pos = (50,400))
  56. #self.Bind(wx.EVT_BUTTON, self.Send,id = 107)
  57.  
  58. #---| Picture |---#
  59. self.bitmap_1 = wx.StaticBitmap(self, -1, wx.Bitmap("py1.png",
  60. wx.BITMAP_TYPE_ANY),pos = (43,5 ), size = (250,42))
  61.  
  62. #---| Label Text |---#
  63. wx.StaticText(self, -1, '---------------------------------------------------------------------------',
  64. pos = (10,107), size = (400,13 )).SetForegroundColour('blue')
  65. wx.StaticText(self, -1, '---------------------------------------------------------------------------',
  66. pos = (10,35), size = (400,13 )).SetForegroundColour('blue')
  67. wx.StaticText(self, -1, '---------------------------------------------------------------------------',
  68. pos = (10,150), size = (400,13 )).SetForegroundColour('blue')
  69. #wx.StaticText(self.panel,-1,"Welcome to Py-mailer.\nLogin with your Gmail credentials and you can send a text-only email to anyone quickly and easily.",pos=(10,10))
  70. wx.StaticText(self.panel,-1,"Enter your Gmail login ID: ",pos = (10,55))
  71. wx.StaticText(self.panel,-1,"Enter your Gmail password:\n(will not be stored)",pos = (10,80))
  72. wx.StaticText(self.panel,-1,"To:",pos = (10,180))
  73. wx.StaticText(self.panel,-1,"Subject:",pos = (10,210))
  74. wx.StaticText(self.panel,-1,"Message",pos = (135,240)).SetForegroundColour('brown')
  75.  
  76. #----| TextBox |---#
  77. self.username = wx.TextCtrl(self.panel,101,"tomlaa1@gmail.com",pos = (150,50),size = (160,20))
  78. self.password = wx.TextCtrl(self.panel,102,"qqqqqq11",style = (wx.TE_PASSWORD), pos = (150,80),size = (160,20))
  79. self.to_info = wx.TextCtrl(self.panel,104,pos = (70,180),size = (240,20))
  80. self.sbj_info = wx.TextCtrl(self.panel,105,pos = (70,210),size = (240,20))
  81. self.msg_info = wx.TextCtrl(self.panel,106,style = wx.TE_MULTILINE,pos = (13,265),size = (300,150))
  82.  
  83. self.Centre()
  84. self.Show()
  85.  
  86. def Quit(self,event):
  87. self.Close()
  88.  
  89. def Login(self,event):
  90. self.user=self.username.GetValue()
  91. self.passw=self.password.GetValue()
  92. try:
  93. self.s.login(self.user,self.passw)
  94. wx.StaticText(self.panel,-1,"You are logged in...",pos = (130,127)).SetForegroundColour('blue')
  95. except:
  96. wx.StaticText(self.panel,-1,"Login in failed",pos = (100,125)).SetForegroundColour('red')
  97.  
  98. def Send(self,event):
  99. self.info["To"] = self.to_info.GetValue()
  100. self.info["Subject"] = self.sbj_info.GetValue()
  101. self.info["Message"]= self.msg_info.GetValue()
  102.  
  103. self.to=self.info["To"]
  104. self.subject = self.info["Subject"]
  105. self.message = self.info["Message"]
  106. self.msg = "To: " + self.to + "\nSubject: " + self.subject+"\n" + self.message
  107.  
  108. try:
  109. self.s.sendmail(self.user,self.to,self.msg)
  110. wx.StaticText(self.panel,-1,"Mail send successfully",pos = (120,435)).SetForegroundColour('blue')
  111. self.s.quit()
  112. except:
  113. wx.StaticText(self.panel,-1,"Mail not sent",pos = (120,435)).SetForegroundColour('red')
  114.  
  115. def About(self,event):
  116. '''
  117. Show about window
  118. '''
  119. info = wx.AboutDialogInfo()
  120. info.Name = "Py-Mailer"
  121. info.Version = "version ?"
  122. info.Copyright = ""
  123. info.Description = wordwrap(
  124. 'info about this program......' ,
  125. 350, wx.ClientDC(self))
  126. info.WebSite = ("http://www.uberpix.wordpress.com", "Sravan home")
  127. info.Developers = [ "Dan Sravan\n"
  128. 'Co-developer:\n'
  129. 'Snippsat',]
  130. info.License = wordwrap(licenseText, 500, wx.ClientDC(self))
  131. wx.AboutBox(info)
  132. licenseText = 'Copyright(c) 2009 Sravan'
  133.  
  134. pymailer()
  135. window.MainLoop()
How did you make those images?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 148
Reputation: snippsat is an unknown quantity at this point 
Solved Threads: 46
snippsat snippsat is offline Offline
Junior Poster
 
0
  #8
27 Days Ago
How did you make those images?
Du you mean the Attached Thumbnails?
Thats just screenshot capture with free program jing.
http://www.jingproject.com/
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 79
Reputation: pythopian is an unknown quantity at this point 
Solved Threads: 21
pythopian pythopian is offline Offline
Junior Poster in Training
 
0
  #9
26 Days Ago
Note that the way you use try/except is not very wise.
  1. try:
  2. self.s.sendmail(self.user,self.to,self.msg)
  3. wx.StaticText(self.panel,-1,"Mail send successfully",pos = (120,435)).SetForegroundColour('blue')
  4. self.s.quit()
  5. except:
  6. wx.StaticText(self.panel,-1,"Mail not sent",pos = (120,435)).SetForegroundColour('red')
You should do something like this instead:
  1. try:
  2. self.s.sendmail(self.user,self.to,self.msg)
  3. except LoginError:
  4. wx.StaticText(self.panel,-1,"Mail not sent",pos = (120,435)).SetForegroundColour('red')
  5. else:
  6. wx.StaticText(self.panel,-1,"Mail send successfully",pos = (120,435)).SetForegroundColour('blue')
  7. self.s.quit()
Reply With Quote Quick reply to this message  
Reply

Tags
dan08, pymailer, statictext, wxpython

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC