Python gi.repository.Gtk.Entry() Examples

The following are 30 code examples of gi.repository.Gtk.Entry(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gi.repository.Gtk , or try the search function .
Example #1
Source File: class_bankaccounts.py    From amir with GNU General Public License v3.0 6 votes vote down vote up
def addNewBank(self, model):
        dialog = Gtk.Dialog(None, None,
                            Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                             Gtk.STOCK_OK, Gtk.ResponseType.OK))
        label = Gtk.Label(label='Bank Name:')
        entry = Gtk.Entry()
        dialog.vbox.pack_start(label, False, False, 0)
        dialog.vbox.pack_start(entry, False, False, 0)
        dialog.show_all()
        result = dialog.run()
        bank_name = entry.get_text()
        if result == Gtk.ResponseType.OK and len(bank_name) != 0:
            iter = model.append()
            model.set(iter, 0, bank_name)
            self.add_bank(bank_name)

        dialog.destroy() 
Example #2
Source File: DenominoViso.py    From addons-source with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, option, dbstate, uistate, track, override=False):
        Gtk.HBox.__init__(self)
        self.__option = option
        value_str = self.__option.get_value()
        (attr_inc, attr_list) = value_str.split(',',1)
        attr_list = attr_list.strip()
        self.cb_w = Gtk.CheckButton(label="")
        self.cb_w.connect('toggled', self.__value_changed)
        self.l_w = Gtk.Label(label=_('restricted to:'))
        self.l_w.set_sensitive(False)
        self.e_w = Gtk.Entry()
        self.e_w.set_text(attr_list)
        self.e_w.connect('changed', self.__value_changed)
        self.e_w.set_sensitive(False)
        self.cb_w.set_active(attr_inc == 'True')
        self.pack_start(self.cb_w, False, True, 0)
        self.pack_end(self.e_w, True, True, 0)
        self.pack_end(self.l_w, False, True, 5)
        self.set_tooltip_text(self.__option.get_help()) 
Example #3
Source File: getgov.py    From addons-source with GNU General Public License v2.0 6 votes vote down vote up
def __create_gui(self):
        """
        Create and display the GUI components of the gramplet.
        """
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        vbox.set_spacing(4)

        label = Gtk.Label(_('Enter GOV-id:'))
        label.set_halign(Gtk.Align.START)

        self.entry = Gtk.Entry()

        button_box = Gtk.ButtonBox()
        button_box.set_layout(Gtk.ButtonBoxStyle.START)

        get = Gtk.Button(label=_('Get Place'))
        get.connect("clicked", self.__get_places)
        button_box.add(get)

        vbox.pack_start(label, False, True, 0)
        vbox.pack_start(self.entry, False, True, 0)
        vbox.pack_start(button_box, False, True, 0)

        return vbox 
Example #4
Source File: RemarkableWindow.py    From Remarkable with MIT License 6 votes vote down vote up
def insert_table(self, widget):
        self.insert_window_table = Gtk.Window()
        self.insert_window_table.set_title("Insert Table")
        self.insert_window_table.set_resizable(True)
        self.insert_window_table.set_border_width(6)
        self.insert_window_table.set_default_size(300, 250)
        self.insert_window_table.set_position(Gtk.WindowPosition.CENTER)
        vbox = Gtk.VBox()
        label_n_rows = Gtk.Label("Number of Rows:")
        self.entry_n_rows = Gtk.Entry()
        label_n_columns = Gtk.Label("Number of Columns")
        self.entry_n_columns = Gtk.Entry()
        vbox.pack_start(label_n_rows, self, False, False)
        vbox.pack_start(self.entry_n_rows, self, False, False)
        vbox.pack_start(label_n_columns, self, False, False)
        vbox.pack_start(self.entry_n_columns, self, False, False)
        button = Gtk.Button("Insert Table")
        vbox.pack_end(button, self, False, False)
        self.insert_window_table.add(vbox)
        self.insert_window_table.show_all()
        button.connect("clicked", self.insert_table_cmd, self.insert_window_table) 
Example #5
Source File: text.py    From gtg with GNU General Public License v3.0 6 votes vote down vote up
def _populate_gtk(self, width):
        """Creates the gtk widgets

        @param width: the width of the Gtk.Label object
        """
        label = Gtk.Label(label=f"{self.description}:")
        label.set_line_wrap(True)
        label.set_alignment(xalign=0, yalign=0.5)
        label.set_size_request(width=width, height=-1)
        self.pack_start(label, False, True, 0)
        align = Gtk.Alignment.new(0, 0.5, 1, 0)
        align.set_padding(0, 0, 10, 0)
        self.pack_start(align, True, True, 0)
        self.textbox = Gtk.Entry()
        backend_parameters = self.backend.get_parameters()[self.parameter_name]
        self.textbox.set_text(backend_parameters)
        self.textbox.connect('changed', self.on_text_modified)
        align.add(self.textbox) 
