Python gi.repository.Gtk.Label() Examples

The following are 30 code examples of gi.repository.Gtk.Label(). 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: heading.py    From kano-toolset with GNU General Public License v2.0 9 votes vote down vote up
def __init__(self, title, description):

        cssProvider = Gtk.CssProvider()
        cssProvider.load_from_path(common_css_dir + "/heading.css")
        styleContext = Gtk.StyleContext()
        styleContext.add_provider(cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER)

        self.title = Gtk.Label(title)
        self.title_style = self.title.get_style_context()
        self.title_style.add_provider(cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
        self.title_style.add_class('title')

        self.container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
        self.container.pack_start(self.title, False, False, 0)

        if description != "":
            self.description = Gtk.Label(description)
            self.description.set_justify(Gtk.Justification.CENTER)
            self.description.set_line_wrap(True)
            self.description_style = self.description.get_style_context()
            self.description_style.add_provider(cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
            self.description_style.add_class('description')

            self.container.pack_start(self.description, False, False, 0) 
Example #2
Source File: add.py    From Authenticator with GNU General Public License v2.0 6 votes vote down vote up
def __send_notification(self, message):
        """
            Show a notification using Gd.Notification.
            :param message: the notification message
            :type message: str
        """
        notification = Gd.Notification()
        notification.set_show_close_button(True)
        notification.set_timeout(5)

        notification_lbl = Gtk.Label()
        notification_lbl.set_text(message)

        notification.add(notification_lbl)

        self.add(notification)
        self.reorder_child(notification, 0)
        self.show_all() 
Example #3
Source File: settings.py    From Authenticator with GNU General Public License v2.0 6 votes vote down vote up
def __on_clear_database_clicked(self, *__):
        notification = Gd.Notification()
        notification.set_timeout(5)
        notification.connect("dismissed", self.__clear_database)
        container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

        notification_lbl = Gtk.Label()
        notification_lbl.set_text(_("The existing accounts will be erased in 5 seconds"))
        container.pack_start(notification_lbl, False, False, 3)

        undo_btn = Gtk.Button()
        undo_btn.set_label(_("Undo"))
        undo_btn.connect("clicked", lambda widget: notification.hide())
        container.pack_end(undo_btn, False, False, 3)

        notification.add(container)
        notification_parent = self.stack.get_child_by_name("behaviour")
        notification_parent.add(notification)
        notification_parent.reorder_child(notification, 0)
        self.show_all() 
Example #4
Source File: settings.py    From Authenticator with GNU General Public License v2.0 6 votes vote down vote up
def _build_widgets(self, label, sub_label=None):
        container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        container.get_style_context().add_class("settings-box")

        main_lbl = Gtk.Label()
        main_lbl.set_halign(Gtk.Align.START)
        main_lbl.get_style_context().add_class("settings-box-main-label")
        main_lbl.set_text(label)
        container.pack_start(main_lbl, True, True, 3)
        self.secondary_lbl = Gtk.Label()
        self.secondary_lbl.set_halign(Gtk.Align.START)
        self.secondary_lbl.get_style_context().add_class("settings-box-secondary-label")
        if sub_label:
            self.secondary_lbl.set_text(sub_label)
        else:
            self.secondary_lbl.set_text("")
        container.pack_start(self.secondary_lbl, True, True, 3)

        self.add(container) 
Example #5
Source File: list.py    From Authenticator with GNU General Public License v2.0 6 votes vote down vote up
def _build_widgets(self):
        """
            Build EmptyAccountList widget.
        """
        self.set_border_width(36)
        self.set_valign(Gtk.Align.CENTER)
        self.set_halign(Gtk.Align.CENTER)

        # Image
        g_icon = Gio.ThemedIcon(name="dialog-information-symbolic.symbolic")
        img = Gtk.Image.new_from_gicon(g_icon, Gtk.IconSize.DIALOG)

        # Label
        label = Gtk.Label(label=_("There are no accounts yet…"))

        self.pack_start(img, False, False, 6)
        self.pack_start(label, False, False, 6) 
Example #6
Source File: buttons.py    From kano-toolset with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, text="", icon_filename=""):

        Gtk.Button.__init__(self)

        apply_colours_to_widget(self)

        self.internal_box = Gtk.Box(spacing=10)
        self.internal_box.props.halign = Gtk.Align.CENTER
        self.add(self.internal_box)

        if icon_filename:
            self.icon = Gtk.Image.new_from_file(icon_filename)
            self.internal_box.pack_start(self.icon, False, False, 0)
            self.label = Gtk.Label(text)
            self.internal_box.pack_start(self.label, False, False, 0)
        else:
            self.label = Gtk.Label(text)
            self.internal_box.add(self.label)

        cursor.attach_cursor_events(self) 
Example #7
Source File: kano_dialog.py    From kano-toolset with GNU General Public License v2.0 6 votes vote down vote up
def __add_orange_button(self, orange_info, kano_button_box):
        orange_text = orange_info['name']
        orange_return_value = orange_info['return_value']

        button_container = Gtk.ButtonBox(spacing=10)
        button_container.set_layout(Gtk.ButtonBoxStyle.SPREAD)
        self.orange_button = OrangeButton(orange_text)
        self.orange_button.connect('button-release-event', self.exit_dialog, orange_return_value)

        button_container.pack_start(self.orange_button, False, False, 0)
        button_container.pack_start(kano_button_box, False, False, 0)
        # The empty label is to centre the kano_button
        label = Gtk.Label("    ")
        button_container.pack_start(label, False, False, 0)

        return button_container 
Example #8
Source File: buttons.py    From kano-toolset with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, button1_text, orange_button_text=""):

        Gtk.ButtonBox.__init__(self, spacing=10)
        self.set_layout(Gtk.ButtonBoxStyle.SPREAD)

        self.kano_button = KanoButton(button1_text)

        if orange_button_text:
            self.orange_button = OrangeButton(orange_button_text)
            self.pack_start(self.orange_button, False, False, 0)
            self.pack_start(self.kano_button, False, False, 0)

            # The empty label is to centre the kano_button
            self.label = Gtk.Label("    ")
            self.pack_start(self.label, False, False, 0)
        else:
            self.pack_start(self.kano_button, False, False, 0)


