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

  • Home
  • SEARCH
  • 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 8248361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:10:05+00:00 2026-06-07T23:10:05+00:00

I have 2 frames in a python script. Once the first one gets minimized,

  • 0

I have 2 frames in a python script. Once the first one gets minimized, the second one shows. How do I get the original one to go from being minimized to restored after I close the second one.

Here is my code so far:

import wx
import wx.media
import os

class MainWindow(wx.Frame):

    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,'Music Player',size=(900,600), style=wx.MINIMIZE_BOX|wx.SYSTEM_MENU|wx.CAPTION|wx.CLOSE_BOX|wx.CLIP_CHILDREN)
        wx.Frame.CenterOnScreen(self)
        panel=wx.Panel(self)
        panel2=wx.Panel(panel,-1, (0,0), (160,600))
        ##wx.Frame.Maximize(self)
        panel.SetBackgroundColour('grey')
        panel2.SetBackgroundColour('black')

        ##MENU AND STATUS BAR
        status=self.CreateStatusBar()
        menubar=wx.MenuBar()
        file_menu=wx.Menu()
        help_menu=wx.Menu()

        ID_FILE_NEW = 1
        ID_FILE_LOAD = 2
        ID_FILE_EXIT = 3

        file_menu.Append(ID_FILE_NEW,"New Window","This will open a new window")
        file_menu.Append(ID_FILE_LOAD,"Load...", "This will let you choose a song to load")
        file_menu.Append(ID_FILE_EXIT,"Exit","This will exit the program")

        menubar.Append(file_menu,"File")
        self.SetMenuBar(menubar)

        self.Bind(wx.EVT_MENU, self.newWin, None, 1)
        self.Bind(wx.EVT_MENU, self.Load, None, 2)        
        self.Bind(wx.EVT_MENU, self.Close, None, 3)

##        heading = wx.StaticText(panel, -1, "Music Player",pos=(345,10))
        font1 = wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.BOLD)
        font2 = wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.BOLD)
