Python gi.repository.Gtk.CheckButton() Examples

The following are 30 code examples of gi.repository.Gtk.CheckButton(). 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: 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 #2
Source File: __main__.py    From HydraPaper with GNU General Public License v3.0 6 votes vote down vote up
def all_wallpaper_folder_interactives_set_sensitive(self, sensitive):
        # listbox
        # --> listboxrow []
        #     --> box
        #         --> checkbutton
        #         --> label
        #         --> button
        for child in self.wallpapers_folders_popover_listbox.get_children():
            for subchild in child.get_child().get_children():
                if type(subchild) in [Gtk.CheckButton, Gtk.Button]:
                    subchild.set_sensitive(sensitive)
        self.add_to_favorites_toggle.set_sensitive(sensitive)
        self.builder.get_object('addWallpapersPath').set_sensitive(sensitive)
        self.on_wallpapersFoldersPopoverListbox_row_selected(
            self.wallpapers_folders_popover_listbox,
            self.wallpapers_folders_popover_listbox.get_selected_row()
        ) 
Example #3
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()
        (on_off_state, filename) = value_str.split(',',1)
        self.cb_w = Gtk.CheckButton("")
        self.cb_w.connect('toggled', self.__value_changed)
        self.l_w = Gtk.Label("")
        self.l_w.set_sensitive(False)
        self.fe_w = FileEntry(filename, _("Give a filename ..."))
        #self.fe_w.connect('changed', self.__value_changed)
        self.fe_w.set_sensitive(False)
        self.cb_w.set_active(on_off_state == 'True')
        self.pack_start(self.cb_w, False, True, 0)
        self.pack_start(self.l_w, False, True, 0)
        self.pack_start(self.fe_w, False, True, 0)
        self.set_tooltip_text(self.__option.get_help()) 
Example #4
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()
        (wrap_html, html_file) = value_str.split(', ',1)
        self.cb_w = Gtk.CheckButton("")
        self.cb_w.connect('toggled', self.__value_changed)
        self.l_w = Gtk.Label(_("Name HTML-wrapper file"))
        self.l_w.set_sensitive(False)
        self.fe_w = FileEntry(html_file, _("Save HTML-wrapper file as ..."))
        self.fe_w.entry.connect('changed', self.__value_changed);
        self.fe_w.set_sensitive(False)
        self.cb_w.set_active(wrap_html == 'True')
        self.pack_start(self.cb_w, False, True, 0)
        self.pack_start(self.l_w, False, True, 0)
        self.pack_start(self.fe_w, False, True, 0)
        self.set_tooltip_text(self.__option.get_help()) 
Example #5
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()
        (copy_img, copy_dir) = value_str.split(', ',1)
        self.cb_w = Gtk.CheckButton(label="")
        self.cb_w.connect('toggled', self.__value_changed)
        self.l_w = Gtk.Label(label=_('to directory:'))
        self.l_w.set_sensitive(False)
        self.fe_w = FileEntry(copy_dir, _('Save images in ...'))
        self.fe_w.set_directory_entry(True)
        self.fe_w.entry.connect('changed', self.__value_changed)
        #self.fe_w.connect('changed', self.__value_changed)
        # Update ReportBase/_FileEntry.py so that signal changed is OK
        self.fe_w.set_sensitive(False)
        self.cb_w.set_active(copy_img == 'True')
        self.pack_start(self.cb_w, False, True, 0)
        self.pack_end(self.fe_w, True, True, 0)
        self.pack_end(self.l_w, False, True, 5)
        self.set_tooltip_text(self.__option.get_help()) 