Example #6
Source File: path.py    From gtg with GNU General Public License v3.0 6 votes vote down vote up
def _populate_gtk(self, width):
        """Creates the Gtk.Label, the textbox and the button

        @param width: the width of the Gtk.Label object
        """
        label = Gtk.Label(label=_("Filename:"))
        label.set_line_wrap(True)
        label.set_alignment(xalign=0, yalign=0.5)
        label.set_size_request(width=width, height=-1)
        self.pack_start(label, False, True, 0)
        align = Gtk.Alignment.new(0, 0.5, 1, 0)
        align.set_padding(0, 0, 10, 0)
        self.pack_start(align, True, True, 0)
        self.textbox = Gtk.Entry()
        self.textbox.set_text(self.backend.get_parameters()['path'])
        self.textbox.connect('changed', self.on_path_modified)
        align.add(self.textbox)
        self.button = Gtk.Button()
        self.button.set_label("Edit")
        self.button.connect('clicked', self.on_button_clicked)
        self.pack_start(self.button, False, True, 0) 
Example #7
Source File: combobox_enhanced.py    From gtg with GNU General Public License v3.0 6 votes vote down vote up
def smartifyComboboxEntry(combobox, list_obj, callback):
    entry = Gtk.Entry()
    # check if Clipboard contains an element of the list
    clipboard = Gtk.Clipboard()
    ifClipboardTextIsInListCallback(clipboard, list_obj, entry.set_text)
    # pressing Enter will cause the callback
    ifKeyPressedCallback(entry, "Return", callback)
    # wrap the combo-box if it's too long
    if len(list_obj) > 15:
        combobox.set_wrap_width(5)
    # populate the combo-box
    if len(list_obj) > 0:
        list_store = listStoreFromList(list_obj)
        entry.set_completion(completionFromListStore(list_store))
        combobox.set_model(list_store)
        combobox.set_active(0)
        entry.set_text(list_store[0][0])
    combobox.add(entry)
    combobox.connect('changed', setText, entry)
    # render the combo-box drop down menu
    cell = Gtk.CellRendererText()
    combobox.pack_start(cell, True)
    combobox.add_attribute(cell, 'text', 0)
    return entry 
Example #8
Source File: prefs.py    From volctl with GNU General Public License v2.0 6 votes vote down vote up
def _setup_mixer_command(self):
        key = self._schema.get_key("mixer-command")
        row = Gtk.ListBoxRow()
        row.set_tooltip_text(key.get_description())

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        row.add(hbox)
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        hbox.pack_start(vbox, True, True, 10)

        label = Gtk.Label(key.get_summary(), xalign=0)
        vbox.pack_start(label, True, True, 0)
        entry = Gtk.Entry().new()
        self._settings.bind(
            "mixer-command", entry, "text", Gio.SettingsBindFlags.DEFAULT
        )
        hbox.pack_start(entry, False, True, 10)

        self.listbox.add(row) 
Example #9
Source File: editordialog.py    From syncthing-gtk with GNU General Public License v2.0 6 votes vote down vote up
def display_value(self, key, w):
		"""
		Sets value on UI element for single key. May be overridden
		by subclass to handle special values.
		"""
		if isinstance(w, Gtk.SpinButton):
			w.get_adjustment().set_value(ints(self.get_value(strip_v(key))))
		elif isinstance(w, Gtk.Entry):
			w.set_text(unicode(self.get_value(strip_v(key))))
		elif isinstance(w, Gtk.ComboBox):
			val = self.get_value(strip_v(key))
			m = w.get_model()
			for i in xrange(0, len(m)):
				if str(val) == str(m[i][0]).strip():
					w.set_active(i)
					break
			else:
				w.set_active(0)
		elif isinstance(w, Gtk.CheckButton):
			w.set_active(self.get_value(strip_v(key)))
		else:
			log.warning("display_value: %s class cannot handle widget %s, key %s", self.__class__.__name__, w, key)
			if not w is None: w.set_sensitive(False) 
