Hi, I have the a situation here .

My motive : Hiding one panel and showing another.

Whats Working :Layout wise , my app is behaving like i want it to .
The Problem : After the I hide one panel and show another , the button in this panel (process button) is still pointing to the funtion binded with "OUT" button .

I am providing the program below.
1) Launch it .
2) Press "Process" button. Then press "Out" Button .
3) U will see old panel come back. Again press "Process" button .
4) Observe that the button is running the function binded with the "OUT" Button.

import wx


class Panels(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title,size=(500,-1))

                #Font
        #__init__(self, pointSize, family, style, weight, underline=False, face=EmptyString, encoding=FONTENCODING_DEFAULT) 
        self.font1 = wx.Font(12, wx.DECORATIVE, wx.ITALIC,wx.FONTWEIGHT_BOLD, underline = True )
        self.font2 = wx.Font(10, wx.DECORATIVE, wx.NORMAL,wx.FONTWEIGHT_BOLD, underline = False )
        self.font3 = wx.Font(10, wx.DECORATIVE, wx.ITALIC,wx.FONTWEIGHT_BOLD, underline = True )

        favicon = wx.Icon('icon.ico', wx.BITMAP_TYPE_ICO)
        wx.Frame.SetIcon(self, favicon)

        list_choice = ['ALL','UnSeen','DRAFT']

        self.vbox = wx.BoxSizer(wx.VERTICAL)

#Launch panel Defined

        panel_launch = wx.Panel(self,-1,style=wx.SUNKEN_BORDER)



#Layout Defination

        hbox= wx.BoxSizer(wx.HORIZONTAL)
        lbl_Username = wx.StaticText(panel_launch,0, "Username:")
        lbl_Username.SetFont(self.font3) 
        self.txt_Username = wx.TextCtrl(panel_launch,0)#wx.Size(self,w,h)
        lbl_Password = wx.StaticText(panel_launch,0, "Password:")
        lbl_Password.SetFont(self.font3) 
        self.txt_Password = wx.TextCtrl(panel_launch,0,style=wx.TE_PASSWORD)

        btn_Process = wx.Button(panel_launch,0, "Process")

        hbox.Add(lbl_Username,0,wx.LEFT|wx.TOP,10)
        hbox.Add(self.txt_Username,0,wx.LEFT|wx.TOP,10)
        hbox.Add(lbl_Password,0,wx.LEFT|wx.TOP,10)
        hbox.Add(self.txt_Password,0,wx.LEFT|wx.TOP,10)
        hbox.Add(btn_Process,0,wx.LEFT|wx.TOP,10)
        panel_launch.SetSizer(hbox)


#Menu section
        menubar=wx.MenuBar()
        pehla=wx.Menu()
        doosra=wx.Menu()
        teesra =wx.Menu()
        option_menu=wx.Menu()
        info=wx.Menu()

#Menu Items

        self.item1_1=pehla.Append(wx.ID_OPEN,"&Add Mail\tAlt-A","This is to add a mail account") #Sub-Items of First menu pull down list
        item1_2=pehla.Append(wx.ID_EXIT,"&Quit\tAlt-Q","This will exit app") #The last comment will show on status bar when mouse is on that option
        item3_2=teesra.Append(wx.ID_ABOUT,"A&bout\tAlt-B","About Section")


        menu_1=menubar.Append(pehla,'&File')    #Naming of Menu items
        menu_2=menubar.Append(doosra,'&Edit')
        menu_3=menubar.Append(teesra,'&Info')
        item2_1=option_menu.Append(wx.ID_ANY,'Export File Location')
        doosra.AppendMenu(wx.ID_ANY,"&Options\tAlt-O",option_menu)
        self.item1_1.Enable(False)
        self.SetMenuBar(menubar)

        self.vbox.Add(panel_launch,-1,wx.EXPAND,10)

        self.SetSizer(self.vbox)

        self.Layout()

        self.Centre()

        self.Show(True)

#Event Bindings

        self.Bind(wx.EVT_BUTTON,self.OnSignIn,btn_Process)
        self.Bind(wx.EVT_MENU,self.OnAddMail,self.item1_1)
        self.Bind(wx.EVT_MENU, self.OnFileExit,item1_2)



