Member Avatar for sravan953

Hey All,

I have 'Py-mailer' here.... here's how it is so far:

import smtplib
import wx

window=wx.App()

class pymailer(wx.Frame):
    
    def __init__(self):
        wx.Frame.__init__(self,None,-1,"Py-mailer",size=(900,700))

        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, "Login ID:", pos=(10,10))
        wx.StaticText(self.panel, -1, "Password:", pos=(10,40))

        self.username=wx.TextCtrl(self.panel,101,"Login ID",pos=(100,10))        
        self.password=wx.TextCtrl(self.panel,102,"Password",style=(wx.TE_PASSWORD),pos=(100,40))

        wx.StaticText(self.panel, -1, "@gmail.com", pos=(220,10))

        login=wx.Button(self.panel,103,label="Login",pos=(115,70))
        self.Bind(wx.EVT_BUTTON,self.Login,id=103)
        
        wx.StaticText(self.panel,-1,"To:",pos=(10,120))
        wx.StaticText(self.panel,-1,"Subject:",pos=(10,150))
        wx.StaticText(self.panel,-1,"Message:", pos=(10,180))

        self.to_info=wx.TextCtrl(self.panel,104,pos=(80,120),size=(300,20))        
        self.sub_info=wx.TextCtrl(self.panel,105,pos=(80,150),size=(300,20))        
        self.msg_info=wx.TextCtrl(self.panel,106,pos=(80,180),size=(800,400))
        
        send=wx.Button(self.panel,107,"Send",pos=(400,600))
        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 and Daniel")
        about.SetWebSite("http://www.team-vaska.co.cc")
        about.AddDeveloper("Sravan")
        about.AddDeveloper("Daniel Pacheco")

        wx.AboutBox(about)

    def Login(self,event):

        self.user=self.username.GetValue()
        self.passw=self.password.GetValue()
        self.loginmsg=wx.StaticText(self.panel,-1,"...",pos=(10,200))

        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)
            self.loginmsg.SetLabel("Logged in...")
        except:
            self.loginmsg.SetLabel("Failed to login, please try again...")
        

    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()

Now what I want to do is: when the user clicks the "Send" button, the panel should refresh, and only a StaticText should be displayed in the centre saying "Sending...". After that I should say (after the message is sent) "You message has been successfully sent to _____".

How do I make the panel destroy all it's contents?

Thanks,
Sravan

You can individually set a sizer/widget to show/hide. You do this by going:

sizer.Show(False)
#or otherwise
ExampleTextCtrl.Show(False)

Then you can set them to show again by doing the same command with True as the argument.

Hope that helps :)

You could also specify which widgets in the sizer should be visible or not

sizer.Show(text_ctrl_1, False)
commented: This is 6 months old. -1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.