# This is a test class to try out different button functions 
Example #9
Source File: gui_utilities.py    From king-phisher with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def gtk_listbox_populate_labels(listbox, label_strings):
	"""
	Formats and adds labels to a listbox. Each label is styled and added as a
	separate entry.

	.. versionadded:: 1.13.0

	:param listbox: Gtk Listbox to put the labels in.
	:type listbox: :py:class:`Gtk.listbox`
	:param list label_strings: List of strings to add to the Gtk Listbox as labels.
	"""
	gtk_widget_destroy_children(listbox)
	for label_text in label_strings:
		label = Gtk.Label()
		label.set_markup("<span font=\"smaller\"><tt>{0}</tt></span>".format(saxutils.escape(label_text)))
		label.set_property('halign', Gtk.Align.START)
		label.set_property('use-markup', True)
		label.set_property('valign', Gtk.Align.START)
		label.set_property('visible', True)
		listbox.add(label) 
Example #10
Source File: list.py    From Authenticator with GNU General Public License v2.0 6 votes vote down vote up
def _build_widgets(self, accounts_list, provider):
        provider_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

        provider_lbl = Gtk.Label()
        provider_lbl.set_text(provider)
        provider_lbl.set_halign(Gtk.Align.START)
        provider_lbl.get_style_context().add_class("provider-lbl")

        provider_img = Gtk.Image()
        pixbuf = load_pixbuf_from_provider(provider)
        provider_img.set_from_pixbuf(pixbuf)

        provider_container.pack_start(provider_img, False, False, 3)
        provider_container.pack_start(provider_lbl, False, False, 3)

        self.pack_start(provider_container, False, False, 3)
        self.pack_start(accounts_list, False, False, 3) 
