We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Choose button missing on Database Connection page for Windows & OS X
When selecting a database connection that has an associated file (i.e., sqlite and Access) the GUI should allow you to navigate to the file by clicking on the `Choose` button. This works fine on Ubuntu:

![screenshot from 2014-01-21 17 01 53](https://f.cloud.github.com/assets/744427/1968743/aa25e82a-82e7-11e3-9762-577c0a8009e5.png)

But this button is missing on the current builds on Windows and OS X. The Database Connection page also generally looks narrower on Windows and OS X.

From Windows:
![win_dbconnect](https://f.cloud.github.com/assets/744427/1968800/c2414480-82e8-11e3-8ce4-524940122130.PNG)


--- 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     def dirbtn_click(self, evt):
100         dialog = wx.DirDialog(None, message="Choose a directory to " +
101                                 "download your data files.")            
102         if dialog.ShowModal() == wx.ID_OK:            
103            self.raw_data_dir.SetValue(dialog.GetPath())            
104         else:
105            pass
106         dialog.Destroy()
107                     
108 
109 class ConnectPage(TitledPage):
110     """The connection info page."""
111     def __init__(self, parent, title, label):
112         TitledPage.__init__(self, parent, title, label)
113         self.option = dict()
114         self.sel = None
115         self.fields = wx.BoxSizer(wx.VERTICAL)
116         self.parent = parent
117         
118     def Draw(self, evt):
119         """When the page is drawn, it may need to update its fields if 
120         the selected database has changed."""
121         
122         if not evt.GetDirection():
123             btn = self.parent.FindWindowById(wx.ID_FORWARD) 
124             if btn: btn.Enable()
125         
126         if len(self.Parent.CHOOSEDB.dblist.GetStringSelection()) == 0 and evt.Direction:
127             evt.Veto()                  
128         else:
129             if self.sel != self.Parent.CHOOSEDB.dblist.GetStringSelection():
130                 self.sel = self.Parent.CHOOSEDB.dblist.GetStringSelection()
131                 self.engine = Engine()
132                 for db in self.Parent.engine_list:
133                     if db.name == self.sel:
134                         self.engine = db
135                 self.fields.Clear(True)     
136                 self.fields = wx.BoxSizer(wx.VERTICAL)
137                 if self.engine.instructions:
138                     self.fields.Add(StaticText(self, -1, '\n' + self.engine.instructions + '\n\n'))
139                 self.fieldset = dict()
140                 self.option = dict()
141                 saved_opts = get_saved_connection(self.engine.name)
142                 for opt in self.engine.required_opts:
143                     if opt[0] in saved_opts.keys():
144                         default = saved_opts[opt[0]]
145                     else:
146                         default = opt[2]
147                     self.fieldset[opt[0]] = wx.BoxSizer(wx.HORIZONTAL)
148                     label = StaticText(self, -1, opt[0] + ": ", 
149                                           size=wx.Size(90,35))
150                     if opt[0] == "password":
151                         txt = TextCtrl(self, -1, 
152                                           str(default), 
153                                           size=wx.Size(200,-1), 
154                                           style=wx.TE_PASSWORD)
155                     else:
156                         txt = TextCtrl(self, -1, str(default),
157                                           size=wx.Size(200,-1))
158                     self.option[opt[0]] = txt
159                     self.fieldset[opt[0]].AddMany([label, 
160                                                    self.option[opt[0]]])
161                     if opt[0] == "file":
162                         file_opt = opt
163                         def open_file_dialog(evt):
164                             filter = ""
165                             if file_opt[3]:
166                                 filter = file_opt[3] + "|"
167                             filter += "All files (*.*)|*.*"                                    
168                             dialog = wx.FileDialog(None, style = wx.OPEN,
169                                                    wildcard = filter)
170                             if dialog.ShowModal() == wx.ID_OK:
171                                 self.option[file_opt[0]].SetValue(dialog.GetPath())
172                         self.browse = wx.Button(self, -1, "Choose...")
173                         self.fieldset[file_opt[0]].Add(self.browse)
174                         self.browse.Bind(wx.EVT_BUTTON, open_file_dialog)                        
175                     self.fieldset[opt[0]].Layout()
176                     self.fields.Add(self.fieldset[opt[0]])
177                 self.sizer.Add(self.fields)
178                 self.sizer.Layout()
179                 
180                 
181 class ConfirmPage(TitledPage):
182     """The final confirmation page."""
183     def __init__(self, parent, title, label):
184         TitledPage.__init__(self, parent, title, label)
185         self.fields = wx.BoxSizer(wx.VERTICAL)
186         self.parent = parent
187         
188     def Draw(self, evt):
189         if not evt.GetDirection(): return
190         
191         self.fields.Clear(True)
192         self.fields = wx.BoxSizer(wx.VERTICAL)
193         
194         self.values_dict = dict()
195         connect = self.parent.CONNECTION
196         for key in connect.option.keys():
197             self.values_dict[key] = str(connect.option[key].Value)
198         
199         try:
200             connect.engine.opts = self.values_dict
201             connect.engine.connect(force_reconnect=True)
202             message = '''<p><b>Success!</b>Your connection has been saved.</p>
203             <p>Click Finish to continue.</p>'''
204             save_connection(connect.engine.name, self.values_dict)
205             
206         except Exception as e:
207             message = message = '''<p><b>Error.</b>There was a problem with your
208             connection:</p><p>%s</p>
209             <p>Click Back to try again, or Cancel.</p>''' % e
210             
211             btn = self.parent.FindWindowById(wx.ID_FORWARD) 
212             if btn: btn.Disable()
213         
214         self.message = HtmlWindow(self)
215         self.message.SetSize((450,400))
216         self.message.SetHtml(message)
217         self.fields.Add(self.message, 1, wx.EXPAND)
218         self.sizer.Add(self.fields)
219         
220         self.sizer.Layout()
221
```
--- 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
@@ -95,6 +95,14 @@
         else:
             self.dblist.SetSelection(0)
         self.sizer.Add(self.dblist, -1, wx.EXPAND)
+
+        #TODO: This is a hack to force the wizard to be large enough to not hide
+        #the Choose button on the Connect Page when the engine has a file
+        #attribute. This should be fixed properly by figuring out how to make wx
+        #work with the fact that the connect page has varying fields depending
+        #on the engine.
+        longspace = StaticText(self, -1, "", wx.Size(375, -1))
+        self.sizer.Add(longspace, -1)
         
     def dirbtn_click(self, evt):
         dialog = wx.DirDialog(None, message="Choose a directory to " +
@@ -147,14 +155,8 @@
                     self.fieldset[opt[0]] = wx.BoxSizer(wx.HORIZONTAL)
                     label = StaticText(self, -1, opt[0] + ": ", 
                                           size=wx.Size(90,35))
-                    if opt[0] == "password":
-                        txt = TextCtrl(self, -1, 
-                                          str(default), 
-                                          size=wx.Size(200,-1), 
-                                          style=wx.TE_PASSWORD)
-                    else:
-                        txt = TextCtrl(self, -1, str(default),
-                                          size=wx.Size(200,-1))
+                    style = wx.TE_PASSWORD if opt[0] == "password" else 0
+                    txt = TextCtrl(self, -1, str(default), size=wx.Size(200,-1), style=style)
                     self.option[opt[0]] = txt
                     self.fieldset[opt[0]].AddMany([label, 
                                                    self.option[opt[0]]])

{"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@@ -95,6 +95,14 @@\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@@ -147,14 +155,8 @@\n                     self.fieldset[opt[0]] = wx.BoxSizer(wx.HORIZONTAL)\n                     label = StaticText(self, -1, opt[0] + \": \", \n                                           size=wx.Size(90,35))\n-                    if opt[0] == \"password\":\n-                        txt = TextCtrl(self, -1, \n-                                          str(default), \n-                                          size=wx.Size(200,-1), \n-                                          style=wx.TE_PASSWORD)\n-                    else:\n-                        txt = TextCtrl(self, -1, str(default),\n-                                          size=wx.Size(200,-1))\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", "issue": "Choose button missing on Database Connection page for Windows & OS X\nWhen selecting a database connection that has an associated file (i.e., sqlite and Access) the GUI should allow you to navigate to the file by clicking on the `Choose` button. This works fine on Ubuntu:\n\n![screenshot from 2014-01-21 17 01 53](https://f.cloud.github.com/assets/744427/1968743/aa25e82a-82e7-11e3-9762-577c0a8009e5.png)\n\nBut this button is missing on the current builds on Windows and OS X. The Database Connection page also generally looks narrower on Windows and OS X.\n\nFrom Windows:\n![win_dbconnect](https://f.cloud.github.com/assets/744427/1968800/c2414480-82e8-11e3-8ce4-524940122130.PNG)\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    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                    if opt[0] == \"password\":\n                        txt = TextCtrl(self, -1, \n                                          str(default), \n                                          size=wx.Size(200,-1), \n                                          style=wx.TE_PASSWORD)\n                    else:\n                        txt = TextCtrl(self, -1, str(default),\n                                          size=wx.Size(200,-1))\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.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"}]}