#+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-
#--------------------------Frame Related Function Zone--------------------------------------

    def OnSignIn(self,event):
        print "We are in default"

        mymail = self.txt_Username.GetValue()
        mypwd = self.txt_Password.GetValue()
        self.tstremove(event) #Hiding the old panel items
        panel_signedin = wx.Panel(self,-1)
        lbl_email = wx.StaticText(panel_signedin,0, "Email:")
        lbl_email.SetFont(self.font3) 
        txt_mymail = wx.StaticText(panel_signedin,0,mymail)
        txt_mymail.SetFont(self.font2)
        btn_OUT = wx.Button(panel_signedin,0, "OUT")
        self.Bind(wx.EVT_BUTTON,self.OnSignOut,btn_OUT)
        hbox3= wx.BoxSizer(wx.HORIZONTAL)

        hbox3.Add(lbl_email,0,wx.ALL,10)
        hbox3.Add(txt_mymail,0,wx.ALL,10)
        hbox3.Add(btn_OUT,0,wx.ALL,10)
        panel_signedin.SetSizer(hbox3)
        self.vbox.Add(panel_signedin,-1,wx.EXPAND,10)
        self.SetSizer(self.vbox)
        self.Layout()
        self.item1_1.Enable(True) #Enable 'Add' menu item

    def OnSignOut(self,event):

        print "We are out"
        event.GetEventObject().GetParent().Hide()

        self.txt_Username.GetParent().Show(True)
        self.Layout()
        return


    def OnSignInNew(self,event):

        print "We are in New"

        self.item1_1.Enable(True)
        mymail1 = self.txt1_Username.GetValue()
        mypwd1 = self.txt_Password.GetValue()
        self.tstremove(event)
        panel_signedin1 = wx.Panel(self,-1)
        lbl_email1 = wx.StaticText(panel_signedin1,0, "Email:")
        lbl_email1.SetFont(self.font3) 
        txt_mymail1 = wx.StaticText(panel_signedin1,0,mymail1)
        txt_mymail1.SetFont(self.font2)
        btn1_OUT = wx.Button(panel_signedin1,0, "OUT")
        self.Bind(wx.EVT_BUTTON,self.OnSignOut,btn1_OUT)

        hbox31= wx.BoxSizer(wx.HORIZONTAL)
        hbox31.Add(lbl_email1,0,wx.ALL,10)
        hbox31.Add(txt_mymail1,0,wx.ALL,10)
        hbox31.Add(btn1_OUT,0,wx.ALL,10)
        panel_signedin1.SetSizer(hbox31)
        self.vbox.Add(panel_signedin1,-1,wx.EXPAND,10)
        self.SetSizer(self.vbox)
        self.Layout()


    def tstremove(self,event):

        event.GetEventObject().GetParent().Hide()
        self.Layout()
        return

    def tstrecall(self,event):
        event.GetEventObject().GetParent().UnHide()
        self.Layout()
        return


    def OnAddMail(self,eventdef):
        self.item1_1.Enable(False)
        self.vbox.Add((-1,5))        
        panel_new = wx.Panel(self,0,style=wx.SUNKEN_BORDER)
        hbox1= wx.BoxSizer(wx.HORIZONTAL)
        lbl1_Username = wx.StaticText(panel_new,-1, "Username:")
        lbl1_Username.SetFont(self.font3) 
        self.txt1_Username = wx.TextCtrl(panel_new,-1)#wx.Size(self,w,h)
        lbl1_Password = wx.StaticText(panel_new,-1, "Password:")
        lbl1_Password.SetFont(self.font3) 
        self.txt1_Password = wx.TextCtrl(panel_new,-1,style=wx.TE_PASSWORD)

        btn1_Process = wx.Button(panel_new,-1, "Process")
        self.Bind(wx.EVT_BUTTON,self.OnSignInNew,btn1_Process)

        hbox1.Add(lbl1_Username,0,wx.LEFT|wx.TOP,10)
        hbox1.Add(self.txt1_Username,0,wx.LEFT|wx.TOP,10)
        hbox1.Add(lbl1_Password,0,wx.LEFT|wx.TOP,10)
        hbox1.Add(self.txt1_Password,0,wx.LEFT|wx.TOP,10)
        hbox1.Add(btn1_Process,0,wx.LEFT|wx.TOP,10)
        panel_new.SetSizer(hbox1)

        self.vbox.Add(panel_new,-1,wx.EXPAND,10)
        self.SetSizer(self.vbox)
        self.Layout()
        self.Bind(wx.EVT_BUTTON,self.OnSignInNew,btn1_Process)
        return

#+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-+-()-
#--------------------------Process Related Function Zone--------------------------------------

    def OnFileExit(self, event):
        """ File|Exit event """
        self.Close()


   

app = wx.App()
Panels(None, -1, 'Test')
app.MainLoop()

I just cant get , how one button is pointing to another function ?
Is hiding and showing not enough ? Someone with some hint plz?

Hi , if anyone still following this , the problem in the above problem was ,

All the widgets (everything else) have been give IDs as 0..
One should never do that.....Atleast in this case , i should'nt have done that . I should use either unique IDs or a -1 (when auto IDs will be generated)....Thank you all

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.