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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:01:27+00:00 2026-05-23T01:01:27+00:00

I have over 300 questions/prompts that I plan to include in the program. The

  • 0

I have over 300 questions/prompts that I plan to include in the program. The flow is pretty much like this:

Create a window with the question.
Store answer in variable.
Create NEW window with question.
Store NEW answer.

this continues on for over 300 questions.


I have 2 concerns:


1) Will this eventually lead to a crash since I’m creating so many windows

2) Everything works with this code if you select ‘Yes’ to the second question (A2) but it does not work if you select ‘No’. Can you please see if you can find what’s wrong with it?


import wx

a1 = ['Apples', 'Bananas', 'Strawberries', 'Watermelon',
     "Don't remember", 'None of the above']

a2 = ['No', 'Yes']

a4 = ['No', 'Yes']


class Fruit(wx.Frame):

    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, 'Fruit', size=(300,200))

        #create panel and button
        panel = wx.Panel(self)

        # B1 - create multiple choice list
        box = wx.MultiChoiceDialog(None, """

A1.    What kind of fruit did you buy at the store?""", 'Fruit', a1)
        if box.ShowModal() == wx.ID_OK:
            a_1 = box.GetSelections()


        print (a_1, '\n')

        # A2 - create single choice list
        box = wx.SingleChoiceDialog(None, """
A2.    Do you like eating fruit?
""", 'Fruit', a2)
        if box.ShowModal() == wx.ID_OK:
            a_2 = box.GetStringSelection()

        print (a_2, '\n')

        if a_2 == 'Yes':
            box = wx.TextEntryDialog(None, "A3.    What kind of fruit is your favorite? ", "Fruit", "")
        if box.ShowModal() == wx.ID_OK:
            a_3 = box.GetValue()

        print (a_3, '\n')


        box = wx.SingleChoiceDialog(None, """
A4.    Did you eat the fruit that you bought?
""", 'Fruit', a4)
        if box.ShowModal() == wx.ID_OK:
            a_4 = box.GetStringSelection()

        print (a_4, '\n')

Thanks

  • 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-23T01:01:28+00:00Added an answer on May 23, 2026 at 1:01 am

    Holy Cow. You’re not really chaining the dialogs like that are you? To try to answer your questions:

    1. Will this eventually lead to a crash: This snippet of code should fail at the first print following someone clicking No. See bullet point #2. There’s a lot missing here, I don’t see any error handling, no __main__, missing an App() etc. Because you’re repeatedly reassigning the value of box I don’t think you’re likely to encounter memory issues, but those are the least of your concerns at this stage.
    2. Everything works if you click Yes, but fails if you click No: That’s coming from this box.ShowModal() == wx.ID_OK. You’re only creating the variables a_# if you get the OK value from your Dialog. You could do this instead:

      a_1 = box.getSelections() if box.ShowModal() == wx.ID_OK else None

    Here you’d substitute in some meaningful value for None.. Note that this uses the Python Ternary Syntax, which was introduced in 2.5 or 2.6. It would not work with 2.4.

    All that said, what you probably want to create is a Wizard. They are “typically used to decompose a complex dialog into several simple steps”. There’s a tutorial available here at wxWidgets that might shed some light. Once you’ve looked at that a little bit you should investigate sizers, as it appears you’re using multiline strings to create white spaces(?).

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

Sidebar

Related Questions

I have a switch statement that has over 300 case statements. case 'hello': {
I have a program that can have a lot of parameters (we have over
im planning to create a movie file that might have over 16,000 frames?i know
I have over 300 items in a list that I need to change the
I've currently written a program in C++ that sometimes uses over 300 threads. In
I need to find out the prime factors of over 300 billion. I have
We all know the effects that lots of thrown exceptions can have over the
If I'm building an application that will have over 30 models, and I want
Good Morning All, I have loaded over 1,300 blurbs into my client's database with
I have inherited a single project in svn: 30Gb in over 300 000 files.

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.