Пример #1
0
    def __init__(self):
        QSTEditWidget.__init__(self, False, 2)

        lab = gtk.Label(_("Choose a station whose position will be sent"))
        lab.show()
        self.pack_start(lab, 1, 1, 1)

        hbox = gtk.HBox(False, 10)

        # This is really ugly, but to fix it requires more work
        self.__sources = mainapp.get_mainapp().map.get_map_sources()
        sources = [x.get_name() for x in self.__sources]
        self.__group = miscwidgets.make_choice(sources,
                                               False,
                                               _("Stations"))
        self.__group.show()
        hbox.pack_start(self.__group, 0, 0, 0)

        self.__station = miscwidgets.make_choice([], False)
        self.__station.show()
        hbox.pack_start(self.__station, 0, 0, 0)

        self.__group.connect("changed", self.ev_group_sel, self.__station)
        self.ev_group_sel(self.__group, self.__station)

        hbox.show()
        self.pack_start(hbox, 0, 0, 0)
Пример #2
0
    def __init__(self):
        QSTEditWidget.__init__(self, False, 2)

        lab = gtk.Label(_("Choose a station whose position will be sent"))
        lab.show()
        self.pack_start(lab, 1, 1, 1)

        hbox = gtk.HBox(False, 10)

        # This is really ugly, but to fix it requires more work
        self.__sources = mainapp.get_mainapp().map.get_map_sources()
        sources = [x.get_name() for x in self.__sources]
        self.__group = miscwidgets.make_choice(sources,
                                               False,
                                               _("Stations"))
        self.__group.show()
        hbox.pack_start(self.__group, 0, 0, 0)

        self.__station = miscwidgets.make_choice([], False)
        self.__station.show()
        hbox.pack_start(self.__station, 0, 0, 0)

        self.__group.connect("changed", self.ev_group_sel, self.__station)
        self.ev_group_sel(self.__group, self.__station)

        hbox.show()
        self.pack_start(hbox, 0, 0, 0)
Пример #3
0
    def _make_controls(self):
        hbox = gtk.HBox(False, 5)

        self._type = make_choice(self._types.keys(), False, default=_("Text"))
        self._type.set_size_request(100, -1)
        self._type.show()
        self._type.connect("changed", self._select_type)
        hbox.pack_start(self._type, 0, 0, 0)

        lab = gtk.Label(_("every"))
        lab.show()
        hbox.pack_start(lab, 0, 0 , 0)

        intervals = ["1", "5", "10", "20", "30", "60", ":30", ":15"]
        self._freq = make_choice(intervals, True, default="60")
        self._freq.set_size_request(75, -1)
        self._freq.show()
        hbox.pack_start(self._freq, 0, 0, 0)

        lab = gtk.Label(_("minutes on port"))
        lab.show()
        hbox.pack_start(lab, 0, 0, 0)

        self._port = make_choice([_("Current"), _("All")], False,
                                 default="Current")
        self._port.show()
        hbox.pack_start(self._port, 0, 0, 0)

        hbox.show()
        return hbox
Пример #4
0
    def _make_controls(self):
        hbox = gtk.HBox(False, 5)

        self._type = make_choice(self._types.keys(), False, default=_("Text"))
        self._type.set_size_request(100, -1)
        self._type.show()
        self._type.connect("changed", self._select_type)
        hbox.pack_start(self._type, 0, 0, 0)

        lab = gtk.Label(_("every"))
        lab.show()
        hbox.pack_start(lab, 0, 0 , 0)

        intervals = ["1", "5", "10", "20", "30", "60", ":30", ":15"]
        self._freq = make_choice(intervals, True, default="60")
        self._freq.set_size_request(75, -1)
        self._freq.show()
        hbox.pack_start(self._freq, 0, 0, 0)

        lab = gtk.Label(_("minutes on port"))
        lab.show()
        hbox.pack_start(lab, 0, 0, 0)

        self._port = make_choice([_("Current"), _("All")], False,
                                 default="Current")
        self._port.show()
        hbox.pack_start(self._port, 0, 0, 0)

        hbox.show()
        return hbox
