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 8016013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:25:23+00:00 2026-06-04T20:25:23+00:00

Lets say I have this sample code: import wx app = wx.App(False) # Create

  • 0

Lets say I have this sample code:

import wx

app = wx.App(False)  # Create a new app, don't redirect stdout/stderr to a window.
frame = wx.Frame(None, wx.ID_ANY, "Hello World") # A Frame is a top-level window.
s=wx.Button(frame,-1,"New")
frame.Show(True)     # Show the frame.
app.MainLoop()

Like in some programs, if you press the New button, it will open the program again in another window. I am wondering, how can i do this in python?

I cannot make a window object then make copies of it because, in my actual program I am using global variables and these global variables are made for only one window.

It appears that my only option is to find a way to run the program again.

  • 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-04T20:25:24+00:00Added an answer on June 4, 2026 at 8:25 pm

    You could try something like this

    import subprocess
    import sys
    new_process = subprocess.Popen([sys.executable]+sys.argv)
    

    Which will run python again with the arguments it was run with originally. Or modifying your original example to make pressing the button run the script again :-

    import wx
    import subprocess
    import sys
    
    def re_run(e):
        new_process = subprocess.Popen([sys.executable]+sys.argv)
    
    app = wx.App(False)  # Create a new app, don't redirect stdout/stderr to a window.
    frame = wx.Frame(None, wx.ID_ANY, "Hello World") # A Frame is a top-level window.
    s=wx.Button(frame,-1,"New")
    s.Bind(wx.EVT_BUTTON, re_run)
    frame.Show(True)     # Show the frame.
    app.MainLoop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have this code: $dom = new DOMDocument(); @$dom->loadHTMLFile('sample.html'); $xp = new
Lets say we have these 2 sample code : public synchronized void getSomething(){ this.hello
lets say i have this html code : <div> <a> <span id=a> </span> </a>
Lets say i have this javascript code in an html pages <script type=text/javascript> $(document).ready(function(){
This is a simple question (I think) Lets say I have this code (Assuming
Lets say have this immutable record type: public class Record { public Record(int x,
Lets say I have this service: public class Service { ... public Service(IFactory factory)
Lets say we have this markup: <div id=container> <ul></ul> <ul></ul> </div> Where the format
Lets say I have this: class A { } class B : A {
Let's say I have a following string from twitter: This is my sample test

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.