def make_id(self): frame = gtk.Frame("Repeater Callsign") hbox = gtk.HBox(False, 2) self.entry_id = gtk.Entry() try: deftxt = self.config.get("settings", "id") except: deftxt = "W1AW" self.entry_id.set_text(deftxt) self.entry_id.set_max_length(8) self.entry_id.show() hbox.pack_start(self.entry_id, 1,1,1) try: idfreq = self.config.get("settings", "idfreq") except: idfreq = "30" self.id_freq = make_choice(["Never", "30", "60", "120"], True, idfreq) self.id_freq.set_size_request(75, -1) #self.id_freq.show() hbox.pack_start(self.id_freq, 0,0,0) hbox.show() frame.add(hbox) frame.show() return frame
def make_id(self): frame = gtk.Frame("Repeater Callsign") hbox = gtk.HBox(False, 2) self.entry_id = gtk.Entry() try: deftxt = self.config.get("settings", "id") except: deftxt = "W1AW" self.entry_id.set_text(deftxt) self.entry_id.set_max_length(8) self.entry_id.show() hbox.pack_start(self.entry_id, 1, 1, 1) try: idfreq = self.config.get("settings", "idfreq") except: idfreq = "30" self.id_freq = make_choice(["Never", "30", "60", "120"], True, idfreq) self.id_freq.set_size_request(75, -1) #self.id_freq.show() hbox.pack_start(self.id_freq, 0, 0, 0) hbox.show() frame.add(hbox) frame.show() return frame
def prompt_for_station(_station_list, config, parent=None): station_list = [str(x) for x in _station_list] port_list = [] for i in config.options("ports"): enb, port, rate, sniff, raw, name = config.get("ports", i).split(",") if enb == "True": port_list.append(name) defsta = defprt = "" if station_list: defsta = str(station_list[0]) if port_list: defprt = port_list[0] port_list.sort() station_list.sort() station = miscwidgets.make_choice(station_list, True, defsta) port = miscwidgets.make_choice(port_list, False, defprt) d = inputdialog.FieldDialog(title=_("Enter destination"), parent=parent) d.add_field(_("Station"), station) d.add_field(_("Port"), port) station.child.set_activates_default(True) while True: res = d.run() if res != gtk.RESPONSE_OK: break s = station.get_active_text().upper() if "@" in s: display_error( _("You must enter a station callsign. " + "You cannot use an email address here"), d) continue elif not re.match(STATION_REGEX, s): display_error(_("Invalid character in callsign"), d) continue break p = port.get_active_text() d.destroy() if res == gtk.RESPONSE_OK: return s, p else: return None, None
def prompt_for_station(_station_list, config, parent=None): station_list = [str(x) for x in _station_list] port_list = [] for i in config.options("ports"): enb, port, rate, sniff, raw, name = config.get("ports", i).split(",") if enb == "True": port_list.append(name) defsta = defprt = "" if station_list: defsta = str(station_list[0]) if port_list: defprt = port_list[0] port_list.sort() station_list.sort() station = miscwidgets.make_choice(station_list, True, defsta) port = miscwidgets.make_choice(port_list, False, defprt) d = inputdialog.FieldDialog(title=_("Enter destination"), parent=parent) d.add_field(_("Station"), station) d.add_field(_("Port"), port) station.child.set_activates_default(True) while True: res = d.run() if res != gtk.RESPONSE_OK: break s = station.get_active_text().upper() if "@" in s: display_error(_("You must enter a station callsign. " + "You cannot use an email address here"), d) continue elif not re.match(STATION_REGEX, s): display_error(_("Invalid character in callsign"), d) continue break p = port.get_active_text() d.destroy() if res == gtk.RESPONSE_OK: return s, p else: return None, None
def prompt_for_account(config): accounts = {} for section in config.options("incoming_email"): info = config.get("incoming_email", section).split(",") key = "%s on %s" % (info[1], info[0]) accounts[key] = info wl2k_call = config.get("user", "callsign") wl2k_ssid = config.get("prefs", "msg_wl2k_ssid").strip() if wl2k_ssid: wl2k_call = "%s-%s" % (wl2k_call, wl2k_ssid) accounts["Other"] = ["", "", "", "", "", "110"] accounts["WL2K"] = ["@WL2K", wl2k_call, "", "", "", "0"] default = list(accounts.keys())[0] account = miscwidgets.make_choice(list(accounts.keys()), False, default) host = Gtk.Entry() user = Gtk.Entry() pasw = Gtk.Entry() ussl = Gtk.CheckButton() port = Gtk.SpinButton(Gtk.Adjustment(110, 1, 65535, 1), digits=0) disable = [host, user, pasw, ussl, port] pasw.set_visibility(False) def choose_account(box): info = accounts[box.get_active_text()] for i in disable: i.set_sensitive(not info[0]) host.set_text(info[0]) user.set_text(info[1]) pasw.set_text(info[2]) ussl.set_active(info[4] == "True") port.set_value(int(info[5])) account.connect("changed", choose_account) choose_account(account) d = inputdialog.FieldDialog(title="Select account") d.add_field("Account", account) d.add_field("Server", host) d.add_field("Username", user) d.add_field("Password", pasw) d.add_field("Use SSL", ussl) d.add_field("Port", port) r = d.run() d.destroy() if r == Gtk.RESPONSE_CANCEL: return None return host.get_text(), user.get_text(), pasw.get_text(), \ str(ussl.get_active()), str(int(port.get_value()))
def prompt_for_account(config): accounts = {} for section in config.options("incoming_email"): info = config.get("incoming_email", section).split(",") key = "%s on %s" % (info[1], info[0]) accounts[key] = info wl2k_call = config.get("user", "callsign") wl2k_ssid = config.get("prefs", "msg_wl2k_ssid").strip() if wl2k_ssid: wl2k_call = "%s-%s" % (wl2k_call, wl2k_ssid) accounts["Other"] = ["", "", "", "", "", "110"] accounts["WL2K"] = ["@WL2K", wl2k_call, "", "", "", "0"] default = accounts.keys()[0] account = miscwidgets.make_choice(accounts.keys(), False, default) host = gtk.Entry() user = gtk.Entry() pasw = gtk.Entry() ussl = gtk.CheckButton() port = gtk.SpinButton(gtk.Adjustment(110, 1, 65535, 1), digits=0) disable = [host, user, pasw, ussl, port] pasw.set_visibility(False) def choose_account(box): info = accounts[box.get_active_text()] for i in disable: i.set_sensitive(not info[0]) host.set_text(info[0]) user.set_text(info[1]) pasw.set_text(info[2]) ussl.set_active(info[4] == "True") port.set_value(int(info[5])) account.connect("changed", choose_account) choose_account(account) d = inputdialog.FieldDialog(title="Select account") d.add_field("Account", account) d.add_field("Server", host) d.add_field("Username", user) d.add_field("Password", pasw) d.add_field("Use SSL", ussl) d.add_field("Port", port) r = d.run() d.destroy() if r == gtk.RESPONSE_CANCEL: return None return host.get_text(), user.get_text(), pasw.get_text(), \ str(ussl.get_active()), str(int(port.get_value()))
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)
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()