Example #11
Source File: bluetooth_config.py    From kano-settings with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, device):
        Gtk.Box.__init__(self, hexpand=True)

        self.device = device
        device_name = device.name

        dev_label = Gtk.Label(device_name, hexpand=True)
        dev_label.get_style_context().add_class('normal_label')
        self.pack_start(dev_label, False, False, 0)

        self._pair_button = KanoButton()
        self._set_paired_button_state()
        self._pair_button.set_margin_top(10)
        self._pair_button.set_margin_bottom(10)
        self._pair_button.set_margin_left(10)
        self._pair_button.set_margin_right(10)
        self._pair_button.connect('clicked', self.pair)
        self.pack_start(self._pair_button, False, False, 0) 
Example #12
Source File: tab.py    From ImEditor with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, win, tab, title, img):
        Gtk.Box.__init__(self)
        self.set_spacing(5)

        self.win = win
        self.tab = tab

        # Preview of image
        self.icon = Gtk.Image()

        # Title
        self.label = Gtk.Label()
        self.set_title(title)

        # Close button
        button = Gtk.Button()
        button.set_relief(Gtk.ReliefStyle.NONE)
        button.add(Gtk.Image.new_from_icon_name('window-close',
            Gtk.IconSize.MENU))
        button.connect('clicked', self.on_close_button_clicked)
        self.add(self.icon)
        self.add(self.label)
        self.add(button)

        self.show_all() 
Example #13
Source File: set_display.py    From kano-settings with GNU General Public License v2.0 6 votes vote down vote up
def generate_slider_label(self, direction):
        value_label = Gtk.Label()
        value_label.get_style_context().add_class('slider_label')
        slider = Gtk.HScale.new_with_range(0, get_overscan_limit(), 1)
        slider.set_value(self.overscan_values[direction])
        slider.set_size_request(400, 30)
        slider.connect('value_changed', self.adjust, direction)
        slider.connect('value_changed', self.update_value, value_label)
        slider.set_value_pos(Gtk.PositionType.RIGHT)
        slider.set_draw_value(False)
        dir_label = Gtk.Label()
        dir_label.get_style_context().add_class('slider_label')
        dir_label.set_alignment(xalign=1, yalign=1)
        dir_label.set_text(direction.title())
        self.update_value(slider, value_label)
        return value_label, slider, dir_label 
Example #14
Source File: mail.py    From king-phisher with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def __init__(self, *args, **kwargs):
		self.label = Gtk.Label(label='Send')
		"""The :py:class:`Gtk.Label` representing this tabs name."""
		super(MailSenderSendTab, self).__init__(*args, **kwargs)
		self.textview = self.gobjects['textview_mail_sender_progress']
		"""The :py:class:`Gtk.TextView` object that renders text status messages."""
		self.textview.modify_font(Pango.FontDescription(self.config['text_font']))
		self.textbuffer = self.textview.get_buffer()
		"""The :py:class:`Gtk.TextBuffer` instance associated with :py:attr:`~.MailSenderSendTab.textview`."""
		self.textbuffer_iter = self.textbuffer.get_start_iter()
		self.progressbar = self.gobjects['progressbar_mail_sender']
		"""The :py:class:`Gtk.ProgressBar` instance which is used to display progress of sending messages."""
		self.pause_button = self.gobjects['togglebutton_mail_sender_pause']
		self.sender_thread = None
		"""The :py:class:`.MailSenderThread` instance that is being used to send messages."""
		self.application.connect('exit', self.signal_kpc_exit)
		self.application.connect('exit-confirm', self.signal_kpc_exit_confirm)
		self.textview.connect('populate-popup', self.signal_textview_populate_popup) 
