Python gtk 模块,Entry() 实例源码

我们从Python开源项目中,提取了以下36个代码示例,用于说明如何使用gtk.Entry()

项目:colorize    作者:BruXy    | 项目源码 | 文件源码
def gui_ask_for_api():
    """Gtk dialog for API key insert."""
    message = gtk.MessageDialog(type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_OK_CANCEL)
    message.set_markup(colorize.MSG_ASK_API.replace(colorize.URL,"<u>" + colorize.URL +"</u>"))

    entry = gtk.Entry(max=64)
    entry.set_text("Enter your API key")
    entry.show()
    message.vbox.pack_end(entry)
    entry.connect("activate", lambda _: d.response(gtk.RESPONSE_OK))
    message.set_default_response(gtk.RESPONSE_OK)
    message.run()

    api_key = entry.get_text().decode('utf8')
    fp = open(colorize.HOME + colorize.API_KEY_FILE, 'w')
    fp.write("YOUR_API_KEY={0}{1}".format(api_key, os.linesep))
    fp.close()

    # process buttong click immediately
    message.destroy()
    while gtk.events_pending():
        gtk.main_iteration()
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def create_text_hbox(self, label, value, trace, sensitivity_group, constraints=None):
        hbox_main = gtk.HBox()
        label_text = gtk.Label(label.title())
        label_text.set_alignment(0, 0.5)
        label_text.set_padding(8,8)
        entry_text = gtk.Entry()
        entry_text.set_text(value)
        hbox_main.pack_start(label_text)
        hbox_main.pack_start(entry_text)

        self.plugin_config_widgets.append(entry_text)
        self.plugin_config_traces.append(trace)
        sensitivity_group.append(label_text)
        sensitivity_group.append(entry_text)

        return hbox_main
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def create_path_hbox(self, label, value, trace, sensitivity_group, constraints=None):
        hbox_main = gtk.HBox()
        label_text = gtk.Label(label.title())
        label_text.set_alignment(0, 0.5)
        label_text.set_padding(8,8)
        entry_filepath = gtk.Entry()
        entry_filepath.set_text(value)
        button_select_folder = gtk.ToolButton(
            gtk.image_new_from_file(os.path.join(definitions.ICONS_DIR, "open_small.png")))
        button_select_folder.connect("clicked", self.select_folder, entry_filepath)
        hbox_main.pack_start(label_text)
        hbox_main.pack_start(entry_filepath)
        hbox_main.pack_start(button_select_folder)

        self.plugin_config_widgets.append(entry_filepath)
        self.plugin_config_traces.append(trace)
        sensitivity_group.append(label_text)
        sensitivity_group.append(entry_filepath)
        sensitivity_group.append(button_select_folder)

        return hbox_main
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def create_filepath_hbox(self, label, value, trace, sensitivity_group, constraints=None):
        hbox_main = gtk.HBox()
        label_text = gtk.Label(label.title())
        label_text.set_alignment(0, 0.5)
        label_text.set_padding(8,8)
        entry_filepath = gtk.Entry()
        entry_filepath.set_text(value)
        button_select_folder = gtk.ToolButton(
            gtk.image_new_from_file(os.path.join(definitions.ICONS_DIR, "open_small.png")))
        button_select_folder.connect("clicked", self.select_file, entry_filepath)
        hbox_main.pack_start(label_text)
        hbox_main.pack_start(entry_filepath)
        hbox_main.pack_start(button_select_folder)

        self.plugin_config_widgets.append(entry_filepath)
        self.plugin_config_traces.append(trace)
        sensitivity_group.append(label_text)
        sensitivity_group.append(entry_filepath)
        sensitivity_group.append(button_select_folder)

        return hbox_main
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        if 'default_value' in kwargs:
            default_value = kwargs['default_value']
            del kwargs['default_value']
        else:
            default_value = ''

        query = args[-1]
        args = args[:-1]

        super(EntryDialog, self).__init__(*args, **kwargs)

        label = gtk.Label(query)
        self.vbox.pack_start(label, True, True)

        entry = gtk.Entry()
        entry.set_text(str(default_value))
        entry.connect("activate",
                      lambda ent, dlg, resp: dlg.response(resp),
                      self, gtk.RESPONSE_OK)
        self.vbox.pack_end(entry, True, True, 0)
        self.vbox.show_all()
        self.entry = entry
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def setup_gui_url_chooser(self):
        self.media_model = gtk.ListStore(str)
        self.media_type = gtk.ComboBox(self.media_model)
        cell = gtk.CellRendererText()
        self.media_type.pack_start(cell, True)
        self.media_type.add_attribute(cell, "text", 0)

        for t in ("file", "dvd", "tv", "dvb", "vcd", "radio", "cdda", "tivo"):
            self.media_model.append((t,))

        self.media_location = gtk.Entry()
        self.media_server = gtk.Label()
        self.media_server.set_alignment(0, 0.5)

        d = catota.ui.Dialog("Choose Location", self.parent_win,
                             extra_buttons=(gtk.STOCK_PREFERENCES, 1))

        t = catota.ui.new_table((("Server:", self.media_server),
                                 ("Type:", self.media_type),
                                 ("Location:", self.media_location)))
        d.vbox.pack_start(t, True, True)

        self.gui_url_chooser = d
    # setup_gui_url_chooser()