##        heading.SetFont(font1)

        try:
            self.mc = wx.media.MediaCtrl(self)
        except NotImplementedError:
            raise

        loadButton = wx.Button(panel2, -1, "Load File", pos=(30,10))
        self.Bind(wx.EVT_BUTTON, self.Load, loadButton)

        playButton = wx.Button(panel2, -1, "Play", pos=(30,50))
        self.Bind(wx.EVT_BUTTON, self.Play, playButton)

        pauseButton = wx.Button(panel2, -1, "Pause", pos=(30,90))
        self.Bind(wx.EVT_BUTTON, self.Pause, pauseButton)

        stopButton = wx.Button(panel2, -1, "Stop", pos=(30,130))
        self.Bind(wx.EVT_BUTTON, self.Stop, stopButton)

        self.playbackSlider = wx.Slider(panel, size=(400,45), pos=(310,50))
        self.playbackSlider.SetRange(0,self.mc.Length())
        self.Bind(wx.EVT_SLIDER, self.onSeek, self.playbackSlider)
        self.playbackSlider.SetBackgroundColour('grey')

        self.volumeCtrl = wx.Slider(panel, value=50, minValue=0, maxValue=100, style=wx.SL_VERTICAL|wx.SL_INVERSE, pos=(180,40))
        self.volumeCtrl.Bind(wx.EVT_SLIDER, self.onSetVolume)

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.onTimer)
        self.timer.Start(100)

        self.Bind(wx.EVT_ICONIZE, self.newWin2)          

        self.st_file = wx.StaticText(self, -1, "**Nothing** Please click the \"Load File\" Button", pos=(310,10))
        playing = wx.StaticText(self, -1, "Now Playing: ", pos=(165,10))
        playing.SetFont(font2)
        self.st_file.SetFont(font1)
        playing.SetBackgroundColour('grey')
        self.st_file.SetBackgroundColour('grey')
        playing.SetForegroundColour('white')
        self.st_file.SetForegroundColour('white')

    def newWin2(self, event):
        if self.IsIconized() == True:
            self.new = NewWindow(parent=None, id=-1)
            self.new.Show()

    def newWin(self, event):
            self.new = NewWindow(parent=None, id=-1)
            self.new.Show()

    def Close(self, event):
        box=wx.MessageDialog(None, 'Are you sure you want to exit?', 'Exit program?', wx.YES_NO)
        answer=box.ShowModal()
        if answer==wx.ID_YES:
            self.Destroy()

    def Load(self, event):
        dlg = wx.FileDialog(self, "Choose a media file", "songs", "", "*.*", wx.OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
            self.doLoadFile(path)
        dlg.Destroy()

    def doLoadFile(self, path):
        if not self.mc.Load(path):
            wx.MessageBox("Unable to load %s: Unsupported format?" % path, "ERROR", wx.ICON_ERROR | wx.OK)

        else:
            folder, filename = os.path.split(path)
            self.st_file.SetLabel('%s' % filename)
            self.mc.SetBestFittingSize()
            self.mc.Play()

    def Play(self, event):
        self.mc.Play()
        self.playbackSlider.SetRange(0,self.mc.Length())

    def Pause(self, event):
        self.mc.Pause()

    def Stop(self, event):
        self.mc.Stop()

    def onSetVolume(self, event):
        self.currentVolume = self.volumeCtrl.GetValue()
        self.mc.SetVolume(float(self.currentVolume) / 100)

    def onTimer(self, event):
        offset = self.mc.Tell()
        self.playbackSlider.SetValue(offset)

    def onSeek(self, event):
        offset = self.playbackSlider.GetValue()
        self.mc.Seek(offset)

class NewWindow(wx.Frame):

    def __init__(self,parent,id):
        wx.Frame.__init__(self, parent, id, 'New Window', size=(130,150), pos=(0,0), style=wx.MINIMIZE_BOX|wx.CLOSE_BOX)
        self.SetBackgroundColour('grey')

        playButton = wx.Button(self, -1, "Play", pos=(5,10))
        self.Bind(wx.EVT_BUTTON, self.Play, playButton)

        pauseButton = wx.Button(self, -1, "Pause", pos=(5,40))
        self.Bind(wx.EVT_BUTTON, self.Pause, pauseButton)

        stopButton = wx.Button(self, -1, "Stop", pos=(5,70))
        self.Bind(wx.EVT_BUTTON, self.Stop, stopButton)

        closeButton = wx.Button(self, -1, "Close", pos=(5,120))
        self.Bind(wx.EVT_BUTTON, self.Close, closeButton)

    def Play(self, event):
        self.mc.Play()
        self.playbackSlider.SetRange(0,self.mc.Length())

    def Pause(self, event):
        self.mc.Pause()

    def Stop(self, event):
        self.mc.Stop()

    def onSetVolume(self, event):
        self.currentVolume = self.volumeCtrl.GetValue()
        self.mc.SetVolume(float(self.currentVolume) / 100)

    def Close(self, event):
        self.Destroy()
        ################## I WANT TO ADD WHATEVER I NEED TO HERE TO RESTORE THE MINIMIZED FRAME AFTER THE CLOSE BUTTON IS PRESSED.

##RUN##

if __name__=='__main__':
        app=wx.PySimpleApp()
        frame=MainWindow(parent=None,id=-1)
        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-06-07T23:10:06+00:00Added an answer on June 7, 2026 at 11:10 pm
    the_app.SetTopWindow(wxFrameObject)
    wxFrameObject.Maximize()
    

    might work … thats what we use

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all i have frames on my SD Card and frames are there
In our product, we have frames that are basically three inheritance levels down from
I have 2 data frames. One is training data ( pubs1 ), the other
I have two data frames with two columns each. The first column is timestamps
So here we have a Python script: Record a few seconds of audio and
I have a python script that I run with 'exec'. When a function is
I have a python script that takes a movie file name and it does
I have the following PyObjC script: from Foundation import NSObject import QTKit error =
I have some code creating a QTabWidget from Python using PyQt4. I want to
I have a python program that processes image frames with Python 2.7, PIL, OpenCV,

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.