Пример #5
0
    def build_data(self):
        vbox = gtk.VBox(False, 2)

        baud_rates = [
            "300", "1200", "4800", "9600", "19200", "38400", "115200"
        ]

        vbox.pack_start(self.make_sb("port", make_choice([])), 0, 0, 0)
        vbox.pack_start(self.make_sb("rate", make_choice(baud_rates, False)),
                        0, 0, 0)

        vbox.pack_start(self.make_sb("autoreceive", self.make_bool()), 0, 0, 0)

        fb = miscwidgets.FilenameBox(find_dir=True)
        vbox.pack_start(self.make_sb("download_dir", fb), 0, 0, 0)

        fb = miscwidgets.FilenameBox(find_dir=True)
        vbox.pack_start(self.make_sb("mapdir", fb), 0, 0, 0)

        vbox.pack_start(
            self.make_sb("ddt_block_size", self.make_spin(128, 128, 4096, 0)),
            0, 0, 0)
        vbox.pack_start(
            self.make_sb("ddt_block_outlimit", self.make_spin(1, 1, 32, 0)), 0,
            0, 0)
        vbox.pack_start(self.make_sb("gpsport", make_choice([])), 0, 0, 0)
        vbox.pack_start(self.make_sb("gpsenabled", self.make_bool()), 0, 0, 0)
        vbox.pack_start(
            self.make_sb("gpsportspeed", make_choice(baud_rates, False)), 0, 0,
            0)
        vbox.pack_start(self.make_sb("aprssymtab", gtk.Entry(1)), 0, 0, 0)
        vbox.pack_start(self.make_sb("aprssymbol", gtk.Entry(1)), 0, 0, 0)
        vbox.pack_start(self.make_sb("compatmode", self.make_bool()), 0, 0, 0)
        vbox.pack_start(self.make_sb("pipelinexfers", self.make_bool()), 0, 0,
                        0)
        vbox.pack_start(
            self.make_sb("warmup_length", self.make_spin(8, 0, 128, 0)), 0, 0,
            0)
        vbox.pack_start(
            self.make_sb("warmup_timeout", self.make_spin(1, 0, 128, 0)), 0, 0,
            0)
        vbox.pack_start(
            self.make_sb("force_delay", self.make_spin(1, 0, 128, 0)), 0, 0, 0)
        vbox.pack_start(self.make_sb("sniff_packets", self.make_bool()), 0, 0,
                        0)

        vbox.show()
        return vbox
Пример #6
0
    def _setup_typesel(self, wtree):
        choice = miscwidgets.make_choice(SOURCE_TYPES.keys(), False, "Static")
        choice.show()
        box = wtree.get_widget("srcs_ctrlbox")
        box.pack_end(choice, 1, 1, 1)

        return choice
Пример #7
0
    def __init__(self, choices, **args):
        buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK,
                   gtk.RESPONSE_OK)
        gtk.Dialog.__init__(self, buttons=buttons, **args)

        self.set_default_response(gtk.RESPONSE_OK)
        self.set_alternative_button_order(
            [gtk.RESPONSE_OK, gtk.RESPONSE_CANCEL])

        self.label = gtk.Label()
        self.label.set_size_request(300, 100)
        self.label.set_alignment(0.0, 0.5)
        # pylint: disable-msg=E1101
        self.vbox.pack_start(self.label, 1, 1, 0)
        self.label.show()

        try:
            default = choices[0]
        except IndexError:
            default = None

        self.choice = make_choice(sorted(choices), self.editable, default)
        # pylint: disable-msg=E1101
        self.vbox.pack_start(self.choice, 1, 1, 0)
        self.choice.show()
