def select_bandplan(self, parent_window): plans = ["None"] for shortname, details in self.plans.iteritems(): if self._config.get_bool(shortname, "bandplan"): plans.insert(0, details[0]) else: plans.append(details[0]) d = inputdialog.ChoiceDialog(plans, parent=parent_window, title="Choose Defaults") d.label.set_text( _("Band plans define default channel settings for " "frequencies in a region. Choose a band plan " "or None for completely manual channel " "settings.")) d.label.set_line_wrap(True) r = d.run() if r == gtk.RESPONSE_OK: selection = d.choice.get_active_text() for shortname, details in self.plans.iteritems(): self._config.set_bool(shortname, selection == details[0], "bandplan") if selection == details[0]: LOG.info("Selected band plan %s: %s" % (shortname, selection)) d.destroy()
def choose_sub_device(self, radio): devices = radio.get_sub_devices() choices = [x.VARIANT for x in devices] d = inputdialog.ChoiceDialog(choices) text = _("The {vendor} {model} has multiple independent sub-devices") d.label.set_text(text.format(vendor=radio.VENDOR, model=radio.MODEL) + os.linesep + _("Choose one to import from:")) r = d.run() chosen = d.choice.get_active_text() d.destroy() if r == gtk.RESPONSE_CANCEL: raise Exception(_("Cancelled")) for d in devices: if d.VARIANT == chosen: return d raise Exception(_("Internal Error"))