Example #10
Source File: FlatCAMApp.py    From FlatCAM with MIT License 6 votes vote down vote up
def get_eval(self, widget_name):
        """
        Runs eval() on the on the text entry of name 'widget_name'
        and returns the results.

        :param widget_name: Name of Gtk.Entry
        :type widget_name: str
        :return: Depends on contents of the entry text.
        """

        value = self.builder.get_object(widget_name).get_text()
        if value == "":
            value = "None"
        try:
            evald = eval(value)
            return evald
        except:
            self.info("Could not evaluate: " + value)
            return None 
Example #11
Source File: keyboard.py    From hazzy with GNU General Public License v2.0 6 votes vote down vote up
def demo():
    keyboard = Keyboard()

    box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

    entry = Gtk.Entry()
    entry.set_hexpand(False)
    entry.set_vexpand(False)
    entry.connect('focus-in-event', show)
    entry.connect('activate', on_activate)
    box.pack_start(entry, False, False, 5)

    window = Gtk.Window(title="Test Keyboard")
    window.connect('button-press-event', on_button_press)
    window.connect('destroy', Gtk.main_quit)
    window.add(box)

    window.set_size_request(1000, 400)
    window.show_all()

    Gtk.main() 
Example #12
Source File: GUIElements.py    From FlatCAM with MIT License 6 votes vote down vote up
def __init__(self, output_units='IN'):
        """

        :param output_units: The default output units, 'IN' or 'MM'
        :return: LengthEntry
        """

        Gtk.Entry.__init__(self)
        self.output_units = output_units
        self.format_re = re.compile(r"^([^\s]+)(?:\s([a-zA-Z]+))?$")

        # Unit conversion table OUTPUT-INPUT
        self.scales = {
            'IN': {'IN': 1.0,
                   'MM': 1/25.4},
            'MM': {'IN': 25.4,
                   'MM': 1.0}
        }

        self.connect('activate', self.on_activate) 
Example #13
Source File: colors_list.py    From oomox with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, display_name, key, callback, transient_for):
        self.color_button = OomoxColorButton(
            transient_for=transient_for,
            callback=self.on_color_set
        )
        self.color_entry = Gtk.Entry(
            text=_('<none>'), width_chars=6, max_length=6
        )
        self.menu_button = OomoxLinkedDropdown(transient_for)
        self.color_entry.get_style_context().add_class(Gtk.STYLE_CLASS_MONOSPACE)
        linked_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        Gtk.StyleContext.add_class(
            linked_box.get_style_context(), "linked"
        )
        linked_box.add(self.color_entry)
        linked_box.add(self.color_button)
        linked_box.add(self.menu_button)
        super().__init__(
            display_name=display_name,
            key=key,
            callback=callback,
            value_widget=linked_box
        ) 
Example #14
Source File: docreport.py    From amir with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        self.builder = get_builder("report")

        self.window = self.builder.get_object("window2")

        self.number = Gtk.Entry()  # numberentry.NumberEntry()
        box = self.builder.get_object("numbox")
        box.add(self.number)
        self.number.set_activates_default(True)
        self.number.show()
        self.builder.get_object("message").set_text("")
        self.window.show_all()
        self.builder.get_object("buttonPreview").connect(
            "clicked", self.previewReport)
        self.builder.get_object("buttonExport").connect(
            "clicked", self.exportToCSV)
        self.builder.get_object("buttonPrint").connect(
            "clicked", self.printReport) 
Example #15
Source File: add.py    From Authenticator with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, **kwargs):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
        GObject.GObject.__init__(self)

        self.is_edit = kwargs.get("edit", False)
        self._account = kwargs.get("account", None)

        self._providers_store = Gtk.ListStore(str, str)

        self.logo_img = Gtk.Image()
        self.username_entry = Gtk.Entry()
        self.provider_combo = Gtk.ComboBox.new_with_model_and_entry(
            self._providers_store)
        self.token_entry = Gtk.Entry()
        self._build_widgets()
        self._fill_data() 
Example #16
Source File: msgbox.py    From eavatar-me with Apache License 2.0 6 votes vote down vote up
def input(title, message):
    dialog = Gtk.MessageDialog(None,
                               (Gtk.DialogFlags.MODAL |
                                Gtk.DialogFlags.DESTROY_WITH_PARENT),
                               Gtk.MessageType.QUESTION,
                               Gtk.ButtonsType.OK_CANCEL,
                               title)
    dialog.format_secondary_text(message)

    dialogBox = dialog.get_content_area()
    userEntry = Gtk.Entry()
    # userEntry.set_visibility(True)
    # userEntry.set_invisible_char("*")
    userEntry.set_size_request(250, 0)
    userEntry.set_text("")
    dialogBox.pack_end(userEntry, False, False, 0)

    dialog.show_all()
    response = dialog.run()
    text = userEntry.get_text()
    dialog.destroy()
    if response == Gtk.ResponseType.OK:
        return text
    else:
        return None 