Example #6
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 #7
Source File: FlatCAMObj.py    From FlatCAM with MIT License 6 votes vote down vote up
def show_tool_chooser(self):
        win = Gtk.Window()
        box = Gtk.Box(spacing=2)
        box.set_orientation(Gtk.Orientation(1))
        win.add(box)
        for tool in self.tools:
            self.tool_cbs[tool] = Gtk.CheckButton(label=tool + ": " + str(self.tools[tool]))
            box.pack_start(self.tool_cbs[tool], False, False, 1)
        button = Gtk.Button(label="Accept")
        box.pack_start(button, False, False, 1)
        win.show_all()

        def on_accept(widget):
            win.destroy()
            tool_list = []
            for toolx in self.tool_cbs:
                if self.tool_cbs[toolx].get_active():
                    tool_list.append(toolx)
            self.options["toolselection"] = ", ".join(tool_list)
            self.to_form()

        button.connect("activate", on_accept)
        button.connect("clicked", on_accept) 
Example #8
Source File: combinedview.py    From addons-source with GNU General Public License v2.0 6 votes vote down vote up
def config_panel(self, configdialog):
        """
        Function that builds the widget in the configuration dialog
        """
        grid = Gtk.Grid()
        grid.set_border_width(12)
        grid.set_column_spacing(6)
        grid.set_row_spacing(6)

        configdialog.add_checkbox(grid,
                _('Use shading'),
                0, 'preferences.relation-shade')
        configdialog.add_checkbox(grid,
                _('Display edit buttons'),
                1, 'preferences.releditbtn')
        checkbox = Gtk.CheckButton(label=_('View links as website links'))
        theme = self._config.get('preferences.relation-display-theme')
        checkbox.set_active(theme == 'WEBPAGE')
        checkbox.connect('toggled', self._config_update_theme)
        grid.attach(checkbox, 1, 2, 8, 1)

        return _('Layout'), grid 
Example #9
Source File: DownloadPage.py    From bcloud with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, app, multiple_files):
        if multiple_files:
            text = _('Do you want to remove unfinished tasks?')
        else:
            text = _('Do you want to remove unfinished task?')
        super().__init__(app.window, Gtk.DialogFlags.MODAL,
                         Gtk.MessageType.WARNING, Gtk.ButtonsType.YES_NO,
                         text)
        self.app = app
        box = self.get_message_area()
        remember_button = Gtk.CheckButton(_('Do not ask again'))
        remember_button.set_active(
                not self.app.profile['confirm-download-deletion'])
        remember_button.connect('toggled', self.on_remember_button_toggled)
        box.pack_start(remember_button, False, False, 0)
        box.show_all() 
Example #10
Source File: set_advanced.py    From kano-settings with GNU General Public License v2.0 6 votes vote down vote up
def create_parental_button(self):
        desc = (
            _(" Use different levels to:\n"
              "- Block mature content in browser and YouTube\n"
              "- Or restrict internet access to only Kano World activity")
        ).split('\n')

        self.parental_button = Gtk.CheckButton()
        box = LabelledListTemplate.label_button(
            self.parental_button,
            _("Parental lock"),
            desc[0])

        grid = self._labelled_list_helper(desc, box)

        if get_parental_enabled():
            parental_config_button = OrangeButton(_("Configure"))
            parental_config_button.connect('button-press-event',
                                           self.go_to_parental_config)
            grid.attach(parental_config_button, 0, len(desc), 1, 1)

        return grid 
Example #11
Source File: dialog.py    From RAFCON with Eclipse Public License 1.0 6 votes vote down vote up
def __init__(self, markup_text=None, button_texts=None, checkbox_texts=None,
                 callback=None, callback_args=(),
                 message_type=Gtk.MessageType.INFO, flags=Gtk.DialogFlags.MODAL, parent=None,
                 width=-1, standalone=False, title="RAFCON", height=-1):

        super(RAFCONColumnCheckboxDialog, self).__init__(markup_text, button_texts, callback, callback_args,
                                                         message_type, flags, parent, width, standalone, title, height)

        checkbox_vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, constants.GRID_SIZE)
        self.get_content_area().add(checkbox_vbox)
        # this is not really needed i guess if I can get the checkboxes over the content area anyway
        # TODO change this to a solution without the list.

        if checkbox_texts:
            self.checkboxes = []

            for index, checkbox in enumerate(checkbox_texts):
                self.checkboxes.append(Gtk.CheckButton(label=checkbox))
                checkbox_vbox.pack_start(self.checkboxes[index], True, True, 1)
        else:
            logger.debug("Argument checkbox_text is None or empty, no checkboxes were created")

        self.show_all()
        self.run() if standalone else None 
