本文整理汇总了Python中gi.repository.Gtk.Label方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.Label方法的具体用法?Python Gtk.Label怎么用?Python Gtk.Label使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.Label方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __send_notification
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Label [as 别名]
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()
示例2: _build_widgets
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Label [as 别名]
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)
示例3: _build_widgets
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Label [as 别名]
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)
示例4: __on_clear_database_clicked
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Label [as 别名]
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()
示例5: __add_orange_button
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Label [as 别名]
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
示例6: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Label [as 别名]
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)
示例7: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Label [as 别名]
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)
示例8: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Label [as 别名]
def __init__(self, pulse=True, title="", rate=0.01):
apply_colours_to_screen()
apply_styling_to_screen(self.CSS_PATH)
ProgressBar.__init__(self, pulse, rate)
self.get_style_context().add_class("KanoProgressBar")
self.win = Gtk.Window()
self.win.get_style_context().add_class("KanoProgressBar")
self.win.set_decorated(False)
self.win.set_resizable(False)
self.win.set_position(Gtk.WindowPosition.CENTER)
self.win.connect("delete-event", Gtk.main_quit)
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.win.add(box)
label = Gtk.Label(title)
label.set_padding(10, 10)
label.get_style_context().add_class("KanoProgressBar")
box.pack_start(label, False, False, 5)
box.pack_start(self, False, False, 0)
示例9: create_custom_label
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Label [as 别名]
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
示例10: gtk_listbox_populate_labels
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Label [as 别名]
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)
示例11: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Label [as 别名]
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)
示例12: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Label [as 别名]
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()
示例13: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Label [as 别名]
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)
示例14: generate_slider_label
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Label [as 别名]
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
示例15: restore_create_dialog
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Label [as 别名]
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'