Example #15
Source File: gtk.py    From encompass with GNU General Public License v3.0 6 votes vote down vote up
def restore_create_dialog():

    # ask if the user wants to create a new wallet, or recover from a seed. 
    # if he wants to recover, and nothing is found, do not create wallet
    dialog = Gtk.Dialog("electrum", parent=None, 
                        flags=Gtk.DialogFlags.MODAL,
                        buttons= ("create", 0, "restore",1, "cancel",2)  )

    label = Gtk.Label("Wallet file not found.\nDo you want to create a new wallet,\n or to restore an existing one?"  )
    label.show()
    dialog.vbox.pack_start(label, True, True, 0)
    dialog.show()
    r = dialog.run()
    dialog.destroy()

    if r==2: return False
    return 'restore' if r==1 else 'create' 
Example #16
Source File: labelled_entries.py    From kano-toolset with GNU General Public License v2.0 6 votes vote down vote up
def create_custom_label(heading, description=""):

    heading_label = Gtk.Label(heading)
    heading_label.get_style_context().add_class("bold_label")
    box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
    box.pack_start(heading_label, False, False, 0)

    if description:
        description_label = Gtk.Label(description)
        description_label.get_style_context().add_class("desc_label")
        box.pack_start(description_label, False, False, 0)

    align = Gtk.Alignment(yscale=0, yalign=0.5)
    align.add(box)

    return align 
Example #17
Source File: templates.py    From kano-settings with GNU General Public License v2.0 5 votes vote down vote up
def label_button(button, text0, text1):
        button.set_label(text0)
        button.get_style_context().add_class('bold_toggle')

        info = Gtk.Label(text1)
        info.get_style_context().add_class('normal_label')

        box = Gtk.Box()
        box.pack_start(button, False, False, 0)
        box.pack_start(info, False, False, 0)

        return box 
Example #18
Source File: matchbox.py    From kickoff-player with GNU General Public License v3.0 5 votes vote down vote up
def do_score_label(self):
    label = Gtk.Label('None')
    label.set_justify(Gtk.Justification.CENTER)
    label.set_halign(Gtk.Align.CENTER)
    label.set_valign(Gtk.Align.CENTER)

    add_widget_class(label, 'event-date')

    return label 
Example #19
Source File: matchbox.py    From kickoff-player with GNU General Public License v3.0 5 votes vote down vote up
def do_team_name(self):
    label = Gtk.Label('Team Name')
    label.set_max_width_chars(25)
    label.set_ellipsize(Pango.EllipsizeMode.MIDDLE)
    label.set_margin_left(5)
    label.set_margin_right(5)

    add_widget_class(label, 'team-name')

    return label 
Example #20
Source File: matchbox.py    From kickoff-player with GNU General Public License v3.0 5 votes vote down vote up
def do_nostreams_label(self):
    label = Gtk.Label('No streams available...')
    label.set_margin_top(7)
    label.set_margin_bottom(10)
    label.show()

    self.add(label)

    add_widget_class(label, 'stream-unknown')

    return label 
Example #21
Source File: ChangeGivenNames.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, dbstate, user, options_class, name, callback=None):
        uistate = user.uistate
        self.label = _('Capitalization changes')
        self.dbstate = dbstate
        self.uistate = uistate
        self.cb = callback

        ManagedWindow.__init__(self,uistate,[],self.__class__)
        self.set_window(Gtk.Window(),Gtk.Label(),'')

        tool.BatchTool.__init__(self, dbstate, user, options_class, name)
        if self.fail:
            return

        given_name_dict = self.get_given_name_dict()

        self.progress = ProgressMeter(_('Checking Given Names'),'',
                                      parent=uistate.window)
        self.progress.set_pass(_('Searching given names'),
                               len(given_name_dict.keys()))
        self.name_list = []

        for name in given_name_dict.keys():
            if name != capitalize(name):
                self.name_list.append((name, given_name_dict[name]))

            if uistate:
                self.progress.step()

        if self.name_list:
            self.display()
        else:
            self.progress.close()
            self.close()
            OkDialog(_('No modifications made'),
                     _("No capitalization changes were detected."),
                     parent=uistate.window) 