Example #12
Source File: deviceeditor.py    From syncthing-gtk with GNU General Public License v2.0 6 votes vote down vote up
def display_value(self, key, w):
		if key == "vfolders":
			# Even more special case
			rids = [ ]
			# Get list of folders that share this device
			for r in self.config["folders"]:
				for n in r["devices"]:
					if n["deviceID"] == self.id and r["id"] not in rids:
						rids.append(r["id"])
			# Create CheckButtons
			for folder in reversed(sorted(self.app.folders.values(), key=lambda x : x["id"])):
				b = Gtk.CheckButton(folder["path"], False)
				b.set_tooltip_text(folder["id"])
				self["vfolders"].pack_start(b, False, False, 0)
				b.set_active(folder["id"] in rids)
			self["vfolders"].show_all()
		else:
			EditorDialog.display_value(self, key, w)
	
	#@Overrides 
Example #13
Source File: preferences_window.py    From RAFCON with Eclipse Public License 1.0 6 votes vote down vote up
def __init__(self, core_config_model, view, gui_config_model):
        assert isinstance(view, PreferencesWindowView)
        assert isinstance(core_config_model, ConfigModel)
        assert isinstance(gui_config_model, ConfigModel)
        ExtendedController.__init__(self, core_config_model, view)
        self.core_config_model = core_config_model
        self.gui_config_model = gui_config_model
        self.observe_model(gui_config_model)

        # (config_key, config_value, text_visible, toggle_activatable, toggle_visible, text_editable, toggle_value)
        self.core_list_store = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING, bool, bool, bool, bool, bool)
        self.library_list_store = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING)
        self.gui_list_store = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING, bool, bool, bool, bool, bool)
        self.shortcut_list_store = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING)

        self._lib_counter = 0
        self._gui_checkbox = Gtk.CheckButton(label="GUI Config")
        self._core_checkbox = Gtk.CheckButton(label="Core Config")
        self._last_path = self.core_config_model.config.path 
Example #14
Source File: app.py    From syncthing-gtk with GNU General Public License v2.0 5 votes vote down vote up
def quit(self, *a):
		if self.process != None:
			if IS_WINDOWS:
				# Always kill subprocess on windows
				self.process.kill()
				self.process = None
			elif self.config["autokill_daemon"] == 2:	# Ask
				d = Gtk.MessageDialog(
					self["window"],
					Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
					Gtk.MessageType.INFO, 0,
					"%s\n%s" % (
						_("Exiting."),
						_("Shutdown Syncthing daemon as well?")
						)
					)
				d.add_button("gtk-yes",	RESPONSE_SLAIN_DAEMON)
				d.add_button("gtk-no",	RESPONSE_SPARE_DAEMON)
				cb = Gtk.CheckButton(_("Always do same; Don't show this window again"))
				d.get_content_area().pack_end(cb, False, False, 2)
				d.connect("response", self.cb_kill_daemon_response, cb)
				d.show_all()
				return
			elif self.config["autokill_daemon"] == 1: # Yes
				self.process.terminate()
				self.process = None
		Gtk.Application.quit(self) 
Example #15
Source File: foldereditor.py    From syncthing-gtk with GNU General Public License v2.0 5 votes vote down vote up
def display_value(self, key, w):
		if key == "vdevices":
			# Very special case
			nids = [ n["deviceID"] for n in self.get_value("devices") ]
			for device in self.app.devices.values():
				if device["id"] != self.app.daemon.get_my_id():
					b = Gtk.CheckButton(device.get_title(), False)
					b.set_tooltip_text(device["id"])
					self["vdevices"].pack_start(b, False, False, 0)
					b.set_active(device["id"] in nids)
			self["vdevices"].show_all()
		else:
			EditorDialog.display_value(self, key, w)
	
	#@Overrides 