项目:File-Explorer    作者:aj95    | 项目源码 | 文件源码
def __init__(self, parent):
        gtk.Dialog.__init__(self, "Rename", parent, 0)

        self.set_default_size(150, 100)
        label1=gtk.Label()
        label1.set_markup("Enter New Name")

        self.newname=gtk.Entry()
        box = self.get_content_area()
        box.add(label1)
        box.add(self.newname)

        self.ok_button=gtk.Button("OK")
        box.add(self.ok_button)
        self.ok_button.connect("clicked",self.on_rename_ok_clicked)
        self.show_all()
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def __init__(self, **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.text = gtk.Entry()
        self.text.connect("activate", self.respond_ok, None)
        # pylint: disable-msg=E1101
        self.vbox.pack_start(self.text, 1, 1, 0)

        self.label.show()
        self.text.show()
项目:hardened-centos7-kickstart    作者:fcaviggia    | 项目源码 | 文件源码
def get_password(self,parent):
        dialog = gtk.Dialog("Configure System Password",parent,gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT,(gtk.STOCK_CANCEL,gtk.RESPONSE_REJECT,gtk.STOCK_OK,gtk.RESPONSE_ACCEPT))
        self.pass1 = gtk.HBox()
                self.label1 = gtk.Label("          Passsword: ")
                self.pass1.pack_start(self.label1,False,True,0)
        self.password1 = gtk.Entry()
        self.password1.set_visibility(False)
        self.pass1.pack_start(self.password1,False,True,0)
        dialog.vbox.add(self.pass1)
        self.pass2 = gtk.HBox()
                self.label2 = gtk.Label("  Verify Password: ")
                self.pass2.pack_start(self.label2,False,True,0)
        self.password2 = gtk.Entry()
        self.password2.set_visibility(False)
        self.pass2.pack_start(self.password2,False,True,0)
        dialog.vbox.add(self.pass2)
        dialog.show_all()
        response = dialog.run()
        if response == gtk.RESPONSE_ACCEPT:
            self.a = self.password1.get_text()
            self.b = self.password2.get_text()
            dialog.destroy()
        else:
            self.a = ''
            self.b = ''
            dialog.destroy()


    # Configure Network Dialog
项目:tools    作者:denglouping    | 项目源码 | 文件源码
def begin():
    begin_dialog = gtk.Dialog();
    begin_dialog_entry = gtk.Entry();

    begin_dialog.add_action_widget(begin_dialog_entry,0);
    begin_dialog.add_button("OK",1);
    begin_dialog.add_button("CANCEL",2);

    begin_dialog.connect("response",begin_response);

    begin_dialog_entry.show();
    begin_dialog.run();
项目:tools    作者:denglouping    | 项目源码 | 文件源码
def select_Server(self,widget,event,pattern,):
        if pattern == 1:#??
            for key in self.serverInfo:
                self.serverInfo[key]['checkButton'].set_active(True);
        elif pattern == 2:#??
            for key in self.serverInfo:
                if self.serverInfo[key]['checkButton'].get_active():
                    self.serverInfo[key]['checkButton'].set_active(False);
                else:
                    self.serverInfo[key]['checkButton'].set_active(True);
        elif pattern ==3:
            def get_response(dialog,response_id):
                if response_id == 1:
                    regex = dialog.get_action_area().get_children()[2].get_text();
                    for key in self.serverInfo:
                        s = re.match(regex,self.serverInfo[key]['serverName'])
                        print s
                        if s:
                            self.serverInfo[key]['checkButton'].set_active(False);
                        else:
                            self.serverInfo[key]['checkButton'].set_active(True);
                else:
                    show_message("The script has exited.","Information");
                dialog.destroy();

            begin_dialog = gtk.Dialog();
            begin_dialog_entry = gtk.Entry();

            begin_dialog.set_title("???????????")
            begin_dialog.add_action_widget(begin_dialog_entry,0);
            begin_dialog.add_button("OK",1);
            begin_dialog.add_button("CANCEL",2);

            begin_dialog.connect("response",get_response);

            begin_dialog_entry.show();
            begin_dialog.run();
项目:tools    作者:denglouping    | 项目源码 | 文件源码
def add_Server(self,widget,event):
        begin_dialog = gtk.Dialog();
        begin_dialog_entry = gtk.Entry();

        begin_dialog.set_title("???????????")
        begin_dialog.add_action_widget(begin_dialog_entry,0);
        begin_dialog.add_button("OK",1);
        begin_dialog.add_button("CANCEL",2);

        begin_dialog.connect("response",self.get_Addresponse);

        begin_dialog_entry.show();
        begin_dialog.run();
项目:tools    作者:denglouping    | 项目源码 | 文件源码
def build_InputEntry(self):
        inputEntry = gtk.Entry();

        inputEntry.connect("key_press_event",self.send_key_event)
        inputEntry.connect("key_release_event",self.send_key_event)
        inputEntry.connect("paste_clipboard",self.copy)

        return inputEntry;
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def setup_gui_preferences(self):
        self.address = gtk.Entry()
        self.port = hildon.NumberEditor(0, 100000)

        wids = ("GMyth Streamer",
                ("Address:", self.address),
                ("Port:", self.port))

        self.gui_preferences = wids
    # setup_gui_preferences()
项目:tintwizard    作者:vanadey    | 项目源码 | 文件源码
def addBg(self):
        """Adds a new background to the list of backgrounds."""
        self.bgs += [gtk.Table(4, 3, False)]

        createLabel(self.bgs[-1], text="Corner Rounding (px)", gridX=0, gridY=0, xPadding=10)
        createEntry(self.bgs[-1], maxSize=7, width=9, text=BG_ROUNDING, gridX=1, gridY=0, xExpand=True, yExpand=False, handler=self.changeOccurred, name="rounded")

        createLabel(self.bgs[-1], text="Background Color", gridX=0, gridY=1, xPadding=10)
        temp = gtk.Entry(7)
        temp.set_width_chars(9)
        temp.set_name("bgColEntry")
        temp.set_text(self.defaults["bgColor"])
        temp.connect("changed", self.changeOccurred)
        temp.connect("activate", self.colorTyped)
        self.bgs[-1].attach(temp, 1, 2, 1, 2, xoptions=gtk.EXPAND)
        temp = gtk.ColorButton(gtk.gdk.color_parse(self.defaults["bgColor"]))
        temp.set_use_alpha(True)
        temp.set_name("bgCol")
        temp.connect("color-set", self.colorChange)
        self.bgs[-1].attach(temp, 2, 3, 1, 2, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)

        createLabel(self.bgs[-1], text="Border Width (px)", gridX=0, gridY=2, xPadding=10)
        createEntry(self.bgs[-1], maxSize=7, width=9, text=BG_BORDER, gridX=1, gridY=2, xExpand=True, yExpand=False, handler=self.changeOccurred, name="border")

        createLabel(self.bgs[-1], text="Border Color", gridX=0, gridY=3, xPadding=10)
        temp = gtk.Entry(7)
        temp.set_width_chars(9)
        temp.set_name("borderColEntry")
        temp.connect("activate", self.colorTyped)
        temp.set_text(self.defaults["borderColor"])
        temp.connect("changed", self.changeOccurred)
        self.bgs[-1].attach(temp, 1, 2, 3, 4, xoptions=gtk.EXPAND)
        temp = gtk.ColorButton(gtk.gdk.color_parse(self.defaults["borderColor"]))
        temp.set_use_alpha(True)
        temp.set_name("borderCol")
        temp.connect("color-set", self.colorChange)
        self.bgs[-1].attach(temp, 2, 3, 3, 4, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND)

    # Note: Only set init to True when initialising background styles.
    # This prevents unwanted calls to changeOccurred()
项目:tintwizard    作者:vanadey    | 项目源码 | 文件源码
def createEntry(parent, maxSize, width, text="", gridX=0, gridY=0, sizeX=1, sizeY=1, xExpand=True, yExpand=True, handler=None, name=""):
    """Creates a text entry widget and adds it to a parent widget."""
    temp = gtk.Entry(maxSize)
    temp.set_width_chars(width)
    temp.set_text(text)
    temp.set_name(name)

    if handler != None:
        temp.connect("changed", handler)

    parent.attach(temp, gridX, gridX+sizeX, gridY, gridY+sizeY, xoptions=gtk.EXPAND if xExpand else 0, yoptions=gtk.EXPAND if yExpand else 0)

    return temp
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def edit_string(self, time_out = 0.05):
        self.stringedit_window = gtk.Dialog(parent = self.tv.get_toplevel())
        self.stringedit_window.hide()
        self.stringedit_window.set_decorated(False)
        self.stringedit_window.set_transient_for(None)
        self.stringedit_window.set_border_width(0)
        self.stringedit_window.set_property("skip-taskbar-hint", True)

        self.stringedit_entry = gtk.Entry()
        self.stringedit_window.vbox.add(self.stringedit_entry)
        self.stringedit_entry.set_editable(True)

        self.stringedit_entry.connect('key-press-event', self.string_edit_keyhandler)

        # position the popup on the edited cell
        (tree_x, tree_y) = self.tv.get_bin_window().get_origin()
        (tree_w, tree_h) = self.tv.window.get_geometry()[2:4]
        x = tree_x + self.cell_area.x
        y = tree_y + self.cell_area.y
        self.stringedit_window.move(x - 4, y - 2)
        self.stringedit_window.resize(tree_w - self.cell_area.x + 4, self.cell_area.height)
        self.stringedit_window.show_all()
        self.stringedit_entry.grab_focus()
        self.stringedit_entry.connect('focus-out-event', self.string_edit_focus_out)

        time.sleep(time_out)
        if self.inputKey != 'BS' :
            self.stringedit_entry.set_text(self.param_value)
        self.inputKey = ''
        response = self.stringedit_window.run()
        new_val = self.stringedit_entry.get_text()
        self.stringedit_window.hide()
        self.stringedit_window.destroy()
        return response, new_val
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def action_renameF(self, *arg):
        self.newnamedlg = gtk.MessageDialog(parent = None,
            flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
            type = gtk.MESSAGE_QUESTION,
            buttons = gtk.BUTTONS_OK_CANCEL
        )
        old_name = self.selected_feature.get_attr('name')
        self.newnamedlg.set_markup(_('Enter new name for'))
        self.newnamedlg.format_secondary_markup(old_name)
        self.newnamedlg.set_title('NativeCAM')
        edit_entry = gtk.Entry()
        edit_entry.set_editable(True)
        edit_entry.set_text(old_name)
        edit_entry.connect('key-press-event', self.action_rename_keyhandler)
        self.newnamedlg.vbox.add(edit_entry)
        self.newnamedlg.set_keep_above(True)

        (tree_x, tree_y) = self.treeview.get_bin_window().get_origin()
        self.newnamedlg.move(tree_x, tree_y + self.click_y)

        self.newnamedlg.show_all()
        response = self.newnamedlg.run()
        if (response == gtk.RESPONSE_OK) :
            newname = edit_entry.get_text().lstrip(' ')
            if newname > '' :
                self.selected_feature.attr['name'] = newname
                self.refresh_views()
        self.newnamedlg.destroy()
项目:griffith    作者:Strit    | 项目源码 | 文件源码
def add_query_widget(container, field_names, sel_qf='title', sel_comm='contains', text=''):
    hbox = gtk.HBox()

    cb = gtk.combo_box_new_text()
    select = 0
    for i, field in enumerate(QUERY_FIELDS):
        if sel_qf == field:
            select = i
        cb.append_text(field_names[field])
    cb.set_active(select)

    action_cb = gtk.combo_box_new_text()
    select = 0
    for i, command in enumerate(QUERY_COMMANDS):
        if sel_comm == command:
            select = i
        action_cb.append_text(QUERY_COMMAND_NAMES[command])
    action_cb.set_active(select)

    entry = gtk.Entry()
    entry.set_text(text)

    button = gtk.Button(stock=gtk.STOCK_DELETE)
    button.connect("clicked", lambda w: hbox.destroy())

    hbox.pack_start(cb, expand=False)
    hbox.pack_start(action_cb, expand=False)
    hbox.pack_start(entry, expand=True, padding=8)
    hbox.pack_start(button, expand=False, fill=False)
    hbox.show_all()

    container.pack_start(hbox)
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def __init__(self, title, message, default_text='', modal=True, mask=False):
        gtk.Dialog.__init__(self)
        self.set_title(title)
        self.connect("destroy", self.quit)
        self.connect("delete_event", self.quit)
        if modal:
            self.set_modal(True)
        box = gtk.VBox(spacing=10)
        box.set_border_width(10)
        self.vbox.pack_start(box)
        box.show()
        if message:
            label = gtk.Label(message)
            box.pack_start(label)
            label.show()
        self.entry = gtk.Entry()
        self.entry.set_text(default_text)
        self.entry.set_visibility(not mask)
        box.pack_start(self.entry)
        self.entry.show()
        self.entry.grab_focus()
        button = gtk.Button(stock=gtk.STOCK_OK)
        button.connect("clicked", self.click)
        self.entry.connect("activate", self.click)
        button.set_flags(gtk.CAN_DEFAULT)
        self.action_area.pack_start(button)
        button.show()
        button.grab_default()
        button = gtk.Button(stock=gtk.STOCK_CANCEL)
        button.connect("clicked", self.quit)
        button.set_flags(gtk.CAN_DEFAULT)
        self.action_area.pack_start(button)
        button.show()
        self.ret = None
项目:linux-pentest-util    作者:fikr4n    | 项目源码 | 文件源码
def __init__(self, parser, max_tree_depth):
        self.parser = parser
        self._max_tree_depth = max_tree_depth
        self.search_thread = None
        self.search_lock = threading.Lock()
        self.name_entry = name_entry = gtk.Entry()
        name_entry.connect('activate', self.on_name_entry_activate)
        search_button = self.search_button = gtk.Button(stock=gtk.STOCK_FIND)
        search_button.connect('clicked', self.on_search)
        search_button.set_no_show_all(True)
        search_button.show()
        stop_button = self.stop_button = gtk.Button(stock=gtk.STOCK_STOP)
        stop_button.connect('clicked', self.stop_search)
        stop_button.set_no_show_all(True)
        self.progress = progress = gtk.ProgressBar()
        progress.set_size_request(-1, 8)
        name_box = gtk.HBox(spacing=8)
        name_box.set_border_width(8)
        name_box.pack_start(name_entry, True, True)
        name_box.pack_start(search_button, False)
        name_box.pack_start(stop_button, False)
        self.store = gtk.TreeStore(str, str, str, str)  # name, icon, fnstyle, info
        self.treeview = treeview = self._create_treeview(self.store)
        scroller = gtk.ScrolledWindow()
        scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroller.add(treeview)
        settings_view = SettingsView(max_depth_value=max_tree_depth)
        settings_view.on_max_depth_changed = self.on_max_depth_changed
        extension = gtk.expander_new_with_mnemonic('_Settings')
        extension.add(settings_view.view)
        vbox = gtk.VBox()
        vbox.pack_start(name_box, False)
        vbox.pack_start(progress, False)
        vbox.pack_start(scroller, True, True)
        vbox.pack_start(extension, False)
        self.window = window = gtk.Window()
        window.set_title(Application.title)
        window.set_default_size(800, 600)
        window.set_icon(Application.get_icon())
        window.add(vbox)
项目:File-Explorer    作者:aj95    | 项目源码 | 文件源码
def __init__(self, parent):
        gtk.Dialog.__init__(self, "New Folder", parent, 0)
        self.set_default_size(150, 100)
        label1=gtk.Label()
        label1.set_markup("Enter New Folder's Name")

        self.newname=gtk.Entry()
        box = self.get_content_area()
        box.add(label1)
        box.add(self.newname)

        self.ok_button=gtk.Button("OK")
        box.add(self.ok_button)
        self.ok_button.connect("clicked",self.on_newfolder_ok_clicked)
        self.show_all()
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def __init__(self):
        self.model = gtk.ListStore(gobject.TYPE_STRING)
        self.nameEntry = gtk.Entry()
        self.buttons = []
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def _init(self, data):
        self._widget = gtk.Entry(int(data))
        self._widget.set_text(str(self._mem_value()))
        self._widget.connect("changed", self.changed)
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def do_dmrmarc_prompt(self):
        fields = {"1City":      (gtk.Entry(), lambda x: x),
                  "2State":     (gtk.Entry(), lambda x: x),
                  "3Country":   (gtk.Entry(), lambda x: x),
                  }

        d = inputdialog.FieldDialog(title=_("DMR-MARC Repeater Database Dump"),
                                    parent=self)
        for k in sorted(fields.keys()):
            d.add_field(k[1:], fields[k][0])
            fields[k][0].set_text(CONF.get(k[1:], "dmrmarc") or "")

        while d.run() == gtk.RESPONSE_OK:
            for k in sorted(fields.keys()):
                widget, validator = fields[k]
                try:
                    if validator(widget.get_text()):
                        CONF.set(k[1:], widget.get_text(), "dmrmarc")
                        continue
                except Exception:
                    pass

            d.destroy()
            return True

        d.destroy()
        return False
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def do_rfinder_prompt(self):
        fields = {"1Email": (gtk.Entry(), lambda x: "@" in x),
                  "2Password": (gtk.Entry(), lambda x: x),
                  "3Latitude": (gtk.Entry(),
                                lambda x: float(x) < 90 and float(x) > -90),
                  "4Longitude": (gtk.Entry(),
                                 lambda x: float(x) < 180 and float(x) > -180),
                  "5Range_in_Miles": (gtk.Entry(),
                                      lambda x: int(x) > 0 and int(x) < 5000),
                  }

        d = inputdialog.FieldDialog(title="RFinder Login", parent=self)
        for k in sorted(fields.keys()):
            d.add_field(k[1:].replace("_", " "), fields[k][0])
            fields[k][0].set_text(CONF.get(k[1:], "rfinder") or "")
            fields[k][0].set_visibility(k != "2Password")

        while d.run() == gtk.RESPONSE_OK:
            valid = True
            for k in sorted(fields.keys()):
                widget, validator = fields[k]
                try:
                    if validator(widget.get_text()):
                        CONF.set(k[1:], widget.get_text(), "rfinder")
                        continue
                except Exception:
                    pass
                common.show_error("Invalid value for %s" % k[1:])
                valid = False
                break

            if valid:
                d.destroy()
                return True

        d.destroy()
        return False
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def __init__(self, *args):
        gtk.Entry.__init__(self, *args)

        self.connect("changed", self.format)
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def __init__(self, find_dir=False, types=[]):
        gtk.HBox.__init__(self, False, 0)

        self.types = types

        self.filename = gtk.Entry()
        self.filename.show()
        self.pack_start(self.filename, 1, 1, 1)

        browse = gtk.Button("...")
        browse.show()
        self.pack_start(browse, 0, 0, 0)

        self.filename.connect("changed", self.do_changed)
        browse.connect("clicked", self.do_browse, find_dir)
项目:pub1ic_POC    作者:i1ikey0u    | 项目源码 | 文件源码
def __init__(self, width, height):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)
        self.window.set_border_width(0)
        self.window.set_size_request(width, height + 30)
        self.window.set_app_paintable(True)

        self.screen = self.window.get_screen()
        self.rgba = self.screen.get_rgba_colormap()
        self.window.set_colormap(self.rgba)
        self.window.connect('expose-event', self.expose)

        self.vbox = gtk.VBox(False, 5)
        self.hbox = gtk.HBox(False, 3)
        self.bbox = gtk.HBox(True, 3)

        self.entry = gtk.Entry()
        self.entry.set_max_length(0)
        self.entry.set_size_request(int(width / 2), 25)
        self.entry.connect("activate", self.enter_callback, self.entry)
        self.spr = gtk.ToggleButton(label='spr')
        self.spr.connect("toggled", self.on_button_toggled, 'spr')
        self.ctrl = gtk.ToggleButton(label='ctrl')
        self.ctrl.connect("toggled", self.on_button_toggled, 'ctrl')
        self.alt = gtk.ToggleButton(label='alt')
        self.alt.connect("toggled", self.on_button_toggled, 'alt')
        self.enter = gtk.Button(label='Enter')
        self.enter.connect("clicked", self.on_enter_clicked)
        self.backspace = gtk.Button(label='Backspace')
        self.backspace.connect("clicked", self.on_backspace_clicked)
        self.shell = gtk.Button(label='R-Shell')
        self.shell.connect("clicked", self.on_shell_clicked, self.entry)

        self.hbox.add(self.entry)
        self.bbox.add(self.spr)
        self.bbox.add(self.ctrl)
        self.bbox.add(self.alt)
        self.bbox.add(self.enter)
        self.bbox.add(self.backspace)
        self.bbox.add(self.shell)
        self.hbox.add(self.bbox)

        self.halign = gtk.Alignment(1, 0, 1, 0)
        self.halign.add(self.hbox)

        self.allalign = gtk.Alignment(0, 0, 1, 1)
        self.clickbox = gtk.EventBox()
        self.clickbox.connect('button-press-event', self.on_click)
        self.clickbox.set_visible_window(False)

        self.allalign.add(self.clickbox)
        self.vbox.pack_start(self.allalign, True, True, 0)

        self.vbox.pack_end(self.halign, False, False, 0)

        self.window.add(self.vbox)

        self.window.show_all()

        self.window.move(100, 100)
