We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Final page of connection wizard reports nothing on Mac & Windows
The final page of the connection wizard is blank on both Mac & Windows. This happens regardless of success or failure and predates the recent changes to the GUI in #157.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `app/connect_wizard.py`
Content:
```
1 """Connection setup wizard.
2 
3 """
4 
5 import os
6 import sys
7 import wx
8 import wx.html
9 import wx.wizard
10 from retriever.lib.models import Engine
11 from retriever.lib.tools import get_saved_connection, save_connection
12 from retriever.app.controls import *
13 from retriever.app.images import icon
14 
15 from retriever import VERSION
16 
17 
18 class ConnectWizard(wx.wizard.Wizard):
19     def __init__(self, lists, engine_list, selected=None):
20         wx.wizard.Wizard.__init__(self, None, -1, "EcoData Retriever")
21         
22         #self.SetIcon(icon.GetIcon())
23         
24         welcome = """<h2>Connection Wizard</h2>
25         
26         <p>The EcoData Retriever downloads raw data files, stores them on your
27         computer, and imports the data into your own local database.</p>
28         <p>To begin, you'll need to set up your own database. Once you've done
29         that, this wizard will walk you through the steps to connect to your
30         database.</p>
31         <p>Supported database systems currently include:</p>
32         <ul>"""
33         
34         for db in engine_list:
35             welcome += "<li>" + db.name + "</li>" 
36         
37         welcome += "</ul>"        
38         
39         self.pages = []
40         self.lists = lists
41         self.engine_list = engine_list
42         self.selected = selected
43         
44         self.pages.append(TitledPage(self, "", ""))
45         
46         self.pages.append(ChooseDbPage(self, "Database", 
47                                        "What kind of database are you using?"))
48         
49         self.pages.append(ConnectPage(self, 
50                                       "Connection Info", 
51                                       ""))
52                                       
53         self.pages.append(ConfirmPage(self, "Connection", ""))
54 
55         (self.TITLE, self.CHOOSEDB, 
56          self.CONNECTION, self.CONFIRM) = [self.pages[i] 
57                                            for i in range(len(self.pages))]
58         
59         self.TITLE.welcome = HtmlWindow(self.TITLE)
60         self.TITLE.welcome.SetSize((450,400))
61         self.TITLE.welcome.SetHtml(welcome)
62         self.TITLE.sizer.Add(self.TITLE.welcome, 1, wx.EXPAND)
63              
64         self.CHOOSEDB.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.CONNECTION.Draw)
65         self.CONNECTION.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.CONFIRM.Draw)
66         self.CONFIRM.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.CONNECTION.Draw)
67         
68         for i in range(len(self.pages) - 1):
69             wx.wizard.WizardPageSimple_Chain(self.pages[i], self.pages[i + 1])
70         
71         for page in self.pages:
72             self.FitToPage(page)
73         
74     
75     def check_for_updates(self):
76         reload(retriever)
77 
78 
79 class ChooseDbPage(TitledPage):
80     def __init__(self, parent, title, label):
81         TitledPage.__init__(self, parent, title, label)
82         engine_list = parent.engine_list
83         
84         dblist = ListBox(self, -1, 
85                          choices=[db.name for db in engine_list], 
86                          style=wx.LB_SINGLE,
87                          size=(-1,150))
88         self.dblist = dblist
89         if parent.selected:
90             index = 0
91             for i in range(len(engine_list)):
92                 if engine_list[i].name == parent.selected:
93                     index = i                                    
94             self.dblist.SetSelection(index)
95         else:
96             self.dblist.SetSelection(0)
97         self.sizer.Add(self.dblist, -1, wx.EXPAND)
98 
99         #TODO: This is a hack to force the wizard to be large enough to not hide
100         #the Choose button on the Connect Page when the engine has a file
101         #attribute. This should be fixed properly by figuring out how to make wx
102         #work with the fact that the connect page has varying fields depending
103         #on the engine.
104         longspace = StaticText(self, -1, "", wx.Size(375, -1))
105         self.sizer.Add(longspace, -1)
106         
107     def dirbtn_click(self, evt):
108         dialog = wx.DirDialog(None, message="Choose a directory to " +
109                                 "download your data files.")            
110         if dialog.ShowModal() == wx.ID_OK:            
111            self.raw_data_dir.SetValue(dialog.GetPath())            
112         else:
113            pass
114         dialog.Destroy()
115                     
116 
117 class ConnectPage(TitledPage):
118     """The connection info page."""
119     def __init__(self, parent, title, label):
120         TitledPage.__init__(self, parent, title, label)
121         self.option = dict()
122         self.sel = None
123         self.fields = wx.BoxSizer(wx.VERTICAL)
124         self.parent = parent
125         
126     def Draw(self, evt):
127         """When the page is drawn, it may need to update its fields if 
128         the selected database has changed."""
129         
130         if not evt.GetDirection():
131             btn = self.parent.FindWindowById(wx.ID_FORWARD) 
132             if btn: btn.Enable()
133         
134         if len(self.Parent.CHOOSEDB.dblist.GetStringSelection()) == 0 and evt.Direction:
135             evt.Veto()                  
136         else:
137             if self.sel != self.Parent.CHOOSEDB.dblist.GetStringSelection():
138                 self.sel = self.Parent.CHOOSEDB.dblist.GetStringSelection()
139                 self.engine = Engine()
140                 for db in self.Parent.engine_list:
141                     if db.name == self.sel:
142                         self.engine = db
143                 self.fields.Clear(True)     
144                 self.fields = wx.BoxSizer(wx.VERTICAL)
145                 if self.engine.instructions:
146                     self.fields.Add(StaticText(self, -1, '\n' + self.engine.instructions + '\n\n'))
147                 self.fieldset = dict()
148                 self.option = dict()
149                 saved_opts = get_saved_connection(self.engine.name)
150                 for opt in self.engine.required_opts:
151                     if opt[0] in saved_opts.keys():
152                         default = saved_opts[opt[0]]
153                     else:
154                         default = opt[2]
155                     self.fieldset[opt[0]] = wx.BoxSizer(wx.HORIZONTAL)
156                     label = StaticText(self, -1, opt[0] + ": ", 
157                                           size=wx.Size(90,35))
158                     style = wx.TE_PASSWORD if opt[0] == "password" else 0
159                     txt = TextCtrl(self, -1, str(default), size=wx.Size(200,-1), style=style)
160                     self.option[opt[0]] = txt
161                     self.fieldset[opt[0]].AddMany([label, 
162                                                    self.option[opt[0]]])
163                     if opt[0] == "file":
164                         file_opt = opt
165                         def open_file_dialog(evt):
166                             filter = ""
167                             if file_opt[3]:
168                                 filter = file_opt[3] + "|"
169                             filter += "All files (*.*)|*.*"                                    
170                             dialog = wx.FileDialog(None, style = wx.OPEN,
171                                                    wildcard = filter)
172                             if dialog.ShowModal() == wx.ID_OK:
173                                 self.option[file_opt[0]].SetValue(dialog.GetPath())
174                         self.browse = wx.Button(self, -1, "Choose...")
175                         self.fieldset[file_opt[0]].Add(self.browse)
176                         self.browse.Bind(wx.EVT_BUTTON, open_file_dialog)                        
177                     self.fieldset[opt[0]].Layout()
178                     self.fields.Add(self.fieldset[opt[0]])
179                 self.sizer.Add(self.fields)
180                 self.sizer.Layout()
181                 
182                 
183 class ConfirmPage(TitledPage):
184     """The final confirmation page."""
185     def __init__(self, parent, title, label):
186         TitledPage.__init__(self, parent, title, label)
187         self.fields = wx.BoxSizer(wx.VERTICAL)
188         self.parent = parent
189         
190     def Draw(self, evt):
191         if not evt.GetDirection(): return
192         
193         self.fields.Clear(True)
194         self.fields = wx.BoxSizer(wx.VERTICAL)
195         
196         self.values_dict = dict()
197         connect = self.parent.CONNECTION
198         for key in connect.option.keys():
199             self.values_dict[key] = str(connect.option[key].Value)
200         
201         try:
202             connect.engine.opts = self.values_dict
203             connect.engine.connect(force_reconnect=True)
204             message = '''<p><b>Success!</b>Your connection has been saved.</p>
205             <p>Click Finish to continue.</p>'''
206             save_connection(connect.engine.name, self.values_dict)
207             
208         except Exception as e:
209             message = message = '''<p><b>Error.</b>There was a problem with your
210             connection:</p><p>%s</p>
211             <p>Click Back to try again, or Cancel.</p>''' % e
212             
213             btn = self.parent.FindWindowById(wx.ID_FORWARD) 
214             if btn: btn.Disable()
215         
216         self.message = HtmlWindow(self)
217         self.message.SetSize((450,400))
218         self.message.SetHtml(message)
219         self.fields.Add(self.message, 1, wx.EXPAND)
220         self.sizer.Add(self.fields)
221         
222         self.sizer.Layout()
223
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/app/connect_wizard.py b/app/connect_wizard.py
--- a/app/connect_wizard.py
+++ b/app/connect_wizard.py
@@ -184,15 +184,11 @@
     """The final confirmation page."""
     def __init__(self, parent, title, label):
         TitledPage.__init__(self, parent, title, label)
-        self.fields = wx.BoxSizer(wx.VERTICAL)
         self.parent = parent
         
     def Draw(self, evt):
         if not evt.GetDirection(): return
         
-        self.fields.Clear(True)
-        self.fields = wx.BoxSizer(wx.VERTICAL)
-        
         self.values_dict = dict()
         connect = self.parent.CONNECTION
         for key in connect.option.keys():
@@ -201,12 +197,12 @@
         try:
             connect.engine.opts = self.values_dict
             connect.engine.connect(force_reconnect=True)
-            message = '''<p><b>Success!</b>Your connection has been saved.</p>
+            message = '''<p><b>Success!</b> Your connection has been saved.</p>
             <p>Click Finish to continue.</p>'''
             save_connection(connect.engine.name, self.values_dict)
             
         except Exception as e:
-            message = message = '''<p><b>Error.</b>There was a problem with your
+            message = message = '''<p><b>Error.</b> There was a problem with your
             connection:</p><p>%s</p>
             <p>Click Back to try again, or Cancel.</p>''' % e
             
@@ -216,7 +212,5 @@
         self.message = HtmlWindow(self)
         self.message.SetSize((450,400))
         self.message.SetHtml(message)
-        self.fields.Add(self.message, 1, wx.EXPAND)
-        self.sizer.Add(self.fields)
-        
+        self.sizer.Add(self.message, 1, wx.EXPAND)
         self.sizer.Layout()

{"golden_diff": "diff --git a/app/connect_wizard.py b/app/connect_wizard.py\n--- a/app/connect_wizard.py\n+++ b/app/connect_wizard.py\n@@ -184,15 +184,11 @@\n     \"\"\"The final confirmation page.\"\"\"\n     def __init__(self, parent, title, label):\n         TitledPage.__init__(self, parent, title, label)\n-        self.fields = wx.BoxSizer(wx.VERTICAL)\n         self.parent = parent\n         \n     def Draw(self, evt):\n         if not evt.GetDirection(): return\n         \n-        self.fields.Clear(True)\n-        self.fields = wx.BoxSizer(wx.VERTICAL)\n-        \n         self.values_dict = dict()\n         connect = self.parent.CONNECTION\n         for key in connect.option.keys():\n@@ -201,12 +197,12 @@\n         try:\n             connect.engine.opts = self.values_dict\n             connect.engine.connect(force_reconnect=True)\n-            message = '''<p><b>Success!</b>Your connection has been saved.</p>\n+            message = '''<p><b>Success!</b> Your connection has been saved.</p>\n             <p>Click Finish to continue.</p>'''\n             save_connection(connect.engine.name, self.values_dict)\n             \n         except Exception as e:\n-            message = message = '''<p><b>Error.</b>There was a problem with your\n+            message = message = '''<p><b>Error.</b> There was a problem with your\n             connection:</p><p>%s</p>\n             <p>Click Back to try again, or Cancel.</p>''' % e\n             \n@@ -216,7 +212,5 @@\n         self.message = HtmlWindow(self)\n         self.message.SetSize((450,400))\n         self.message.SetHtml(message)\n-        self.fields.Add(self.message, 1, wx.EXPAND)\n-        self.sizer.Add(self.fields)\n-        \n+        self.sizer.Add(self.message, 1, wx.EXPAND)\n         self.sizer.Layout()\n", "issue": "Final page of connection wizard reports nothing on Mac & Windows\nThe final page of the connection wizard is blank on both Mac & Windows. This happens regardless of success or failure and predates the recent changes to the GUI in #157.\n\n", "before_files": [{"content": "\"\"\"Connection setup wizard.\n\n\"\"\"\n\nimport os\nimport sys\nimport wx\nimport wx.html\nimport wx.wizard\nfrom retriever.lib.models import Engine\nfrom retriever.lib.tools import get_saved_connection, save_connection\nfrom retriever.app.controls import *\nfrom retriever.app.images import icon\n\nfrom retriever import VERSION\n\n\nclass ConnectWizard(wx.wizard.Wizard):\n    def __init__(self, lists, engine_list, selected=None):\n        wx.wizard.Wizard.__init__(self, None, -1, \"EcoData Retriever\")\n        \n        #self.SetIcon(icon.GetIcon())\n        \n        welcome = \"\"\"<h2>Connection Wizard</h2>\n        \n        <p>The EcoData Retriever downloads raw data files, stores them on your\n        computer, and imports the data into your own local database.</p>\n        <p>To begin, you'll need to set up your own database. Once you've done\n        that, this wizard will walk you through the steps to connect to your\n        database.</p>\n        <p>Supported database systems currently include:</p>\n        <ul>\"\"\"\n        \n        for db in engine_list:\n            welcome += \"<li>\" + db.name + \"</li>\" \n        \n        welcome += \"</ul>\"        \n        \n        self.pages = []\n        self.lists = lists\n        self.engine_list = engine_list\n        self.selected = selected\n        \n        self.pages.append(TitledPage(self, \"\", \"\"))\n        \n        self.pages.append(ChooseDbPage(self, \"Database\", \n                                       \"What kind of database are you using?\"))\n        \n        self.pages.append(ConnectPage(self, \n                                      \"Connection Info\", \n                                      \"\"))\n                                      \n        self.pages.append(ConfirmPage(self, \"Connection\", \"\"))\n\n        (self.TITLE, self.CHOOSEDB, \n         self.CONNECTION, self.CONFIRM) = [self.pages[i] \n                                           for i in range(len(self.pages))]\n        \n        self.TITLE.welcome = HtmlWindow(self.TITLE)\n        self.TITLE.welcome.SetSize((450,400))\n        self.TITLE.welcome.SetHtml(welcome)\n        self.TITLE.sizer.Add(self.TITLE.welcome, 1, wx.EXPAND)\n             \n        self.CHOOSEDB.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.CONNECTION.Draw)\n        self.CONNECTION.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.CONFIRM.Draw)\n        self.CONFIRM.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.CONNECTION.Draw)\n        \n        for i in range(len(self.pages) - 1):\n            wx.wizard.WizardPageSimple_Chain(self.pages[i], self.pages[i + 1])\n        \n        for page in self.pages:\n            self.FitToPage(page)\n        \n    \n    def check_for_updates(self):\n        reload(retriever)\n\n\nclass ChooseDbPage(TitledPage):\n    def __init__(self, parent, title, label):\n        TitledPage.__init__(self, parent, title, label)\n        engine_list = parent.engine_list\n        \n        dblist = ListBox(self, -1, \n                         choices=[db.name for db in engine_list], \n                         style=wx.LB_SINGLE,\n                         size=(-1,150))\n        self.dblist = dblist\n        if parent.selected:\n            index = 0\n            for i in range(len(engine_list)):\n                if engine_list[i].name == parent.selected:\n                    index = i                                    \n            self.dblist.SetSelection(index)\n        else:\n            self.dblist.SetSelection(0)\n        self.sizer.Add(self.dblist, -1, wx.EXPAND)\n\n        #TODO: This is a hack to force the wizard to be large enough to not hide\n        #the Choose button on the Connect Page when the engine has a file\n        #attribute. This should be fixed properly by figuring out how to make wx\n        #work with the fact that the connect page has varying fields depending\n        #on the engine.\n        longspace = StaticText(self, -1, \"\", wx.Size(375, -1))\n        self.sizer.Add(longspace, -1)\n        \n    def dirbtn_click(self, evt):\n        dialog = wx.DirDialog(None, message=\"Choose a directory to \" +\n                                \"download your data files.\")            \n        if dialog.ShowModal() == wx.ID_OK:            \n           self.raw_data_dir.SetValue(dialog.GetPath())            \n        else:\n           pass\n        dialog.Destroy()\n                    \n\nclass ConnectPage(TitledPage):\n    \"\"\"The connection info page.\"\"\"\n    def __init__(self, parent, title, label):\n        TitledPage.__init__(self, parent, title, label)\n        self.option = dict()\n        self.sel = None\n        self.fields = wx.BoxSizer(wx.VERTICAL)\n        self.parent = parent\n        \n    def Draw(self, evt):\n        \"\"\"When the page is drawn, it may need to update its fields if \n        the selected database has changed.\"\"\"\n        \n        if not evt.GetDirection():\n            btn = self.parent.FindWindowById(wx.ID_FORWARD) \n            if btn: btn.Enable()\n        \n        if len(self.Parent.CHOOSEDB.dblist.GetStringSelection()) == 0 and evt.Direction:\n            evt.Veto()                  \n        else:\n            if self.sel != self.Parent.CHOOSEDB.dblist.GetStringSelection():\n                self.sel = self.Parent.CHOOSEDB.dblist.GetStringSelection()\n                self.engine = Engine()\n                for db in self.Parent.engine_list:\n                    if db.name == self.sel:\n                        self.engine = db\n                self.fields.Clear(True)     \n                self.fields = wx.BoxSizer(wx.VERTICAL)\n                if self.engine.instructions:\n                    self.fields.Add(StaticText(self, -1, '\\n' + self.engine.instructions + '\\n\\n'))\n                self.fieldset = dict()\n                self.option = dict()\n                saved_opts = get_saved_connection(self.engine.name)\n                for opt in self.engine.required_opts:\n                    if opt[0] in saved_opts.keys():\n                        default = saved_opts[opt[0]]\n                    else:\n                        default = opt[2]\n                    self.fieldset[opt[0]] = wx.BoxSizer(wx.HORIZONTAL)\n                    label = StaticText(self, -1, opt[0] + \": \", \n                                          size=wx.Size(90,35))\n                    style = wx.TE_PASSWORD if opt[0] == \"password\" else 0\n                    txt = TextCtrl(self, -1, str(default), size=wx.Size(200,-1), style=style)\n                    self.option[opt[0]] = txt\n                    self.fieldset[opt[0]].AddMany([label, \n                                                   self.option[opt[0]]])\n                    if opt[0] == \"file\":\n                        file_opt = opt\n                        def open_file_dialog(evt):\n                            filter = \"\"\n                            if file_opt[3]:\n                                filter = file_opt[3] + \"|\"\n                            filter += \"All files (*.*)|*.*\"                                    \n                            dialog = wx.FileDialog(None, style = wx.OPEN,\n                                                   wildcard = filter)\n                            if dialog.ShowModal() == wx.ID_OK:\n                                self.option[file_opt[0]].SetValue(dialog.GetPath())\n                        self.browse = wx.Button(self, -1, \"Choose...\")\n                        self.fieldset[file_opt[0]].Add(self.browse)\n                        self.browse.Bind(wx.EVT_BUTTON, open_file_dialog)                        \n                    self.fieldset[opt[0]].Layout()\n                    self.fields.Add(self.fieldset[opt[0]])\n                self.sizer.Add(self.fields)\n                self.sizer.Layout()\n                \n                \nclass ConfirmPage(TitledPage):\n    \"\"\"The final confirmation page.\"\"\"\n    def __init__(self, parent, title, label):\n        TitledPage.__init__(self, parent, title, label)\n        self.fields = wx.BoxSizer(wx.VERTICAL)\n        self.parent = parent\n        \n    def Draw(self, evt):\n        if not evt.GetDirection(): return\n        \n        self.fields.Clear(True)\n        self.fields = wx.BoxSizer(wx.VERTICAL)\n        \n        self.values_dict = dict()\n        connect = self.parent.CONNECTION\n        for key in connect.option.keys():\n            self.values_dict[key] = str(connect.option[key].Value)\n        \n        try:\n            connect.engine.opts = self.values_dict\n            connect.engine.connect(force_reconnect=True)\n            message = '''<p><b>Success!</b>Your connection has been saved.</p>\n            <p>Click Finish to continue.</p>'''\n            save_connection(connect.engine.name, self.values_dict)\n            \n        except Exception as e:\n            message = message = '''<p><b>Error.</b>There was a problem with your\n            connection:</p><p>%s</p>\n            <p>Click Back to try again, or Cancel.</p>''' % e\n            \n            btn = self.parent.FindWindowById(wx.ID_FORWARD) \n            if btn: btn.Disable()\n        \n        self.message = HtmlWindow(self)\n        self.message.SetSize((450,400))\n        self.message.SetHtml(message)\n        self.fields.Add(self.message, 1, wx.EXPAND)\n        self.sizer.Add(self.fields)\n        \n        self.sizer.Layout()\n", "path": "app/connect_wizard.py"}], "after_files": [{"content": "\"\"\"Connection setup wizard.\n\n\"\"\"\n\nimport os\nimport sys\nimport wx\nimport wx.html\nimport wx.wizard\nfrom retriever.lib.models import Engine\nfrom retriever.lib.tools import get_saved_connection, save_connection\nfrom retriever.app.controls import *\nfrom retriever.app.images import icon\n\nfrom retriever import VERSION\n\n\nclass ConnectWizard(wx.wizard.Wizard):\n    def __init__(self, lists, engine_list, selected=None):\n        wx.wizard.Wizard.__init__(self, None, -1, \"EcoData Retriever\")\n        \n        #self.SetIcon(icon.GetIcon())\n        \n        welcome = \"\"\"<h2>Connection Wizard</h2>\n        \n        <p>The EcoData Retriever downloads raw data files, stores them on your\n        computer, and imports the data into your own local database.</p>\n        <p>To begin, you'll need to set up your own database. Once you've done\n        that, this wizard will walk you through the steps to connect to your\n        database.</p>\n        <p>Supported database systems currently include:</p>\n        <ul>\"\"\"\n        \n        for db in engine_list:\n            welcome += \"<li>\" + db.name + \"</li>\" \n        \n        welcome += \"</ul>\"        \n        \n        self.pages = []\n        self.lists = lists\n        self.engine_list = engine_list\n        self.selected = selected\n        \n        self.pages.append(TitledPage(self, \"\", \"\"))\n        \n        self.pages.append(ChooseDbPage(self, \"Database\", \n                                       \"What kind of database are you using?\"))\n        \n        self.pages.append(ConnectPage(self, \n                                      \"Connection Info\", \n                                      \"\"))\n                                      \n        self.pages.append(ConfirmPage(self, \"Connection\", \"\"))\n\n        (self.TITLE, self.CHOOSEDB, \n         self.CONNECTION, self.CONFIRM) = [self.pages[i] \n                                           for i in range(len(self.pages))]\n        \n        self.TITLE.welcome = HtmlWindow(self.TITLE)\n        self.TITLE.welcome.SetSize((450,400))\n        self.TITLE.welcome.SetHtml(welcome)\n        self.TITLE.sizer.Add(self.TITLE.welcome, 1, wx.EXPAND)\n             \n        self.CHOOSEDB.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.CONNECTION.Draw)\n        self.CONNECTION.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.CONFIRM.Draw)\n        self.CONFIRM.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.CONNECTION.Draw)\n        \n        for i in range(len(self.pages) - 1):\n            wx.wizard.WizardPageSimple_Chain(self.pages[i], self.pages[i + 1])\n        \n        for page in self.pages:\n            self.FitToPage(page)\n        \n    \n    def check_for_updates(self):\n        reload(retriever)\n\n\nclass ChooseDbPage(TitledPage):\n    def __init__(self, parent, title, label):\n        TitledPage.__init__(self, parent, title, label)\n        engine_list = parent.engine_list\n        \n        dblist = ListBox(self, -1, \n                         choices=[db.name for db in engine_list], \n                         style=wx.LB_SINGLE,\n                         size=(-1,150))\n        self.dblist = dblist\n        if parent.selected:\n            index = 0\n            for i in range(len(engine_list)):\n                if engine_list[i].name == parent.selected:\n                    index = i                                    \n            self.dblist.SetSelection(index)\n        else:\n            self.dblist.SetSelection(0)\n        self.sizer.Add(self.dblist, -1, wx.EXPAND)\n\n        #TODO: This is a hack to force the wizard to be large enough to not hide\n        #the Choose button on the Connect Page when the engine has a file\n        #attribute. This should be fixed properly by figuring out how to make wx\n        #work with the fact that the connect page has varying fields depending\n        #on the engine.\n        longspace = StaticText(self, -1, \"\", wx.Size(375, -1))\n        self.sizer.Add(longspace, -1)\n        \n    def dirbtn_click(self, evt):\n        dialog = wx.DirDialog(None, message=\"Choose a directory to \" +\n                                \"download your data files.\")            \n        if dialog.ShowModal() == wx.ID_OK:            \n           self.raw_data_dir.SetValue(dialog.GetPath())            \n        else:\n           pass\n        dialog.Destroy()\n                    \n\nclass ConnectPage(TitledPage):\n    \"\"\"The connection info page.\"\"\"\n    def __init__(self, parent, title, label):\n        TitledPage.__init__(self, parent, title, label)\n        self.option = dict()\n        self.sel = None\n        self.fields = wx.BoxSizer(wx.VERTICAL)\n        self.parent = parent\n        \n    def Draw(self, evt):\n        \"\"\"When the page is drawn, it may need to update its fields if \n        the selected database has changed.\"\"\"\n        \n        if not evt.GetDirection():\n            btn = self.parent.FindWindowById(wx.ID_FORWARD) \n            if btn: btn.Enable()\n        \n        if len(self.Parent.CHOOSEDB.dblist.GetStringSelection()) == 0 and evt.Direction:\n            evt.Veto()                  \n        else:\n            if self.sel != self.Parent.CHOOSEDB.dblist.GetStringSelection():\n                self.sel = self.Parent.CHOOSEDB.dblist.GetStringSelection()\n                self.engine = Engine()\n                for db in self.Parent.engine_list:\n                    if db.name == self.sel:\n                        self.engine = db\n                self.fields.Clear(True)     \n                self.fields = wx.BoxSizer(wx.VERTICAL)\n                if self.engine.instructions:\n                    self.fields.Add(StaticText(self, -1, '\\n' + self.engine.instructions + '\\n\\n'))\n                self.fieldset = dict()\n                self.option = dict()\n                saved_opts = get_saved_connection(self.engine.name)\n                for opt in self.engine.required_opts:\n                    if opt[0] in saved_opts.keys():\n                        default = saved_opts[opt[0]]\n                    else:\n                        default = opt[2]\n                    self.fieldset[opt[0]] = wx.BoxSizer(wx.HORIZONTAL)\n                    label = StaticText(self, -1, opt[0] + \": \", \n                                          size=wx.Size(90,35))\n                    style = wx.TE_PASSWORD if opt[0] == \"password\" else 0\n                    txt = TextCtrl(self, -1, str(default), size=wx.Size(200,-1), style=style)\n                    self.option[opt[0]] = txt\n                    self.fieldset[opt[0]].AddMany([label, \n                                                   self.option[opt[0]]])\n                    if opt[0] == \"file\":\n                        file_opt = opt\n                        def open_file_dialog(evt):\n                            filter = \"\"\n                            if file_opt[3]:\n                                filter = file_opt[3] + \"|\"\n                            filter += \"All files (*.*)|*.*\"                                    \n                            dialog = wx.FileDialog(None, style = wx.OPEN,\n                                                   wildcard = filter)\n                            if dialog.ShowModal() == wx.ID_OK:\n                                self.option[file_opt[0]].SetValue(dialog.GetPath())\n                        self.browse = wx.Button(self, -1, \"Choose...\")\n                        self.fieldset[file_opt[0]].Add(self.browse)\n                        self.browse.Bind(wx.EVT_BUTTON, open_file_dialog)                        \n                    self.fieldset[opt[0]].Layout()\n                    self.fields.Add(self.fieldset[opt[0]])\n                self.sizer.Add(self.fields)\n                self.sizer.Layout()\n                \n                \nclass ConfirmPage(TitledPage):\n    \"\"\"The final confirmation page.\"\"\"\n    def __init__(self, parent, title, label):\n        TitledPage.__init__(self, parent, title, label)\n        self.parent = parent\n        \n    def Draw(self, evt):\n        if not evt.GetDirection(): return\n        \n        self.values_dict = dict()\n        connect = self.parent.CONNECTION\n        for key in connect.option.keys():\n            self.values_dict[key] = str(connect.option[key].Value)\n        \n        try:\n            connect.engine.opts = self.values_dict\n            connect.engine.connect(force_reconnect=True)\n            message = '''<p><b>Success!</b> Your connection has been saved.</p>\n            <p>Click Finish to continue.</p>'''\n            save_connection(connect.engine.name, self.values_dict)\n            \n        except Exception as e:\n            message = message = '''<p><b>Error.</b> There was a problem with your\n            connection:</p><p>%s</p>\n            <p>Click Back to try again, or Cancel.</p>''' % e\n            \n            btn = self.parent.FindWindowById(wx.ID_FORWARD) \n            if btn: btn.Disable()\n        \n        self.message = HtmlWindow(self)\n        self.message.SetSize((450,400))\n        self.message.SetHtml(message)\n        self.sizer.Add(self.message, 1, wx.EXPAND)\n        self.sizer.Layout()\n", "path": "app/connect_wizard.py"}]}