예제 #1
0
def prefs_changed(cmdr, is_beta):
    this.distances = list()
    for settingsUiElement in this.settingsUiElements:
        systemText = settingsUiElement.systemEntry.get()
        xText = settingsUiElement.xEntry.get()
        yText = settingsUiElement.yEntry.get()
        zText = settingsUiElement.zEntry.get()
        if systemText and xText and yText and zText:
            try:
                d = dict()
                d["system"] = systemText.strip()
                d["x"] = Locale.numberFromString(xText.strip())
                d["y"] = Locale.numberFromString(yText.strip())
                d["z"] = Locale.numberFromString(zText.strip())
                this.distances.append(d)
            except Exception as e:  # error while parsing the numbers
                print(e)
                sys.stderr.write(
                    "DistanceCalc: Error while parsing the coordinates for {0}"
                    .format(systemText.strip()))
                continue
    config.set("DistanceCalc", json.dumps(this.distances))

    settings = this.travelledTotalOption.get() | (
        this.travelledSessionOption.get() << 1) | (
            this.travelledSessionSelected.get() << 2)
    config.set("DistanceCalc_options", settings)

    updateMainUi()
    updateDistances()
예제 #2
0
def prefs_changed():
    this.distances = list()
    for (system, x, y, z) in this.settingUiEntries:
        systemText = system.get()
        xText = x.get()
        yText = y.get()
        zText = z.get()
        if systemText and xText and yText and zText:
            try:
                d = dict()
                d["system"] = systemText.strip()
                d["x"] = Locale.numberFromString(xText.strip())
                d["y"] = Locale.numberFromString(yText.strip())
                d["z"] = Locale.numberFromString(zText.strip())
                this.distances.append(d)
            except:  # error while parsing the numbers
                sys.stderr.write(
                    "DistanceCalc: Error while parsing the coordinates for {0}"
                    .format(systemText.strip()))
                continue
    config.set("DistanceCalc", json.dumps(this.distances))

    settings = this.travelledTotalOption.get() | (
        this.travelledSessionOption.get() << 1) | (
            this.travelledSessionSelected.get() << 2)
    config.set("DistanceCalc_options", settings)

    updateUi()
    updateDistances()
예제 #3
0
def validate(action, index, value_if_allowed, prior_value, text,
             validation_type, trigger_type, widget_name):
    if value_if_allowed == "-" or value_if_allowed == "":
        return True
    elif text in "0123456789.," or text == value_if_allowed:
        try:
            t = type(Locale.numberFromString(value_if_allowed))
            if t is float or t is int:
                return True
        except ValueError:
            return False
    return False