Example #17
Source File: editable_label.py    From pympress with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, builder, ett = 0):
        super(EstimatedTalkTime, self).__init__()

        self.entry_ett = Gtk.Entry()

        builder.load_widgets(self)
        builder.get_object('nav_goto').set_name('nav_goto')
        builder.get_object('nav_jump').set_name('nav_jump')

        self.set_time(ett)

        self.event_box = self.eb_ett 
Example #18
Source File: settings.py    From Authenticator with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, label, is_password=False):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
        self.get_style_context().add_class("settings-box")
        self.entry = Gtk.Entry()
        if is_password:
            self.entry.set_visibility(False)
        self._build_widgets(label) 
Example #19
Source File: GUIElements.py    From FlatCAM with MIT License 5 votes vote down vote up
def __init__(self):
        Gtk.Entry.__init__(self) 
Example #20
Source File: GUIElements.py    From FlatCAM with MIT License 5 votes vote down vote up
def __init__(self):
        Gtk.Entry.__init__(self) 
Example #21
Source File: GUIElements.py    From FlatCAM with MIT License 5 votes vote down vote up
def __init__(self):
        Gtk.Entry.__init__(self)

        self.connect('activate', self.on_activate) 
Example #22
Source File: gui_utilities.py    From king-phisher with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def delayed_signal(delay=500):
	"""
	A decorator to delay the execution of a signal handler to aggregate emission
	into a single event. This can for example be used to run a handler when a
	:py:class:`Gtk.Entry` widget's ``changed`` signal is emitted but not after
	every single key press meaning the handler can perform network operations to
	validate or otherwise process input.

	.. note::
		The decorated function **must** be a method. The wrapper installed by
		this decorator will automatically add an attribute to the class to track
		invoked instances to ensure the timeout is respected.

	.. versionadded:: 1.14.0

	:param int delay: The delay in milliseconds from the original emission
		before the handler should be executed.
	"""
	def decorator(function):
		src_name = '__delayed_source_' + function.__name__
		@functools.wraps(function)
		def wrapped(self, *args, **kwargs):
			def new_function(self, *args, **kwargs):
				setattr(self, src_name, None)
				return function(self, *args, **kwargs)
			src = getattr(self, src_name, None)
			if src is not None:
				return
			src = GLib.timeout_add(delay, new_function, self, *args, **kwargs)
			setattr(self, src_name, src)
		return wrapped
	return decorator 
Example #23
Source File: FlatCAMApp.py    From FlatCAM with MIT License 5 votes vote down vote up
def on_eval_update(self, widget):
        """
        Modifies the content of a Gtk.Entry by running
        eval() on its contents and puting it back as a
        string.

        :param widget: The widget from which this was called.
        :return: None
        """
        # TODO: error handling here
        widget.set_text(str(eval(widget.get_text())))

    # def on_cncjob_exportgcode(self, widget):
    #     """
    #     Called from button on CNCjob form to save the G-Code from the object.
    #
    #     :param widget: The widget from which this was called.
    #     :return: None
    #     """
    #     def on_success(app_obj, filename):
    #         cncjob = app_obj.collection.get_active()
    #         f = open(filename, 'w')
    #         f.write(cncjob.gcode)
    #         f.close()
    #         app_obj.info("Saved to: " + filename)
    #
    #     self.file_chooser_save_action(on_success) 
Example #24
Source File: plugins.py    From king-phisher with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def get_widget(self, _, value):
		if self.multiline:
			scrolled_window = Gtk.ScrolledWindow()
			textview = extras.MultilineEntry()
			textview.set_property('hexpand', True)
			scrolled_window.add(textview)
			scrolled_window.set_property('height-request', 60)
			scrolled_window.set_property('vscrollbar-policy', Gtk.PolicyType.ALWAYS)
			widget = scrolled_window
		else:
			widget = Gtk.Entry()
			widget.set_hexpand(True)
		self.set_widget_value(widget, value)
		return widget 
Example #25
Source File: FlatCAMApp.py    From FlatCAM with MIT License 5 votes vote down vote up
def on_toggle_pointbox(self, widget):
        """
        Callback for radio selection change between point and box in the
        Double-sided PCB tool. Updates the UI accordingly.

        :param widget: Ignored.
        :return: None
        """

        # Where the entry or combo go
        box = self.builder.get_object("box_pointbox")

        # Clear contents
        children = box.get_children()
        for child in children:
            box.remove(child)

        choice = self.get_radio_value({"rb_mirror_point": "point",
                                       "rb_mirror_box": "box"})

        if choice == "point":
            self.point_entry = Gtk.Entry()
            self.builder.get_object("box_pointbox").pack_start(self.point_entry,
                                                               False, False, 1)
            self.point_entry.show()
        else:
            self.box_combo = Gtk.ComboBoxText()
            self.builder.get_object("box_pointbox").pack_start(self.box_combo,
                                                               False, False, 1)
            self.populate_objects_combo(self.box_combo)
            self.box_combo.show() 
