I have over 300 questions 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 questions:
- Will this eventually lead to a crash since I'm creating so many windows?
- 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')