Example #16
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 #17
Source File: row.py    From Authenticator with GNU General Public License v2.0 5 votes vote down vote up
def checked(self):
        """
            Whether the CheckButton is active or not.
            :return: bool
        """
        return self.check_btn.get_active() 
Example #18
Source File: intelligent_text_completion.py    From gedit-intelligent-text-completion with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _add_setting_checkbox(self, vbox, current_value, helptext):
        box = Gtk.HBox()
        check_button = Gtk.CheckButton(helptext)
        check_button.set_active(current_value)
        box.pack_start(check_button,False,False,6)
        check_button.connect('toggled', self._on_check_button_toggled)
        vbox.pack_start(box, False, True, 0)
        return check_button 
Example #19
Source File: intelligent_text_completion.py    From gedit-intelligent-text-completion with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _add_setting_checkbox(self, vbox, current_value, helptext):
        box = Gtk.HBox()
        check_button = Gtk.CheckButton(helptext)
        check_button.set_active(current_value)
        box.pack_start(check_button,False,False,6)
        check_button.connect('toggled', self._on_check_button_toggled)
        vbox.pack_start(box, False, True, 0)
        return check_button 
Example #20
Source File: GUIElements.py    From FlatCAM with MIT License 5 votes vote down vote up
def __init__(self, label=''):
        Gtk.CheckButton.__init__(self, label=label) 
Example #21
Source File: pref_widgets.py    From hazzy with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, section, option, default_value=False):
        Gtk.CheckButton.__init__(self)

        self.section = section
        self.option = option
        self.default_value = default_value

        self.connect('toggled', self.on_toggle)

        self.state = prefs.get(self.section, self.option, self.default_value, bool)
        self.set_active(self.state) 
Example #22
Source File: preferences.py    From drawing with GNU General Public License v3.0 5 votes vote down vote up
def build_check_btn(self, label, row_id, key):
		btn = Gtk.CheckButton(label=label, visible=True)
		array_of_strings = self._settings.get_strv(key)
		btn.set_active(row_id not in array_of_strings)
		btn.connect('toggled', self.on_check_btn_changed, key, row_id)
		return btn

	############################################################################
	# Generic callbacks ######################################################## 
Example #23
Source File: widgets.py    From zim-desktop-wiki with GNU General Public License v2.0 5 votes vote down vote up
def __getitem__(self, key):
		if not key in self._keys:
			raise KeyError(key)
		elif key in self.widgets:
			widget = self.widgets[key]
			if isinstance(widget, LinkEntry):
				return widget.get_text() # Could be either page or file
			elif isinstance(widget, (PageEntry, NamespaceEntry)):
				return widget.get_path()
			elif isinstance(widget, FSPathEntry):
				return widget.get_path()
			elif isinstance(widget, InputEntry):
				return widget.get_text()
			elif isinstance(widget, Gtk.CheckButton):
				return widget.get_active()
			elif isinstance(widget, Gtk.ComboBox):
				if hasattr(widget, 'zim_key_mapping'):
					label = widget.get_active_text()
					return widget.zim_key_mapping.get(label) or label
				else:
					return widget.get_active_text()
			elif isinstance(widget, Gtk.SpinButton):
				return int(widget.get_value())
			elif isinstance(widget, Gtk.ColorButton):
				return widget.get_rgba().to_string()
			else:
				raise TypeError(widget.__class__.name)
		else:
			# Group of RadioButtons
			for name, widget in self._get_radiogroup(key):
				if widget.get_active():
					x, name = name.rsplit(':', 1)
						# using rsplit to assure another ':' in the
						# group name is harmless
					return name 
