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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:05:56+00:00 2026-05-14T21:05:56+00:00

I have a python console app. Like most python console apps it uses the

  • 0

I have a python console app. Like most python console apps it uses the OptionParser module to take arguments. I’ve now developed a GUI for my app using wxPython and i’d like to integrate the two. I’d like my app to be run both from the console and from the OS’s UI. When it is invoked from the console it runs as a console app and when it is double clicked in the OS’s UI, it runs as a GUI app. How could I do something like this? Could someone show me a a snippet of what the __main__ block should be like?

Thanks a ton.

  • 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-14T21:05:57+00:00Added an answer on May 14, 2026 at 9:05 pm

    can you pass args to the app then use the arg parser?

    if __name__ == "__main__":
      from  optparse import OptionParser
    
      parser = OptionParser() 
      parser.add_option("-g","--gui_mode",
                        dest="guimode",
                        help="start program in gui mode",
                       action="store_true")
    
      (options,args) = parser.parse_args()
    
      if (options.guimode):
          print "start wx app"
      else:
          print "start cmd line app"
    

    Edit:
    Sorry, misread, i thought you wanted to start from another Wx App. rather than from the “OS UI”
    I don’t know of a great, cross platform way to do this. The issue is that in windows .py files are usually associated with the python.exe .pyw files are similar, but don’t have a console window.
    So you would actually have to modify the OS to support this behaviour. For example you could create a shortcut (in windows/gnome/kde) that launches the program with –gui_mode or use a mechanism like @Austin suggested in an *nix OS.
    Some of this stuff can be automated by disttools if you are installing an application

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

Sidebar

Ask A Question

Stats

  • Questions 536k
  • Answers 536k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could use the .find() function: $('#container li').each(function() { $(this).find('a').each(function()… May 17, 2026 at 1:31 am
  • Editorial Team
    Editorial Team added an answer This should do it: SPSite site = new SPSite( siteCollectionUrl… May 17, 2026 at 1:31 am
  • Editorial Team
    Editorial Team added an answer Reliable Regex for HTML are difficult. Here is how to… May 17, 2026 at 1:31 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a c console app which converts a c file to a html
I have a console daemon that is run by a GUI application. When the
I have multiple python processes running in their console output windows. I can set
I have a simple Python script that runs in a console windows. How can
Well this interactive python console snippet will tell everything: >>> class Test: ... def
According to Firebug console, we have the following in JavaScript: >>> [''] == ''
I have been trying to use the new validators that are now included with
I'm starting to get into the Python logging module, but unless I want all
can I use Popen from python subprocess to close started process? For example, from
I'm working on a Django app for hosting media (specifically audio and images). I

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.