Example #26
Source File: parental_config.py    From kano-settings with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, win):
        entry = Gtk.Entry()
        entry.set_visibility(False)
        self.win = win
        KanoDialog.__init__(
            self,
            title_text=_("Parental Authentication"),
            description_text=_("Enter your parental password:"),
            widget=entry,
            has_entry=True,
            global_style=True,
            parent_window=self.win
        ) 
Example #27
Source File: widgets.py    From badKarma with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, url, proxy=False, *args, **kwargs):
		super(WebView, self).__init__(*args, **kwargs)
		""" WebKit2 Webview widget """

		web_context = WebKit2.WebContext.get_default()
		web_context.set_tls_errors_policy(WebKit2.TLSErrorsPolicy.IGNORE)

		if proxy:
			# proxy False or "http://127.0.0.1:8080"
			web_context.set_network_proxy_settings(WebKit2.NetworkProxyMode.CUSTOM, WebKit2.NetworkProxySettings.new(proxy))
		
		self.set_hexpand(True)
		self.set_vexpand(True)

		self.toolbar = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

		self.address_bar = Gtk.Entry()
		self.go_button = Gtk.Button("go")

		self.address_bar.set_text(url)

		self.toolbar.add(self.address_bar)
		self.toolbar.add(self.go_button)

		if proxy:
			GLib.timeout_add_seconds(2, self._reload)

		self.toolbar.set_hexpand(True)
		self.address_bar.set_hexpand(True)

		self.load_uri(url)
		self.toolbar.show_all()
		self.show_all()

		self.load_uri(url)

		self.connect("load-changed", self._load_changed)
		self.go_button.connect("clicked", self._load_uri) 
Example #28
Source File: editordialog.py    From syncthing-gtk with GNU General Public License v2.0 5 votes vote down vote up
def store_value(self, key, w):
		"""
		Loads single value from UI element to self.values dict. May be
		overriden by subclass to handle special values.
		"""
		if isinstance(w, Gtk.SpinButton):
			self.set_value(strip_v(key), int(w.get_adjustment().get_value()))
		elif isinstance(w, Gtk.Entry):
			self.set_value(strip_v(key), w.get_text().decode("utf-8"))
		elif isinstance(w, Gtk.CheckButton):
			self.set_value(strip_v(key), w.get_active())
		elif isinstance(w, Gtk.ComboBox):
			self.set_value(strip_v(key), str(w.get_model()[w.get_active()][0]).strip())
		# else nothing, unknown widget class cannot be read 
Example #29
Source File: gtk.py    From encompass with GNU General Public License v3.0 5 votes vote down vote up
def run_recovery_dialog():
    message = "Please enter your wallet seed or the corresponding mnemonic list of words, and the gap limit of your wallet."
    dialog = Gtk.MessageDialog(
        parent = None,
        flags = Gtk.DialogFlags.MODAL, 
        buttons = Gtk.ButtonsType.OK_CANCEL,
        message_format = message)

    vbox = dialog.vbox
    dialog.set_default_response(Gtk.ResponseType.OK)

    # ask seed, server and gap in the same dialog
    seed_box = Gtk.HBox()
    seed_label = Gtk.Label(label='Seed or mnemonic:')
    seed_label.set_size_request(150,-1)
    seed_box.pack_start(seed_label, False, False, 10)
    seed_label.show()
    seed_entry = Gtk.Entry()
    seed_entry.show()
    seed_entry.set_size_request(450,-1)
    seed_box.pack_start(seed_entry, False, False, 10)
    add_help_button(seed_box, '.')
    seed_box.show()
    vbox.pack_start(seed_box, False, False, 5)    

    dialog.show()
    r = dialog.run()
    seed = seed_entry.get_text()
    dialog.destroy()

    if r==Gtk.ResponseType.CANCEL:
        return False

    if Wallet.is_seed(seed):
        return seed

    show_message("no seed")
    return False 
Example #30
Source File: GUIElements.py    From FlatCAM with MIT License 5 votes vote down vote up
def __init__(self):
        Gtk.Entry.__init__(self)