Example #24
Source File: sourceview.py    From zim-desktop-wiki with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, parent):
		Dialog.__init__(self, parent, _('Insert Code Block')) # T: dialog title
		self.result = (None, None)
		self.uistate.define(lang=String(None))
		self.uistate.define(line_numbers=Boolean(True))
		defaultlang = self.uistate['lang']

		menu = {}
		for l in sorted(LANGUAGES, key=lambda k: k.lower()):
			key = l[0].upper()
			if not key in menu:
				menu[key] = []
			menu[key].append(l)

		model = Gtk.TreeStore(str)
		defaultiter = None
		for key in sorted(menu):
			iter = model.append(None, [key])
			for lang in menu[key]:
				myiter = model.append(iter, [lang])
				if LANGUAGES[lang] == defaultlang:
					defaultiter = myiter

		hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
		hbox.set_spacing(5)
		label = Gtk.Label(_('Syntax') +':') # T: input label
		hbox.add(label)

		combobox = Gtk.ComboBox.new_with_model(model)
		renderer_text = Gtk.CellRendererText()
		combobox.pack_start(renderer_text, True)
		combobox.add_attribute(renderer_text, "text", 0)
		if defaultiter is not None:
			combobox.set_active_iter(defaultiter)
		hbox.add(combobox)
		self.combobox = combobox
		self.vbox.add(hbox)
		self.checkbox = Gtk.CheckButton(_('Display line numbers')) # T: input checkbox
		self.checkbox.set_active(self.uistate['line_numbers'])
		self.vbox.add(self.checkbox) 
Example #25
Source File: options.py    From rednotebook with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, text, name, value=None, tooltip=""):
        Option.__init__(self, "", name, tooltip=tooltip)

        self.check_button = Gtk.CheckButton(text)
        if value is None:
            self.check_button.set_active(Option.config.read(name) == 1)
        else:
            self.check_button.set_active(value)
        self.check_button.connect("clicked", self.on_check_button_clicked)
        self.pack_start(self.check_button, False, False, 0) 
Example #26
Source File: app.py    From syncthing-gtk with GNU General Public License v2.0 5 votes vote down vote up
def display_run_daemon_dialog(self):
		"""
		Displays 'Syncthing is not running, should I start it for you?'
		dialog.
		"""
		if self.connect_dialog == None: # Don't override already existing dialog
			log.debug("Creating run_daemon_dialog")
			self.connect_dialog = Gtk.MessageDialog(
				self["window"],
				Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
				Gtk.MessageType.INFO, 0,
				"%s\n%s" % (
					_("Syncthing daemon doesn't appear to be running."),
					_("Start it now?")
					)
				)
			cb = Gtk.CheckButton(_("Always start daemon automatically"))
			self.connect_dialog.get_content_area().pack_end(cb, False, False, 2)
			self.connect_dialog.add_button("_Start",   RESPONSE_START_DAEMON)
			self.connect_dialog.add_button("gtk-quit", RESPONSE_QUIT)
			# There is only one response available on this dialog
			self.connect_dialog.connect("response", self.cb_connect_dialog_response, cb)
			if self.is_visible():
				self.connect_dialog.show_all()
			else:
				cb.show()	# Keep this one visible, even if dialog is not
			# Update notification icon menu so user can start daemon from there
			self["menu-si-shutdown"].set_visible(False)
			self["menu-si-resume"].set_visible(True) 
Example #27
Source File: state_substitute.py    From RAFCON with Eclipse Public License 1.0 5 votes vote down vote up
def __init__(self, model, width=500, height=600, pos=None, parent=None):
        self.model = model

        super(StateSubstituteChooseLibraryDialog, self).__init__("Choose a Library to substitute the state with.",
                                                                 ['As library', 'As template', 'Cancel'],
                                                                 title='Library choose dialog',
                                                                 callback=self.check_for_library_path,
                                                                 message_type=Gtk.MessageType.INFO,
                                                                 flags=Gtk.DialogFlags.MODAL, parent=parent)

        self.set_title('Library choose dialog')
        self.resize(width=width, height=height)
        if pos is not None:
            self.move(*pos)

        self.set_resizable(True)

        self.scrollable = Gtk.ScrolledWindow()
        self.widget_view = LibraryTreeView()
        self.widget_ctrl = StateSubstituteChooseLibraryDialogTreeController(self.model, self.widget_view,
                                                                            dialog_widget=self)
        self.scrollable.add(self.widget_view)

        self.keep_name_check_box = Gtk.CheckButton()
        self.keep_name_check_box.set_active(self.widget_ctrl.keep_name)
        self.keep_name_check_box.set_label("Keep state name")
        self.keep_name_check_box.connect('toggled', self.on_toggle_keep_name)

        self.vbox.pack_end(self.keep_name_check_box, False, False, 0)
        self.vbox.pack_start(self.scrollable, True, True, 0)

        self.vbox.show_all()
        self.grab_focus()
        self.run() 