项目:ecel    作者:ARL-UTEP-OC    | 项目源码 | 文件源码
def save_shot(self):
        # create a new window
        dialog = gtk.Dialog("Manual ScreenShot",
                            None,
                            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                            (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                             gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))

        dialog.set_size_request(400, 250)
        dialog.set_title("Manual ScreenShot Comment ECEL V2.0")

        table = gtk.Table(5,2,False)
        table.show()
        # create ip row
        ipLabel = gtk.Label("IP")
        ipEntry = gtk.Entry()
        table.attach(ipLabel, 0, 1, 0, 1)
        table.attach(ipEntry, 1, 2, 0, 1)
        ipLabel.show()
        ipEntry.show()

        # create Port row
        portLabel = gtk.Label("Port")
        portEntry = gtk.Entry()
        table.attach(portLabel, 0, 1, 1, 2)
        table.attach(portEntry, 1, 2, 1, 2)
        portLabel.show()
        portEntry.show()

        # create initial row
        initialLabel = gtk.Label("Initials")
        initialEntry = gtk.Entry()
        table.attach(initialLabel, 0, 1, 2, 3)
        table.attach(initialEntry, 1, 2, 2, 3)
        initialLabel.show()
        initialEntry.show()

        #create the comment entry field
        maxChar = 64
        commentEntry = gtk.Entry()
        commentEntry.set_max_length(maxChar)
        commentEntry.insert_text("Enter Comment")
        commentEntry.select_region(0, len(commentEntry.get_text()))
        table.attach(commentEntry, 0, 2, 3, 4)
        commentEntry.show()

        dialog.vbox.pack_start(table)

        response = dialog.run()

        self.ip_entry_text = ipEntry.get_text()
        self.port_entry_text = portEntry.get_text()
        self.initial_entry_text = initialEntry.get_text()
        self.comment_entry_text = commentEntry.get_text()
        dialog.hide_all()
        dialog.destroy()
        return response
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def setup_gui_preferences(self):
        self.player_path = gtk.Entry()
        self.player_params = gtk.Entry()

        self.player_ao_model = gtk.ListStore(str)
        self.player_ao = gtk.ComboBox(self.player_ao_model)
        cell = gtk.CellRendererText()
        self.player_ao.pack_start(cell, True)
        self.player_ao.add_attribute(cell, "text", 0)

        for t in ("esd", "gst"):
            self.player_ao_model.append((t,))


        self.player_acodec_model = gtk.ListStore(str)
        self.player_acodec = gtk.ComboBox(self.player_acodec_model)
        cell = gtk.CellRendererText()
        self.player_acodec.pack_start(cell, True)
        self.player_acodec.add_attribute(cell, "text", 0)

        for t in ("ffmpeg", "dspmp3"):
            self.player_acodec_model.append((t,))



        hbox = gtk.HBox(homogeneous=False, spacing=2)
        btn = gtk.Button(stock=gtk.STOCK_OPEN)
        hbox.pack_start(self.player_path, fill=True, expand=True)
        hbox.pack_start(btn, fill=True, expand=False)
        btn.connect("clicked", self._choose_mplayer_path)

        hbox.show_all()

        wids = ("MPlayer",
                ("Path:", hbox),
                ("Parameters:", self.player_params),
                ("Audio Output:", self.player_ao),
                ("Audio Codec:", self.player_acodec),
                )

        self.gui_preferences = wids
    # setup_gui_preferences()