Пример #8
0
    def __init__(self):
        gtk.Dialog.__init__(self,
                            title="Edit form element",
                            buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
                                     gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))

        self.entries = {}

        self.set_default_size(150, 150)

        self.vals = {
            "text": self.make_entry_editor("text"),
            "multiline": self.make_entry_editor("multiline"),
            "date": self.make_null_editor("date"),
            "time": self.make_null_editor("time"),
            "numeric": self.make_entry_editor("numeric"),
            "toggle": self.make_toggle_editor("toggle"),
            "choice": self.make_choice_editor("choice"),
            "multiselect": self.make_choice_editor("multiselect", False),
            "label": self.make_null_editor("label"),
        }

        self.type_sel = make_choice(self.vals.keys(), False, "text")
        self.type_sel.connect("changed", self.type_changed, None)
        self.type_sel.show()
        self.vals["text"].show()

        self.ts_frame = gtk.Frame("Field Type")
        self.ts_frame.show()
        self.ts_frame.add(self.type_sel)

        self.vbox.pack_start(self.ts_frame, 0, 0, 0)

        for t, w in self.vals.items():
            self.vbox.pack_start(w, 1, 1, 1)
Пример #9
0
    def _make_controls(self):
        hbox = gtk.HBox(False, 2)

        self._type = make_choice(self._types.keys(), False, default=_("Text"))
        self._type.set_size_request(100, -1)
        self._type.show()
        self._type.connect("changed", self._select_type)
        hbox.pack_start(self._type, 0, 0, 0)

        intervals = ["1", "5", "10", "20", "30", "60", ":30", ":15"]
        self._freq = make_choice(intervals, True, default="60")
        self._freq.set_size_request(75, -1)
        self._freq.show()
        hbox.pack_start(self._freq, 0, 0, 0)

        hbox.show()
        return hbox
Пример #10
0
    def _make_controls(self):
        hbox = gtk.HBox(False, 2)

        self._type = make_choice(self._types.keys(), False, default=_("Text"))
        self._type.set_size_request(100, -1)
        self._type.show()
        self._type.connect("changed", self._select_type)
        hbox.pack_start(self._type, 0, 0, 0)

        intervals = ["1", "5", "10", "20", "30", "60", ":30", ":15"]
        self._freq = make_choice(intervals, True, default="60")
        self._freq.set_size_request(75, -1)
        self._freq.show()
        hbox.pack_start(self._freq, 0, 0, 0)

        hbox.show()
        return hbox
Пример #11
0
    def _setup_typesel(self, wtree):
        choice = miscwidgets.make_choice(SOURCE_TYPES.keys(),
                                         False,
                                         "Static")
        choice.show()
        box = wtree.get_widget("srcs_ctrlbox")
        box.pack_end(choice, 1, 1, 1)

        return choice
Пример #12
0
def do_dprs_calculator(initial=""):
    def ev_sym_changed(iconsel, oversel, icons):
        oversel.set_sensitive(icons[iconsel.get_active()][1][0] == "\\")

    d = inputdialog.FieldDialog(title=_("DPRS message"))
    msg = gtk.Entry(13)

    overlays = [chr(x) for x in range(ord(" "), ord("_"))]

    cur = initial
    if cur and cur[-3] == "*" and cur[3] == " ":
        msg.set_text(cur[4:-3])
        dsym = cur[:2]
        deficn = gps.DPRS_TO_APRS.get(dsym, "/#")
        defovr = cur[2]
        if defovr not in overlays:
            print "Overlay %s not in list" % defovr
            defovr = " "
    else:
        deficn = "/#"
        defovr = " "

    icons = []
    for sym in sorted(gps.DPRS_TO_APRS.values()):
        icon = get_icon(sym)
        if icon:
            icons.append((icon, sym))
    iconsel = miscwidgets.make_pixbuf_choice(icons, deficn)

    oversel = miscwidgets.make_choice(overlays, False, defovr)
    iconsel.connect("changed", ev_sym_changed, oversel, icons)
    ev_sym_changed(iconsel, oversel, icons)

    d.add_field(_("Message"), msg)
    d.add_field(_("Icon"), iconsel)
    d.add_field(_("Overlay"), oversel)

    r = d.run()
    aicon = icons[iconsel.get_active()][1]
    mstr = msg.get_text().upper()
    over = oversel.get_active_text()
    d.destroy()
    if r != gtk.RESPONSE_OK:
        return

    dicon = gps.APRS_TO_DPRS[aicon]

    callsign = mainapp.get_mainapp().config.get("user", "callsign")
    string = "%s%s %s" % (dicon, over, mstr)

    check = gps.DPRS_checksum(callsign, string)

    return string + check
