wxSerialConfigDialog: allow custom baudrates (ComboBox instead of Choice)
diff --git a/examples/wxSerialConfigDialog.py b/examples/wxSerialConfigDialog.py
index 44e2f79..bb79d87 100755
--- a/examples/wxSerialConfigDialog.py
+++ b/examples/wxSerialConfigDialog.py
@@ -42,7 +42,7 @@
         self.label_2 = wx.StaticText(self, -1, "Port")
         self.choice_port = wx.Choice(self, -1, choices=[])
         self.label_1 = wx.StaticText(self, -1, "Baudrate")
-        self.choice_baudrate = wx.Choice(self, -1, choices=["choice 1"])
+        self.combo_box_baudrate = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN)
         self.sizer_1_staticbox = wx.StaticBox(self, -1, "Basics")
         self.panel_format = wx.Panel(self, -1)
         self.label_3 = wx.StaticText(self.panel_format, -1, "Data Bits")
@@ -73,7 +73,6 @@
     def __set_properties(self):
         # begin wxGlade: SerialConfigDialog.__set_properties
         self.SetTitle("Serial Port Configuration")
-        self.choice_baudrate.SetSelection(0)
         self.choice_databits.SetSelection(0)
         self.choice_stopbits.SetSelection(0)
         self.choice_parity.SetSelection(0)
@@ -87,7 +86,7 @@
 
         if not self.show & SHOW_BAUDRATE:
             self.label_1.Hide()
-            self.choice_baudrate.Hide()
+            self.combo_box_baudrate.Hide()
         if not self.show & SHOW_FORMAT:
             self.panel_format.Hide()
         if not self.show & SHOW_TIMEOUT:
@@ -106,13 +105,17 @@
                 preferred_index = n
         self.choice_port.SetSelection(preferred_index)
         if self.show & SHOW_BAUDRATE:
+            preferred_index = None
             # fill in baud rates and select current setting
-            self.choice_baudrate.Clear()
+            self.combo_box_baudrate.Clear()
             for n, baudrate in enumerate(self.serial.BAUDRATES):
-                self.choice_baudrate.Append(str(baudrate))
+                self.combo_box_baudrate.Append(str(baudrate))
                 if self.serial.baudrate == baudrate:
-                    index = n
-            self.choice_baudrate.SetSelection(index)
+                    preferred_index = n
+            if preferred_index is not None:
+                self.combo_box_baudrate.SetSelection(preferred_index)
+            else:
+                self.combo_box_baudrate.SetValue(u'%d' % (self.serial.baudrate,))
         if self.show & SHOW_FORMAT:
             # fill in data bits and select current setting
             self.choice_databits.Clear()
@@ -167,7 +170,7 @@
         sizer_basics.Add(self.label_2, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 4)
         sizer_basics.Add(self.choice_port, 0, wx.EXPAND, 0)
         sizer_basics.Add(self.label_1, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 4)
-        sizer_basics.Add(self.choice_baudrate, 0, wx.EXPAND, 0)
+        sizer_basics.Add(self.combo_box_baudrate, 0, wx.EXPAND, 0)
         sizer_basics.AddGrowableCol(1)
         sizer_1.Add(sizer_basics, 0, wx.EXPAND, 0)
         sizer_2.Add(sizer_1, 0, wx.EXPAND, 0)
@@ -208,7 +211,19 @@
         success = True
         self.serial.port = self.ports[self.choice_port.GetSelection()]
         if self.show & SHOW_BAUDRATE:
-            self.serial.baudrate = self.serial.BAUDRATES[self.choice_baudrate.GetSelection()]
+            #~ self.serial.baudrate = self.serial.BAUDRATES[self.combo_box_baudrate.GetSelection()]
+            try:
+                b = int(self.combo_box_baudrate.GetValue())
+            except ValueError:
+                with wx.MessageDialog(
+                        self,
+                        'Baudrate must be a numeric value',
+                        'Value Error',
+                        wx.OK | wx.ICON_ERROR) as dlg:
+                    dlg.ShowModal()
+                success = False
+            else:
+                self.serial.baudrate = b
         if self.show & SHOW_FORMAT:
             self.serial.bytesize = self.serial.BYTESIZES[self.choice_databits.GetSelection()]
             self.serial.stopbits = self.serial.STOPBITS[self.choice_stopbits.GetSelection()]
diff --git a/examples/wxSerialConfigDialog.wxg b/examples/wxSerialConfigDialog.wxg
index 8938479..5cde5c4 100644
--- a/examples/wxSerialConfigDialog.wxg
+++ b/examples/wxSerialConfigDialog.wxg
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<!-- generated by wxGlade 0.6.5 on Sat Sep 12 02:03:03 2015 -->
+<!-- generated by wxGlade 0.6.5 on Wed Oct 14 18:12:11 2015 -->
 
 <application path="wxSerialConfigDialog.py" name="app" class="MyApp" option="0" language="python" top_window="dialog_serial_cfg" encoding="ISO-8859-1" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.8" is_template="0" indent_amount="4" indent_symbol="space" source_extension=".cpp" header_extension=".h">
     <object class="SerialConfigDialog" name="dialog_serial_cfg" base="EditDialog">
@@ -56,10 +56,9 @@
                                 <flag>wxEXPAND</flag>
                                 <border>0</border>
                                 <option>0</option>
-                                <object class="wxChoice" name="choice_baudrate" base="EditChoice">
-                                    <selection>0</selection>
+                                <object class="wxComboBox" name="combo_box_baudrate" base="EditComboBox">
+                                    <selection>-1</selection>
                                     <choices>
-                                        <choice>choice 1</choice>
                                     </choices>
                                 </object>
                             </object>
@@ -235,6 +234,7 @@
                         <object class="wxButton" name="button_ok" base="EditButton">
                             <stockitem>OK</stockitem>
                             <default>1</default>
+                            <label>&amp;OK</label>
                         </object>
                     </object>
                     <object class="sizeritem">
@@ -242,6 +242,7 @@
                         <option>0</option>
                         <object class="wxButton" name="button_cancel" base="EditButton">
                             <stockitem>CANCEL</stockitem>
+                            <label>&amp;Cancel</label>
                         </object>
                     </object>
                 </object>