Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6791811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:53:29+00:00 2026-05-26T17:53:29+00:00

The idea here is to login (top frame called LoginFrame). Open a child frame

  • 0

The idea here is to login (top frame called LoginFrame).
Open a child frame (MainFrame) with 2 option (a or b).
Each option opens another child frame (with MainFrame as parent).
Inside each one is a button to go back to the MainFrame.

I used the LoginFrame as parent for MainFrame,a and b as a workaround.
But I can’t get the back button to work.

class MainFrame(wx.Frame):
    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,'Title',size=(353,270),style=wx.CAPTION|wx.CLOSE_BOX|wx.SYSTEM_MENU|wx.MINIMIZE_BOX)
        self.panel=wx.Panel(self)

        aButton= wx.Button(self.panel, -1, 'a',pos=(10,10),size=(-1,30))
        self.Bind(wx.EVT_BUTTON, self.a,aButton)

        bButton= wx.Button(self.panel, -1, 'b',pos=(100,10),size=(-1,30))
        self.Bind(wx.EVT_BUTTON, self.b,bButton)

    def a(self,event):
        aframe=aFrame(parent=frame,id=997)
        aframe.Centre()
        aframe.Show()
        mainframe.Hide()

    def b(self,event):
        bframe=bFrame(parent=frame,id=996)
        bframe.Centre()
        bframe.Show()
        mainframe.Hide()


class bFrame(wx.Frame):
    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,'2',size=(353,270),style=wx.CAPTION|wx.CLOSE_BOX|wx.SYSTEM_MENU|wx.MINIMIZE_BOX)
        self.panel=wx.Panel(self)

        mainButton = wx.Button(self.panel, -1, '&Back to Main',pos=(100,100),size=(-1,30))
        self.Bind(wx.EVT_BUTTON, self.backMain,mainButton)

    def backMain (self, event):
        mainframe.Show()
        self.Destroy()


class aFrame(wx.Frame):
    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,'1',size=(353,270),style=wx.CAPTION|wx.CLOSE_BOX|wx.SYSTEM_MENU|wx.MINIMIZE_BOX)
        self.panel=wx.Panel(self)

        mainButton = wx.Button(self.panel, -1, '&Back to Main',pos=(100,100),size=(-1,30))
        self.Bind(wx.EVT_BUTTON, self.backMain,mainButton)

    def backMain (self, event):
        mainframe.Show()
        self.Destroy()


class LoginFrame(wx.Frame):
    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,'Login',size=(400,200),style=wx.CAPTION|wx.CLOSE_BOX|wx.SYSTEM_MENU|wx.MINIMIZE_BOX)
        self.panel=wx.Panel(self)
        sizer = wx.FlexGridSizer(rows=3, cols=2, hgap=5, vgap=15)

        self.txt_Username = wx.TextCtrl(self.panel, 1, size=(150, -1))
        username = wx.StaticText(self.panel, -1, "Username:")
        sizer.Add(username,0, wx.LEFT|wx.TOP| wx.RIGHT, 50)
        sizer.Add(self.txt_Username,0, wx.TOP| wx.RIGHT, 50)

        self.txt_Password = wx.TextCtrl(self.panel, 1, size=(150, -1), style=wx.TE_PASSWORD)
        password = wx.StaticText(self.panel, -1, "Password:")
        sizer.Add(password,0, wx.LEFT|wx.RIGHT, 50)
        sizer.Add(self.txt_Password,0, wx.RIGHT, 50)

        loginButton = wx.Button(self.panel, -1, "&Login")
        self.Bind(wx.EVT_BUTTON, self.login,loginButton)
        sizer.Add(loginButton,0, wx.LEFT, 50)

        self.panel.SetSizer(sizer)

    def login(self, event):
        usertext = self.txt_Username.GetValue()
        passwordtext = self.txt_Password.GetValue()
        if usertext=='' and passwordtext=='':
            granted=wx.MessageDialog(None,'Access Granted!','Access Granted!',wx.OK)
            answerG=granted.ShowModal()
            granted.Destroy()
            mainframe=MainFrame(parent=frame,id=998)
            mainframe.Centre()
            mainframe.Show()
            frame.Hide()
        else:
            denied=wx.MessageDialog(None,'Access Denied!','Access Denied!',wx.OK)
            answerD=denied.ShowModal()
            denied.Destroy()


if __name__ == '__main__':
    app=wx.App()
    frame=LoginFrame(parent=None,id=999)
    frame.Centre()
    frame.Show()
    app.MainLoop()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:53:30+00:00Added an answer on May 26, 2026 at 5:53 pm

    Modify the methods a and b like this:

    def a(self,event):
        aframe = aFrame(parent=self, id=997)  # parent is the MainFrame instance self
        aframe.Centre()
        aframe.Show()
        self.Hide()                           # Hide the MainFrame instance
    

    Then modify the Frames a and b like this:

    class bFrame(wx.Frame):
        def __init__(self, parent, id):
            wx.Frame.__init__(self, parent, id, '2', size=(353,270), style=wx.CAPTION|wx.CLOSE_BOX|wx.SYSTEM_MENU|wx.MINIMIZE_BOX)
            self.parent = parent              # parent is the MainFrame instance (self --> parent)
            self.panel = wx.Panel(self)
    
            mainButton = wx.Button(self.panel, -1, '&Back to Main',pos=(100,100),size=(-1,30))
            self.Bind(wx.EVT_BUTTON, self.backMain,mainButton)
    
        def backMain (self, event):
            self.parent.Show()                # now I can show again Mainframe
            self.Destroy()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the basic idea: There is a java window (main) that opens another java
Here's the scenario I have a page lets say login.aspx having a button called
The idea here is to get better programmers right out of college. I think
This is a weird one, but hopefully someone can give me an idea here.
Here's the idea, I'd like to make a service? that will look for a
Here's the idea: you commit your code to a repository and call a web
Here is the idea: When the user wants to see /controller/action, then I want
I have no idea what this means. But here is the code that it
Help, here is the idea: External.dll IMyClass NewCreated = (IMyClass)Activator.CreateInstance(Namespace.MyClass).UnWrap(); ----------------------------------------- Asp.Net WebSite App_Code
Maybe I'm thinking about this the wrong way but here's the idea: Class A

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.