Пример #13
0
def do_dprs_calculator(initial=""):
    def ev_sym_changed(iconsel, oversel, icons):
        oversel.set_sensitive(icons[iconsel.get_active()][1][0] == "\\")

    d = inputdialog.FieldDialog(title=_("DPRS message"))
    msg = gtk.Entry(13)

    overlays = [chr(x) for x in range(ord(" "), ord("_"))]

    cur = initial
    if cur and cur[-3] == "*" and cur[3] == " ":
        msg.set_text(cur[4:-3])
        dsym = cur[:2]
        deficn = gps.DPRS_TO_APRS.get(dsym, "/#")
        defovr = cur[2]
        if defovr not in overlays:
            print "Overlay %s not in list" % defovr
            defovr = " "
    else:
        deficn = "/#"
        defovr = " "

    icons = []
    for sym in sorted(gps.DPRS_TO_APRS.values()):
        icon = get_icon(sym)
        if icon:
            icons.append((icon, sym))
    iconsel = miscwidgets.make_pixbuf_choice(icons, deficn)

    oversel = miscwidgets.make_choice(overlays, False, defovr)
    iconsel.connect("changed", ev_sym_changed, oversel, icons)
    ev_sym_changed(iconsel, oversel, icons)

    d.add_field(_("Message"), msg)
    d.add_field(_("Icon"), iconsel)
    d.add_field(_("Overlay"), oversel)

    r = d.run()
    aicon = icons[iconsel.get_active()][1]
    mstr = msg.get_text().upper()
    over = oversel.get_active_text()
    d.destroy()
    if r != gtk.RESPONSE_OK:
        return

    dicon = gps.APRS_TO_DPRS[aicon]

    callsign = mainapp.get_mainapp().config.get("user", "callsign")
    string = "%s%s %s" % (dicon, over, mstr)

    check = gps.DPRS_checksum(callsign, string)

    return string + check
Пример #14
0
    def build_ddt(self):
        vbox = gtk.VBox(False, 2)

        block_sizes = [str(pow(2, x)) for x in range(6, 13)]
        encodings = ddt.ENCODINGS.keys()

        vbox.pack_start(self.make_sb("compression", self.make_bool()), 0, 0, 0)
        vbox.pack_start(
            self.make_sb("encoding", make_choice(encodings, False)), 0, 0, 0)

        vbox.show()

        return vbox
Пример #15
0
    def __init__(self):
        QSTEditWidget.__init__(self)

        lab = gtk.Label(self.label_text)
        lab.show()
        self.pack_start(lab, 1, 1, 1)

        hbox = gtk.HBox(False, 2)
        hbox.show()
        self.pack_start(hbox, 0, 0, 0)
        
        self.__station = gtk.Entry()
        self.__station.show()
        hbox.pack_start(self.__station, 0, 0, 0)

        types = [_("Airport"), _("Personal")]
        self.__type = miscwidgets.make_choice(types, False, types[0])
        self.__type.show()
        hbox.pack_start(self.__type, 0, 0, 0)
Пример #16
0
    def __init__(self):
        QSTEditWidget.__init__(self)

        lab = gtk.Label(self.label_text)
        lab.show()
        self.pack_start(lab, 1, 1, 1)

        hbox = gtk.HBox(False, 2)
        hbox.show()
        self.pack_start(hbox, 0, 0, 0)
        
        self.__station = gtk.Entry()
        self.__station.show()
        hbox.pack_start(self.__station, 0, 0, 0)

        types = [_("Airport"), _("Personal")]
        self.__type = miscwidgets.make_choice(types, False, types[0])
        self.__type.show()
        hbox.pack_start(self.__type, 0, 0, 0)