Example #28
Source File: dialog.py    From RAFCON with Eclipse Public License 1.0 5 votes vote down vote up
def __init__(self, markup_text=None, button_texts=None, checkbox_text=None,
                 callback=None, callback_args=(),
                 message_type=Gtk.MessageType.INFO, flags=Gtk.DialogFlags.MODAL, parent=None,
                 width=-1, standalone=False, title="RAFCON", height=-1):

        super(RAFCONInputDialog, self).__init__(markup_text, button_texts, callback, callback_args,
                                                message_type, flags, parent, width, standalone, title, height)

        # Create a new Gtk.Hbox to put in the checkbox and entry
        hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, constants.GRID_SIZE)
        self.get_content_area().add(hbox)

        # Setup new text entry line
        self.entry = Gtk.Entry()
        self.entry.set_editable(True)
        self.entry.set_activates_default(True)
        self.entry.set_width_chars(10)

        # Hitting the enter button responds 1 from the widget
        # This is the same as the first button, so the first button should always be sth. approving the content of the
        # window. Probably a configurable flag would also make sense.
        self.entry.connect('activate', self.forward_response, 1)
        hbox.pack_start(self.entry, True, True, 1)

        self.checkbox = None

        if isinstance(checkbox_text, string_types):
            # If a checkbox_text is specified by the caller, we can assume that one should be used.
            self.checkbox = Gtk.CheckButton(label=checkbox_text)
            hbox.pack_end(self.checkbox, False, True, 1)
        hbox.show_all()

        self.show_grab_focus_and_run(standalone) 
Example #29
Source File: row.py    From Authenticator with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, account):
        """
        :param account: Account
        """
        Gtk.ListBoxRow.__init__(self)
        self.get_style_context().add_class("account-row")
        self._account = account
        self.check_btn = Gtk.CheckButton()

        self._account.connect("otp_updated", self._on_pin_updated)
        self._build_widget()
        self.show_all() 
Example #30
Source File: authentication.py    From networkmgr with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, ssid, bssid, wificard):
        self.wificard = wificard
        self.ssid = ssid
        self.bssid = bssid
        self.window = Gtk.Window()
        self.window.set_title("wi-Fi Network Authetification Required")
        self.window.set_border_width(0)
        # self.window.set_position(Gtk.WIN_POS_CENTER)
        self.window.set_size_request(500, 200)
        # self.window.set_icon_from_file("/usr/local/etc/gbi/logo.png")
        box1 = Gtk.VBox(False, 0)
        self.window.add(box1)
        box1.show()
        box2 = Gtk.VBox(False, 10)
        box2.set_border_width(10)
        box1.pack_start(box2, True, True, 0)
        box2.show()
        # Creating MBR or GPT drive
        title = "Authetification required by %s Wi-Fi Network" % ssid
        label = Gtk.Label("<b><span size='large'>%s</span></b>" % title)
        label.set_use_markup(True)
        pwd_label = Gtk.Label("Password:")
        self.password = Gtk.Entry()
        self.password.set_visibility(False)
        check = Gtk.CheckButton("Show password")
        check.connect("toggled", self.on_check)
        table = Gtk.Table(1, 2, True)
        table.attach(label, 0, 5, 0, 1)
        table.attach(pwd_label, 1, 2, 2, 3)
        table.attach(self.password, 2, 4, 2, 3)
        table.attach(check, 2, 4, 3, 4)
        box2.pack_start(table, False, False, 0)
        box2 = Gtk.HBox(False, 10)
        box2.set_border_width(5)
        box1.pack_start(box2, False, True, 0)
        box2.show()
        # Add create_scheme button
        box2.pack_end(self.button(), True, True, 5)
        self.window.show_all()