Example #22
Source File: menu_button.py    From kano-settings with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, name, description=''):

        # Contains the info about the level and the image
        self.container = Gtk.Grid()
        self.container.set_hexpand(True)
        self.container.props.margin = 20

        # Info about the different settings
        self.title = Gtk.Label(_(name))
        self.title.get_style_context().add_class('menu_intro_label')
        self.title.set_alignment(xalign=0, yalign=0)
        self.title.props.margin_top = 10

        self.description = Gtk.Label(description)
        self.description.get_style_context().add_class('menu_custom_label')
        self.description.set_ellipsize(Pango.EllipsizeMode.END)
        self.description.set_size_request(130, 10)
        self.description.set_alignment(xalign=0, yalign=0)
        self.description.props.margin_bottom = 8

        self.button = Gtk.Button()
        self.button.set_can_focus(False)
        cursor.attach_cursor_events(self.button)
        self.img = Gtk.Image()
        self.img.set_from_file(common.media + "/Icons/Icon-" + name + ".png")

        self.container.attach(self.title, 2, 0, 1, 1)
        self.container.attach(self.description, 2, 1, 1, 1)
        self.container.attach(self.img, 0, 0, 2, 2)
        self.container.set_row_spacing(2)
        self.container.set_column_spacing(20)
        self.container.props.valign = Gtk.Align.CENTER

        self.button.add(self.container) 
Example #23
Source File: no_internet_screen.py    From kano-settings with GNU General Public License v2.0 5 votes vote down vote up
def create_text_align(self):
        label = Gtk.Label(_("You need internet to continue"))
        label.get_style_context().add_class('about_version')

        align = Gtk.Alignment(xalign=0.5, xscale=0, yalign=0, yscale=0)
        align.add(label)

        return align 
Example #24
Source File: set_style.py    From kano-settings with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, win):

        Gtk.Notebook.__init__(self)

        background = Gtk.EventBox()
        background.add(self)

        self.win = win
        self.win.set_main_widget(background)
        self.win.top_bar.enable_prev()
        self.win.change_prev_callback(self.win.go_to_home)

        # Modify set_wallpaper so it doesn't add itself to the window
        wallpaper_widget = SetWallpaper(self.win)
        screensaver_widget = SetScreensaver(self.win)
        reset_widget = SetResetDesktop(self.win)

        wallpaper_label = Gtk.Label(_("BACKGROUND"))
        wallpaper_label_ebox = Gtk.EventBox()
        wallpaper_label_ebox.add(wallpaper_label)
        wallpaper_label_ebox.connect('realize', self._set_cursor_to_hand_cb)
        wallpaper_label_ebox.show_all()

        screensaver_label = Gtk.Label(_("SCREENSAVER"))
        screensaver_label_ebox = Gtk.EventBox()
        screensaver_label_ebox.add(screensaver_label)
        screensaver_label_ebox.connect('realize', self._set_cursor_to_hand_cb)
        screensaver_label_ebox.show_all()

        general_label = Gtk.Label(_("GENERAL"))
        general_label_ebox = Gtk.EventBox()
        general_label_ebox.add(general_label)
        general_label_ebox.connect('realize', self._set_cursor_to_hand_cb)
        general_label_ebox.show_all()

        # Add the screensaver and wallpaper tabs
        self.append_page(wallpaper_widget, wallpaper_label_ebox)
        self.append_page(screensaver_widget, screensaver_label_ebox)
        self.append_page(reset_widget, general_label_ebox)

        self.win.show_all() 