Пример #17
0
    def make_field(self, caption, choices=None):
        box = gtk.HBox(False, 2)

        l = gtk.Label(caption)
        l.set_size_request(45, -1)
        l.show()

        if choices is not None:
            e = make_choice(choices, True)
        else:
            e = gtk.Entry()
        e.show()

        self.props[caption] = e

        box.pack_start(l, 0, 0, 0)
        box.pack_start(e, 1, 1, 1)
        box.show()

        return box
Пример #18
0
    def make_field(self, caption, choices=None):
        box = gtk.HBox(False, 2)

        l = gtk.Label(caption)
        l.set_size_request(45, -1)
        l.show()

        if choices is not None:
            e = make_choice(choices, True)
        else:
            e = gtk.Entry()
        e.show()

        self.props[caption] = e

        box.pack_start(l, 0, 0, 0)
        box.pack_start(e, 1, 1, 1)
        box.show()

        return box
Пример #19
0
    def __init__(self, choices, **args):
        buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)
        gtk.Dialog.__init__(self, buttons=buttons, **args)

        self.label = gtk.Label()
        self.label.set_size_request(300, 100)
        # pylint: disable-msg=E1101
        self.vbox.pack_start(self.label, 1, 1, 0)
        self.label.show()

        try:
            default = choices[0]
        except IndexError:
            default = None

        self.choice = make_choice(sorted(choices), self.editable, default)
        # pylint: disable-msg=E1101
        self.vbox.pack_start(self.choice, 1, 1, 0)
        self.choice.show()

        self.set_default_response(gtk.RESPONSE_OK)
Пример #20
0
def build_image_dialog(filename, image, dlgParent=None):
    d = inputdialog.FieldDialog(title="Send Image",
                                parent=dlgParent)

    def update():
        update_image(filename, d)

    d.add_field(_("Filename"), gtk.Label(os.path.basename(filename)))

    d.sizelabel = gtk.Label("--")
    d.add_field(_("Size"), d.sizelabel)

    d.size = miscwidgets.make_choice(sizes, False, sizes[1])
    d.size.connect("changed", lambda x: update())
    d.add_field(_("Resize to"), d.size)

    quality = gtk.HScale(gtk.Adjustment(50, 1, 100, 10, 10))
    quality.connect("format-value",
                    lambda s,v: "%i" % v)
    quality.connect("change-value", set_quality, d)
    d.add_field(_("Quality"), quality)

    d.preview = gtk.Image()
    d.preview.show()
    sw = gtk.ScrolledWindow()
    sw.add_with_viewport(d.preview)
    sw.set_size_request(320,320)
    d.add_field(_("Preview"), sw, full=True)

    d.set_size_request(400, 450)

    d.image = image
    d.resized = None
    d.quality = 50

    d.update = update
    d.update()

    return d
