From: Alexander Vasarab Date: Mon, 29 Jun 2020 17:07:06 +0000 (-0700) Subject: Convert travel mode/units from combobox to radios X-Git-Tag: v2.2.0^2~7 X-Git-Url: https://wylark.com/src/munter.git/commitdiff_plain/b3b7fa789cb055b75ff9fa33d5b49dced19df4f0?ds=inline;hp=363bc8c5115d6714444d1660ab4c386b442deda2 Convert travel mode/units from combobox to radios --- diff --git a/munter/gui.py b/munter/gui.py index c8e4130..141a24c 100644 --- a/munter/gui.py +++ b/munter/gui.py @@ -62,8 +62,12 @@ class MainFrame(wx.Frame): self.st_units = wx.StaticText(self.pnl, label="Units: ") cb_units_choices = ['imperial', 'metric'] cb_units_default = 'imperial' - self.cb_units = wx.ComboBox(self.pnl, choices=cb_units_choices, - value=cb_units_default, style=wx.CB_READONLY) + + self.cb_units = [] + for choice in range(len(cb_units_choices)): + label = cb_units_choices[choice] + style = wx.RB_GROUP if not choice else 0 + self.cb_units.append(wx.RadioButton(self.pnl, label=label, style=style)) # static text self.st_mtc = wx.StaticText(self.pnl, label="0h", @@ -78,7 +82,9 @@ class MainFrame(wx.Frame): self.pnl.Bind(wx.EVT_TEXT, self.update_elevation, self.te_elevation) self.cb_fitness.Bind(wx.EVT_COMBOBOX, self.update_fitness) self.cb_travel_mode.Bind(wx.EVT_COMBOBOX, self.update_travel_mode) - self.cb_units.Bind(wx.EVT_COMBOBOX, self.update_units) + + for cb in self.cb_units: + cb.Bind(wx.EVT_RADIOBUTTON, self.update_units) # buttons b_clear = wx.Button(self.pnl, wx.NewId(), '&Clear', (-1, -1), @@ -112,7 +118,8 @@ class MainFrame(wx.Frame): hsizer_units = wx.BoxSizer(wx.HORIZONTAL) hsizer_units.Add(self.st_units, 0, wx.RIGHT, b) - hsizer_units.Add(self.cb_units, 1, wx.GROW, b) + for cb in range(len(self.cb_units)): + hsizer_units.Add(self.cb_units[cb], cb + 1, wx.GROW, b) hsizer_units.SetItemMinSize(self.st_units, (w, -1)) hsizer_mtc = wx.BoxSizer(wx.HORIZONTAL) @@ -162,7 +169,8 @@ class MainFrame(wx.Frame): self.update_mtc() def update_units(self, event): - value = self.cb_units.GetValue() + rb = event.GetEventObject() + value = rb.GetLabel() if value: self.props['units'] = value self.update_mtc()