Example #25
Source File: templates.py    From kano-settings with GNU General Public License v2.0 5 votes vote down vote up
def __init__(
        self,
        title,
        description,
        button_text,
        orange_button_text=None
    ):

        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.sw = ScrolledWindow()
        self.sw.apply_styling_to_widget(wide=False)

        self.title = Heading(title, description)
        self.kano_button = KanoButton(button_text)
        self.kano_button.pack_and_align()

        self.pack_start(self.title.container, False, False, 0)
        self.pack_start(self.sw, True, True, 0)

        if orange_button_text:
            box_align = Gtk.Alignment(xscale=0, xalign=0.5)
            button_box = Gtk.ButtonBox(
                orientation=Gtk.Orientation.HORIZONTAL, spacing=40
            )

            label = Gtk.Label("")
            self.orange_button = OrangeButton(orange_button_text)
            button_box.pack_start(label, False, False, 0)
            button_box.pack_start(self.kano_button.align, False, False, 0)
            button_box.pack_start(self.orange_button, False, False, 0)

            box_align.add(button_box)
            self.pack_start(box_align, False, False, 0)
        else:
            self.pack_start(self.kano_button.align, False, False, 0) 
Example #26
Source File: bluetooth_config.py    From kano-settings with GNU General Public License v2.0 5 votes vote down vote up
def set_no_devices_nearby(self):
        no_dev = Gtk.Label(_("No devices found nearby"))
        no_dev.get_style_context().add_class('normal_label')
        self.dev_view.pack_start(no_dev, False, False, 0)

        self.dev_view.show_all() 
Example #27
Source File: extractcity.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, dbstate, user, options_class, name, callback=None):
        self.uistate = user.uistate
        self.label = _('Extract Place data')

        ManagedWindow.__init__(self, self.uistate, [], self.__class__)
        self.set_window(Gtk.Window(), Gtk.Label(), '')

        tool.BatchTool.__init__(self, dbstate, user, options_class, name)

        if not self.fail:
            self.uistate.set_busy_cursor(True)
            self.run(dbstate.db)
            self.uistate.set_busy_cursor(False) 
Example #28
Source File: bluetooth_config.py    From kano-settings with GNU General Public License v2.0 5 votes vote down vote up
def set_no_adapter_available(self):
        no_adapter = Gtk.Label(_("No bluetooth dongle detected"))
        no_adapter.get_style_context().add_class('normal_label')
        self.dev_view.pack_start(no_adapter, False, False, 0)

        self.dev_view.show_all() 
Example #29
Source File: NetworkScreen.py    From kano-settings with GNU General Public License v2.0 5 votes vote down vote up
def _create_refresh_connect_buttons(self):
        '''Create the buttons used for the refresh button and the
        to connect to a network, and pack them into a button box.
        Returns the button box.
        '''

        self._connect_btn = KanoButton(_("CONNECT"))
        self._connect_btn.pack_and_align()
        self.connect_handler = self._connect_btn.connect(
            'clicked', self._first_time_connect
        )
        self._connect_btn.set_sensitive(False)
        self._refresh_btn = self._create_refresh_button()

        # For now, show both connect and refresh buttons
        buttonbox = Gtk.ButtonBox()
        buttonbox.set_layout(Gtk.ButtonBoxStyle.CENTER)
        buttonbox.set_spacing(10)
        buttonbox.pack_start(self._refresh_btn, False, False, 0)
        buttonbox.pack_start(self._connect_btn.align, False, False, 0)

        if self._win.is_plug():
            self._skip_btn = WhiteButton(_("Skip"))
            buttonbox.pack_start(self._skip_btn, False, False, 0)
            self._skip_btn.connect('clicked', self.skip)
        else:
            blank_label = Gtk.Label("")
            buttonbox.pack_start(blank_label, False, False, 0)

        return buttonbox

    # Attached to a callback, hence the extra argument 
Example #30
Source File: set_about.py    From kano-settings with GNU General Public License v2.0 5 votes vote down vote up
def create_align(self, text, css_class='about_label'):
        '''This styles the status information in the 'about' dialog
        '''

        label = Gtk.Label(text)
        label.get_style_context().add_class(css_class)

        align = Gtk.Alignment(xalign=0.5, xscale=0, yalign=0, yscale=0)
        align.add(label)

        return align