项目:inkscapeMadeEasy    作者:fsmMLK    | 项目源码 | 文件源码
def ask(self, callback):
            self.callback = callback

            root = Tk.Tk()

            self._frame = Tk.Frame(root)
            self._frame.pack()

            box = Tk.Frame(self._frame)
            label = Tk.Label(box, text="Preamble file:")
            label.pack(pady=2, padx=5, side="left", anchor="w")
            self._preamble = Tk.Entry(box)
            self._preamble.pack(expand=True, fill="x", pady=2, padx=5, side="right")
            self._preamble.insert(Tk.END, self.preamble_file)
            box.pack(fill="x", expand=True)

            box = Tk.Frame(self._frame)
            label = Tk.Label(box, text="Scale factor:")
            label.pack(pady=2, padx=5, side="left", anchor="w")
            self._scale = Tk.Scale(box, orient="horizontal", from_=0.1, to=10, resolution=0.1)
            self._scale.pack(expand=True, fill="x", pady=2, padx=5, anchor="e")
            if self.scale_factor is not None:
                self._scale.set(self.scale_factor)
            else:
                self._scale.set(1.0)
            box.pack(fill="x", expand=True)

            label = Tk.Label(self._frame, text="Text:")
            label.pack(pady=2, padx=5, anchor="w")

            self._text = Tk.Text(self._frame)
            self._text.pack(expand=True, fill="both", pady=5, padx=5)
            self._text.insert(Tk.END, self.text)

            box = Tk.Frame(self._frame)
            self._btn = Tk.Button(box, text="OK", command=self.cb_ok)
            self._btn.pack(ipadx=30, ipady=4, pady=5, padx=5, side="left")

            self._cancel = Tk.Button(box, text="Cancel", command=self.cb_cancel)
            self._cancel.pack(ipadx=30, ipady=4, pady=5, padx=5, side="right")

            box.pack(expand=False)

            root.mainloop()

            self.callback(self.text, self.preamble_file, self.scale_factor)
            return self.text, self.preamble_file, self.scale_factor
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def addParam(self, name, field, ptype, *args):
        x = self.tblGeneral.rows
        self.tblGeneral.rows += 1
        value = eval(field)
        if ptype==bool:
            obj = gtk.CheckButton()
            obj.set_label(name)
            obj.set_active(value)
            obj.set_alignment(0, 0.5)            
            obj.show()
            obj.field=field
            self.tblGeneral.attach(obj, 0, 2, x, x+1, gtk.EXPAND|gtk.FILL, 0)            
        elif ptype==int:            
            obj = gtk.SpinButton(climb_rate=10)
            if len(args)==2:
                obj.set_range(args[0], args[1])
            obj.set_increments(1, 10)
            obj.set_numeric(True)
            obj.set_value(value)                        
            obj.show()
            obj.field=field
            lbl = gtk.Label(name)
            lbl.set_alignment(0, 0.5)
            lbl.show()
            self.tblGeneral.attach(lbl, 0, 1, x, x+1, gtk.FILL, 0)
            self.tblGeneral.attach(obj, 1, 2, x, x+1, gtk.EXPAND|gtk.FILL, 0)
        elif ptype==list:
            obj = gtk.combo_box_new_text()
            for s in args[0]:
                obj.append_text(s)
            obj.set_active(value)
            obj.show()
            obj.field=field
            lbl = gtk.Label(name)
            lbl.set_alignment(0, 0.5)
            lbl.show()
            self.tblGeneral.attach(lbl, 0, 1, x, x+1, gtk.FILL, 0)
            self.tblGeneral.attach(obj, 1, 2, x, x+1, gtk.EXPAND|gtk.FILL, 0)
        else:            
            obj = gtk.Entry()
            obj.set_text(value)            
            obj.show()
            obj.field=field
            lbl = gtk.Label(name)
            lbl.set_alignment(0, 0.5)
            lbl.show()
            self.tblGeneral.attach(lbl, 0, 1, x, x+1, gtk.FILL, 0)
            self.tblGeneral.attach(obj, 1, 2, x, x+1, gtk.EXPAND|gtk.FILL, 0)
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def do_repeaterbook_proximity_prompt(self):
        default_band = "--All--"
        try:
            code = int(CONF.get("band", "repeaterbook"))
            for k, v in RB_BANDS.items():
                if code == v:
                    default_band = k
                    break
        except:
            pass
        fields = {"1Location":  (gtk.Entry(), lambda x: x.get_text()),
                  "2Distance":  (gtk.Entry(), lambda x: x.get_text()),
                  "3Band":      (miscwidgets.make_choice(
                                sorted(RB_BANDS.keys(), key=key_bands),
                                False, default_band),
                                lambda x: RB_BANDS[x.get_active_text()]),
                  }

        d = inputdialog.FieldDialog(title=_("RepeaterBook Query"),
                                    parent=self)
        for k in sorted(fields.keys()):
            d.add_field(k[1:], fields[k][0])
            if isinstance(fields[k][0], gtk.Entry):
                fields[k][0].set_text(
                    CONF.get(k[1:].lower(), "repeaterbook") or "")

        while d.run() == gtk.RESPONSE_OK:
            valid = True
            for k, (widget, fn) in fields.items():
                try:
                    CONF.set(k[1:].lower(), str(fn(widget)), "repeaterbook")
                    continue
                except:
                    pass
                common.show_error("Invalid value for %s" % k[1:])
                valid = False
                break

            if valid:
                d.destroy()
                return True

        d.destroy()
        return False
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def do_przemienniki_prompt(self):
        d = inputdialog.FieldDialog(title='przemienniki.net query',
                                    parent=self)
        fields = {
            "Country":
                (miscwidgets.make_choice(
                    ['at', 'bg', 'by', 'ch', 'cz', 'de', 'dk', 'es', 'fi',
                        'fr', 'hu', 'it', 'lt', 'lv', 'no', 'pl', 'ro', 'se',
                        'sk', 'ua', 'uk'], False),
                 lambda x: str(x.get_active_text())),
            "Band":
                (miscwidgets.make_choice(['10m', '4m', '6m', '2m', '70cm',
                                          '23cm', '13cm', '3cm'], False, '2m'),
                 lambda x: str(x.get_active_text())),
            "Mode":
                (miscwidgets.make_choice(['fm', 'dv'], False),
                 lambda x: str(x.get_active_text())),
            "Only Working":
                (miscwidgets.make_choice(['', 'yes'], False),
                 lambda x: str(x.get_active_text())),
            "Latitude": (gtk.Entry(), lambda x: float(x.get_text())),
            "Longitude": (gtk.Entry(), lambda x: float(x.get_text())),
            "Range": (gtk.Entry(), lambda x: int(x.get_text())),
        }
        for name in sorted(fields.keys()):
            value, fn = fields[name]
            d.add_field(name, value)
        while d.run() == gtk.RESPONSE_OK:
            query = "http://przemienniki.net/export/chirp.csv?"
            args = []
            for name, (value, fn) in fields.items():
                if isinstance(value, gtk.Entry):
                    contents = value.get_text()
                else:
                    contents = value.get_active_text()
                if contents:
                    try:
                        _value = fn(value)
                    except ValueError:
                        common.show_error(_("Invalid value for %s") % name)
                        query = None
                        continue

                    args.append("=".join((name.replace(" ", "").lower(),
                                          contents)))
            query += "&".join(args)
            LOG.debug(query)
            d.destroy()
            return query

        d.destroy()
        return query
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def make_file_ctl(self):
        self.w_fileframe = gtk.Frame("File")

        vbox = gtk.VBox(False, 2)
        vbox.set_border_width(2)

        hbox = gtk.HBox(False, 2)
        hbox.set_border_width(2)

        l = gtk.Label("File")
        l.show()
        hbox.pack_start(l, 0, , )

        self.w_filename = gtk.Entry()
        self.w_filename.connect("changed", self.file_changed)
        self.tips.set_tip(self.w_filename, "Path to CSV file")
        self.w_filename.show()
        hbox.pack_start(self.w_filename, 1, , )

        bb = StdButton("Browse")
        bb.connect("clicked", self.pick_file)
        bb.show()
        hbox.pack_start(bb, 0, , )

        hbox.show()
        vbox.pack_start(hbox, 0, , )

        hbox = gtk.HBox(True, 2)
        hbox.set_border_width(2)

        def export_handler(x):
            return self.fn_eport(self.w_filename.get_text())
        self.w_export = StdButton("Export")
        self.w_export.set_sensitive(False)
        self.w_export.connect("clicked", export_handler)
        self.tips.set_tip(self.w_export,
                          "Export radio memories to CSV file")
        self.w_export.show()
        hbox.pack_start(self.w_export, 0, , )

        def import_handler(x):
            return self.fn_iport(self.w_filename.get_text())
        self.w_import = StdButton("Import")
        self.w_import.set_sensitive(False)
        self.w_import.connect("clicked", import_handler)
        self.tips.set_tip(self.w_import,
                          "Import radio memories from CSV file")
        self.w_import.show()
        hbox.pack_start(self.w_import, 0, , )

        hbox.show()
        vbox.pack_start(hbox, 0, , )

        vbox.show()
        self.w_fileframe.add(vbox)
        self.w_fileframe.show()

        return self.w_fileframe