Пример #21
0
    def build_user(self):
        vbox = gtk.VBox(False, 2)

        vbox.pack_start(self.make_sb("callsign", gtk.Entry(8)), 0, 0, 0)
        vbox.pack_start(self.make_sb("name", gtk.Entry()), 0, 0, 0)
        vbox.pack_start(self.make_sb("dosignon", self.make_bool()), 0, 0, 0)
        vbox.pack_start(self.make_sb("signon", gtk.Entry()), 0, 0, 0)

        vbox.pack_start(self.make_sb("dosignoff", self.make_bool()), 0, 0, 0)
        vbox.pack_start(self.make_sb("signoff", gtk.Entry()), 0, 0, 0)
        vbox.pack_start(self.make_sb("logenabled", self.make_bool()), 0, 0, 0)
        #vbox.pack_start(self.make_sb("debuglog",
        #                             self.make_bool()), 0,0,0)
        vbox.pack_start(self.make_sb("logresume", self.make_bool()), 0, 0, 0)
        vbox.pack_start(self.make_sb("restore_stations", self.make_bool()), 0,
                        0, 0)

        vbox.pack_start(self.make_sb("latitude", miscwidgets.LatLonEntry()), 0,
                        0, 0)
        vbox.pack_start(self.make_sb("longitude", miscwidgets.LatLonEntry()),
                        0, 0, 0)

        lookupbtn = gtk.Button("Lookup by address")
        lookupbtn.connect("clicked", self.address_button)
        lookupbtn.show()
        vbox.pack_start(lookupbtn, 0, 0, 0)

        vbox.pack_start(
            self.make_sb("altitude", self.make_spin(1.0, 0.0, 29028.0, 0)), 0,
            0, 0)

        units = ["Imperial", "Metric"]

        vbox.pack_start(self.make_sb("units", make_choice(units, False)), 0, 0,
                        0)

        vbox.pack_start(self.make_sb("ping_info", gtk.Entry()), 0, 0, 0)
        vbox.show()
        return vbox
Пример #22
0
    def __init__(self):
        gtk.Dialog.__init__(
            self,
            title="Edit form element",
            buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL),
        )

        self.entries = {}

        self.set_default_size(150, 150)

        self.vals = {
            "text": self.make_entry_editor("text"),
            "multiline": self.make_entry_editor("multiline"),
            "date": self.make_null_editor("date"),
            "time": self.make_null_editor("time"),
            "numeric": self.make_entry_editor("numeric"),
            "toggle": self.make_toggle_editor("toggle"),
            "choice": self.make_choice_editor("choice"),
            "multiselect": self.make_choice_editor("multiselect", False),
            "label": self.make_null_editor("label"),
        }

        self.type_sel = make_choice(self.vals.keys(), False, "text")
        self.type_sel.connect("changed", self.type_changed, None)
        self.type_sel.show()
        self.vals["text"].show()

        self.ts_frame = gtk.Frame("Field Type")
        self.ts_frame.show()
        self.ts_frame.add(self.type_sel)

        self.vbox.pack_start(self.ts_frame, 0, 0, 0)

        for t, w in self.vals.items():
            self.vbox.pack_start(w, 1, 1, 1)
Пример #23
0
        widget.set_size_request(150, -1)
        widget.show()

        box.pack_start(lab, 0, 0, 0)
        if full:
            box.pack_start(widget, 1, 1, 1)
        else:
            box.pack_start(widget, 0, 0, 0)
        box.show()

        # pylint: disable-msg=E1101
        if full:
            self.vbox.pack_start(box, 1, 1, 1)
        else:
            self.vbox.pack_start(box, 0, 0, 0)

        self.__fields[label] = widget

    def get_field(self, label):
        return self.__fields.get(label, None)


if __name__ == "__main__":
    # pylint: disable-msg=C0103
    d = FieldDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK))
    d.add_field("Foo", gtk.Entry())
    d.add_field("Bar", make_choice(["A", "B"]))
    d.run()
    gtk.main()
    d.destroy()
Пример #24
0
        widget.set_size_request(150, -1)
        widget.show()

        box.pack_start(lab, 0, 0, 0)
        if full:
            box.pack_start(widget, 1, 1, 1)
        else:
            box.pack_start(widget, 0, 0, 0)
        box.show()

        # pylint: disable-msg=E1101
        if full:
            self.vbox.pack_start(box, 1, 1, 1)
        else:
            self.vbox.pack_start(box, 0, 0, 0)

        self.__fields[label] = widget

    def get_field(self, label):
        return self.__fields.get(label, None)


if __name__ == "__main__":
    # pylint: disable-msg=C0103
    d = FieldDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK))
    d.add_field("Foo", gtk.Entry())
    d.add_field("Bar", make_choice(["A", "B"]))
    d.run()
    gtk.main()
    d.destroy()