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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:50:47+00:00 2026-05-17T17:50:47+00:00

In my program there is a complex calculation that requires the user to evaluate

  • 0

In my program there is a complex calculation that requires the user to evaluate intermediate results. This works well in a command line application (which is what my code looks like now) because the interactive prompt halts the program execution until the user hits enter. The command line code looks something like this:

def calculate(starting):
    result1 = initial_calculation(starting)
    user_input1 = input("What is your choice for " + result1 + "?")
    result2 = calculate1(user_input1)
    user_input2 = input("What is your choice for " + result2 + "?")
    result2 = calculate2(user_input2)
    #...etc

I would like to provide a more intuitive interface than is possible with the command line by using a GUI and allowing the user to click on a button indicating their choice instead of typing it in. I’m picturing something like this:

def do_something(starting):
    result1 = initial_calculation(starting)
    #wait for user to press a button indicating their choice?
    result2 = calculate1(clicked_button.user_input1)

    label.text("What is your choice for " + result1 + "?")
    #wait for user again
    result2 = calculate2(clicked_button.user_input2)
    #...etc

Is there a way I can pause the execution of the procedural code that does the calculations and then resume the code after the user clicks a button? I’m not really sure how to raise or handle events here because normally in a GUI the control callbacks are the starting point for code execution, but here, the code starts elsewhere and needs to yield to and resume from the GUI.

(If it makes a difference, I am using Python and wxPython.)

  • 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-17T17:50:47+00:00Added an answer on May 17, 2026 at 5:50 pm

    General solution:

    flag = false;
    

    your thread:

    while (!flag); // wait here, consume cpu doing nothing
    

    gui thread:

    void OnInputEvent() { flag = true; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that can accept command-line arguments and I want to access
I have a program, and in that program there is some variables (username and
Is there a program which I can run like this: py2py.py < orig.py >
Is there any program code that can help me to pop up the virtual
This is a function in my program. With the cout statement there the program
Is there a program that will take response curve values from me, and provide
I'm writing a Java program to simulate a command line feeder, it runs DOS
I have a complex issue at hand. I have developed a program that takes
I have a command line program to validate an XML against an XSD file.
This is a pretty beginner question, but given that I render a complex shape

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.