我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用gi.repository.Gtk.Label()。
def generate_components(self): self.get_style_context().add_class("top") self.infobar = Gtk.InfoBar() self.infobar.set_show_close_button(True) self.infobar.connect("response", self.response) self.infobar.set_default_response(Gtk.ResponseType.CLOSE) self.infobar.set_message_type(Gtk.MessageType.INFO) content_area = self.infobar.get_content_area() action_area = self.infobar.get_action_area() self.undo_button = None if self.undo_action: self.undo_button = self.infobar.add_button( _("Undo"), Gtk.ResponseType.CANCEL) self.message_label = Gtk.Label() self.message_label.set_text(self.message) content_area.add(self.message_label) self.add(self.infobar)
def __init__(self, parent, window, account): # Read default values self.window = window self.parent = parent self.account = account # Create needed widgets self.code_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) self.revealer = Gtk.Revealer() self.checkbox = Gtk.CheckButton() self.application_name = Gtk.Label(xalign=0) self.code_label = Gtk.Label(xalign=0) self.timer_label = Gtk.Label(xalign=0) self.accel = Gtk.AccelGroup() self.window.add_accel_group(self.accel) self.accel.connect(Gdk.keyval_from_name('C'), Gdk.ModifierType.CONTROL_MASK, 0, self.copy_code) self.accel.connect(Gdk.keyval_from_name("Enter"), Gdk.ModifierType.META_MASK, 0, self.toggle_code)
def bottom_bar_handler(self, tim: time, text: str, action: str): """Add actions to the eventlist in the bottom bar. :param tim: Time of action. :param text: Recognized text. :param action: Action performed. """ row = Gtk.ListBoxRow() box = Gtk.HBox() box.set_homogeneous(True) text_label = Gtk.Label(text) text_label.set_line_wrap(True) box.pack_start(Gtk.Label(tim), False, False, 0) box.pack_start(text_label, True, True, 0) box.pack_start(Gtk.Label(action), False, False, 0) row.add(box) # Remove old entries if self.bottom_widget.get_object("event_list").get_row_at_index(40): self.bottom_widget.get_object("event_list").get_row_at_index(40).destroy() row.show_all() self.bottom_widget.get_object("event_list").prepend(row)
def __init__(self, app, name, use_icon, widget): self.pressed = Gtk.Label() ControllerWidget.__init__(self, app, name, use_icon, widget) grid = Gtk.Grid() self.label.set_property("vexpand", True) self.label.set_property("hexpand", True) self.label.set_xalign(0.0); self.label.set_yalign(0.5) self.pressed.set_property("hexpand", True) self.pressed.set_xalign(0.0); self.pressed.set_yalign(1.0) if self.icon: self.icon.set_margin_right(5) grid.attach(self.icon, 1, 1, 1, 2) grid.attach(self.label, 2, 1, 1, 1) grid.attach(self.pressed, 2, 2, 1, 1) self.over_icon = False self.widget.add(grid) self.widget.show_all()
def __init__(self, parent): self.parent = parent self.language = 'Plain' self.curLinter = None self.lintersObj = { 'c': LinterClang(self.parent, self) } self.linterPopover = Gtk.Popover() self.errorsLbl = Gtk.Label('Errors: 0') self.statusLbl = Gtk.Label('Status: OK') self.linterPopoverBox = Gtk.VBox() self.linterPopoverBox.set_border_width(10) self.linterPopoverBox.pack_start(self.errorsLbl, False, False, 0) self.linterPopoverBox.pack_start(self.statusLbl, False, False, 0) self.linterPopover.add(self.linterPopoverBox) ##
def buildTree(self, *args): for item in self.files: a = Gtk.Label(item) if os.path.isdir(self.projectPath + '/' + item): i = Gtk.Image.new_from_icon_name('folder', Gtk.IconSize.MENU) # change this for recursive function else: i = Gtk.Image.new_from_icon_name('text-x-script', Gtk.IconSize.MENU) hb = Gtk.HBox(spacing=6) hb.pack_start(i, False, False, 0) hb.pack_start(a, False, False, 0) row = Gtk.ListBoxRow() row.add(hb) self.sideView.add(row) self.sideView.show_all()
def update(self, tablist: list, tabcurr: int): """Updates the widget's tabs. :tablist: list of tab names. :tabcurr: the active buffer's number. """ self.props.updating = True for _ in range(self.get_n_pages()): self.remove_page(-1) for name in tablist: page = Gtk.Box() self.append_page(page, Gtk.Label(name)) self.child_set_property(page, 'tab-expand', True) self.show_all() self.set_current_page(tabcurr - 1) self.set_show_tabs(self.get_n_pages() > 1) self.props.updating = False
def __init__(self, sbrick_configuration, sbrick_communications_store): Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL, spacing=10, margin=5) self.set_homogeneous(False) self.sbrick_configuration = sbrick_configuration self.sbrick_communications_store = sbrick_communications_store self.sbrick_communications_store.add_observer(self) label = Gtk.Label(sbrick_configuration["name"]) label.set_width_chars(20) label.set_justify(Gtk.Justification.LEFT) self.pack_start(label, False, True, 0) self.handler_ids = [] self.sequence_player_handler_id = None self.button_play = Gtk.Button.new() self.button_play.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_MEDIA_PLAY, Gtk.IconSize.BUTTON)) self.button_play.connect("clicked", self.on_play_clicked) self.pack_start(self.button_play, False, True, 0) self.checkPause = Gtk.CheckButton("Pause in Play All") self.checkPause.connect("toggled", self.on_pause_changed) self.pack_start(self.checkPause, False, True, 0) self.sbrick_communications = None self.sequence_player = None
def _create_ticker_labels(self): self._tickers_vbox.forall(lambda w: w.destroy()) self._ticker_labels = {} for i, market_config in enumerate(config['markets']): if market_config['ticker']: market_id = get_market_id(market_config) hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) exchange, market = market_config['exchange'], market_config['market'] provider = btcwidget.exchanges.factory.get(exchange) market_name = '{} - {}:'.format(provider.get_name(), market) name_label = Gtk.Label(market_name) color = self._get_color(i) name_label.set_markup('<span color="{}">{}</span>'.format(color, market_name)) name_label.set_size_request(150, 10) name_label.set_alignment(0, 0.5) hbox.pack_start(name_label, False, False, 10) price_label = Gtk.Label() hbox.pack_start(price_label, False, False, 10) self._ticker_labels[market_id] = price_label price_label.get_parent() self._tickers_vbox.pack_start(hbox, True, True, 2) self._tickers_vbox.show_all()
def create_version_view(self, label, version): custom = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12, expand=True, visible=True) title = Gtk.Label(halign='start', expand=True, visible=True, label=label) subtitle = Gtk.Label(halign='start', expand=True, visible=True) subtitle.get_style_context().add_class('dim-label') subtitle.set_markup(version) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, expand=True, visible=True) vbox.pack_start(title, True, True, 0) vbox.pack_start(subtitle, True, True, 0) custom.pack_start(vbox, True, True, 0) pack = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6, expand=True, visible=True) pack.pack_start(custom, True, True, 0) return pack
def __init__(self, data, chapter): """ Holds data that is chapter name and chapter_link that is link to chapter file. For use as ListBox element. :param data: :param chapter: """ super(Gtk.ListBoxRow, self).__init__() # Remember chapter name and file link self.data = data self.chapter_link = chapter # Just a bunch of label styling label = Gtk.Label(xalign=0) label.set_text(data) label.set_justify(Gtk.Justification.LEFT) try: label.set_margin_start(10) except AttributeError: label.set_margin_left(10) label.set_width_chars(20) label.set_ellipsize(Pango.EllipsizeMode.END) self.add(label)
def __init__(self): #self._widget = Gtk.Notebook() self._widget = Gtk.Label("Configuration panel for JSHint Plugin") #grid = Gtk.Grid() #for i in range(30): # button = Gtk.CheckButton("Button {}".format(i)) # button.set_tooltip_text("This is the button {}".format(i)) # grid.attach(button, i // 10, i % 10, 1, 1) #self._widget.append_page(grid, Gtk.Label("Enforcing")) #page = Gtk.Box() #page.add(Gtk.Label("Relaxing options")) #self._widget.append_page(page, Gtk.Label("Relaxing")) #page = Gtk.Box() #page.add(Gtk.Label("Environments options")) #self._widget.append_page(page, Gtk.Label("Environments"))
def add_module_is_deprecated_label(self): """ The deprecated module must set a message in self.g_deprecated_label in on_start_practise, preferable telling the file name of the lesson file. """ img = Gtk.Image() img.set_from_stock(Gtk.STOCK_DIALOG_WARNING, Gtk.IconSize.BUTTON) hbox = Gtk.HBox() hbox.set_border_width(12) self.practise_box.set_child_packing(self.g_lesson_heading, False, False, 0, 0) hbox.set_spacing(6) hbox.pack_start(img, True, True, 0) self.g_deprecated_label = Gtk.Label() hbox.pack_start(self.g_deprecated_label, True, True, 0) self.practise_box.pack_start(hbox, False, False, 0) self.practise_box.reorder_child(hbox, 0)
def _add_auto_new_question_gui(self, box): hbox = gu.bHBox(box, False) hbox.set_spacing(gu.PAD_SMALL) adj = Gtk.Adjustment(0, 0, 10, 0.1, 1) spin = gu.nSpinButton(self.m_exname, 'seconds_before_new_question', adj) spin.set_digits(1) label = Gtk.Label(label=_("Delay (seconds):")) label.show() def f(button, spin=spin, label=label): spin.set_sensitive(button.get_active()) label.set_sensitive(button.get_active()) b = gu.nCheckButton(self.m_exname, 'new_question_automatically', _("_New question automatically."), callback=f) hbox.pack_start(b, False, False, 0) label.set_sensitive(b.get_active()) hbox.pack_start(label, False, False, 0) spin.set_sensitive(b.get_active()) hbox.pack_start(spin, False, False, 0)
def add_select_num_beats_gui(self): ### hbox = Gtk.HBox() hbox.set_spacing(gu.hig.SPACE_SMALL) label = Gtk.Label(label=_("Number of beats in question:")) hbox.pack_start(label, False, False, 0) self.config_box_sizegroup.add_widget(label) label.set_alignment(1.0, 0.5) hbox.pack_start(gu.nSpinButton(self.m_exname, "num_beats", Gtk.Adjustment(4, 1, 100, 1, 10)), False, False, 0) self.config_box.pack_start(hbox, False, False, 0) hbox.show_all() # hbox = Gtk.HBox() hbox.set_spacing(gu.hig.SPACE_SMALL) label = Gtk.Label(label=_("Count in before question:")) hbox.pack_start(label, False, False, 0) self.config_box_sizegroup.add_widget(label) label.set_alignment(1.0, 0.5) hbox.pack_start(gu.nSpinButton(self.m_exname, "count_in", Gtk.Adjustment(2, 0, 10, 1, 10)), False, False, 0) hbox.show_all() self.config_box.pack_start(hbox, False, False, 0)
def create(self): table = Gtk.Table() label = Gtk.Label() label.set_alignment(0.0, 0.5) label.set_markup(u"<b>%s</b>" % self.m_heading) self.pack_start(label, True, True, 0) for idx, (cell1, cell2) in enumerate(self.m_data): table.attach(label_from_key(self.m_statistics, cell1), 1, 2, idx*2+1, idx*2+2, xoptions=Gtk.AttachOptions.SHRINK, xpadding=2) table.attach(Gtk.Label(label=cell2), 3, 4, idx*2+1, idx*2+2, xoptions=Gtk.AttachOptions.SHRINK, xpadding=2) for idx in range(len(self.m_data) + 1): table.attach(Gtk.HSeparator(), 0, 5, idx*2, idx*2+1, xoptions=Gtk.AttachOptions.FILL) table.attach(Gtk.VSeparator(), 0, 1, 0, idx*2+2, xoptions=Gtk.AttachOptions.SHRINK) table.attach(Gtk.VSeparator(), 2, 3, 0, idx*2+2, xoptions=Gtk.AttachOptions.SHRINK) table.attach(Gtk.VSeparator(), 4, 5, 0, idx*2+2, xoptions=Gtk.AttachOptions.SHRINK) self.pack_start(table, False, False, 0) self.show_all()
def __init__(self, statistics, heading): Gtk.ScrolledWindow.__init__(self) self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.vbox = Gtk.VBox(False, 0) self.vbox.set_spacing(gu.PAD) self.vbox.set_border_width(gu.PAD) self.add_with_viewport(self.vbox) hbox = Gtk.HBox(False, 0) hbox.set_spacing(gu.hig.SPACE_SMALL) im = Gtk.Image.new_from_file("graphics/applications-system.svg") self.g_settings_button = b = Gtk.Button() b.connect('clicked', self.on_delete_statistics) b.add(im) hbox.pack_start(b, False, False, 0) self.g_heading = Gtk.Label(label=heading) self.g_heading.set_alignment(0.0, 0.5) self.g_heading.set_name("StatisticsH1") hbox.pack_start(self.g_heading, False, False, 0) self.vbox.pack_start(hbox, False, False, 0) self.m_statistics = statistics self.g_tables = Gtk.VBox(False, 0) self.g_tables.show() self.vbox.pack_start(self.g_tables, True, True, 0) self.show_all()
def hig_category_vbox(title, spacing=6): """ spacing the space to put between children. HIG say is should be 6, but while packing Gtk.LinkButtons there is too much space between the links when packing with 6 pixels. So I added the spacing parameter. Return a tuple of two boxes: box1 -- a box containing everything including the title. Useful if you have to hide a category. box2 The box you should pack your stuff in. """ vbox = Gtk.VBox(False, 0) vbox.set_spacing(hig.SPACE_SMALL) label = Gtk.Label(label='<span weight="bold">%s</span>' % title) label.set_use_markup(True) label.set_alignment(0.0, 0.0) vbox.pack_start(label, False, False, 0) hbox = Gtk.Box(False, 0) vbox.pack_start(hbox, False, False, 0) fill = Gtk.Label(label=" ") hbox.pack_start(fill, False, False, 0) category_content_vbox = Gtk.VBox(False, 0) hbox.pack_start(category_content_vbox, True, True, 0) category_content_vbox.set_spacing(spacing) vbox.show_all() return vbox, category_content_vbox
def hig_label_widget(txt, widget, sizegroup, expand=False, fill=False): """ Return a box containing a label and a widget, aligned nice as the HIG say we should. widget can also be a list or tuple of widgets. """ hbox = Gtk.Box() hbox.set_spacing(hig.SPACE_SMALL) label = Gtk.Label(label=txt) label.set_alignment(0.0, 0.5) if sizegroup: sizegroup.add_widget(label) hbox.pack_start(label, False, False, 0) if not isinstance(widget, (list, tuple)): widget = [widget] for w in widget: hbox.pack_start(w, fill, expand, padding=0) label.set_use_underline(True) label.set_mnemonic_widget(widget[0]) return hbox
def create_statistics_config(self): it, page_vbox = self.new_page_box(None, _("Statistics")) box, category_vbox = gu.hig_category_vbox(_("Statistics from 3.15 and older")) page_vbox.pack_start(box, False, False, 0) self.g_old_stat_info = Gtk.Label() self.g_old_stat_info.set_line_wrap(True) self.g_old_stat_info.set_alignment(0.0, 0.5) category_vbox.pack_start(self.g_old_stat_info, False, False, 0) ### self.g_delete_old_statistics = Gtk.Button(stock=Gtk.STOCK_DELETE) self.g_delete_old_statistics.connect('clicked', self.delete_obsolete_statistics) category_vbox.pack_start(self.g_delete_old_statistics, False, False, 0) box, category_vbox = gu.hig_category_vbox(_("Statistics")) page_vbox.pack_start(box, False, False, 0) self.g_stat_info = Gtk.Label() self.g_stat_info.set_line_wrap(True) self.g_stat_info.set_alignment(0.0, 0.5) category_vbox.pack_start(self.g_stat_info, False, False, 0) b = Gtk.Button(stock=Gtk.STOCK_DELETE) b.connect('clicked', self.delete_statistics) category_vbox.pack_start(b, False, False, 0) self.update_statistics_info() self.update_old_statistics_info()
def _worker_Xrandom(self, rfunc): styles = ["8beat", "ballad", "rock"] s = """ styles = %s question { style = %s("8beat", "ballad") } question { style = %s(styles) } """ % (", ".join(['"%s"' % x for x in styles]), rfunc, rfunc) self.p = QuestionsLessonfile() p = self.do_file(s) for idx in range(2): st = p.m_questions[idx]['style'] for x in range(20): self.assert_(str(st) in styles) self.assert_(unicode(st) in styles) st.randomize() # This test only works with nrandom, because prandom will # return a possible different value every time. if rfunc == 'nrandom': l = Gtk.Label(label=st) self.assert_(l.get_text() == unicode(st), "%s and gtk does not cooperate." % rfunc)
def __init__(self, oldname): Gtk.Dialog.__init__(self, _(u"_Rename profile\u2026").replace("_", "").replace(u"\u2026", "")) self.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT) vbox = gu.hig_dlg_vbox() self.vbox.pack_start(vbox, True, True, 0) label = Gtk.Label(label=_(u"Rename the profile «%s» to:") % oldname) label.set_alignment(0.0, 0.5) vbox.pack_start(label, False, False, 0) self.g_entry = Gtk.Entry() self.g_entry.set_text(oldname) self.g_entry.set_activates_default(True) self.g_entry.connect('changed', self.on_entry_changed) vbox.pack_start(self.g_entry, False, False, 0) self.g_info = Gtk.Label() self.g_info.set_no_show_all(True) vbox.pack_start(self.g_info, False, False, 0) self.set_default_response(Gtk.ResponseType.ACCEPT)
def __init__(self, lf, v): """ lf is the lesson file (aka m_P of the teacher object) v is a list of element names defind in the lesson file lf, for example: ['I', 'IV', 'V', 'I'] Return a HBox that presents a label with the label names separated by "-". """ gu.AlignedHBox.__init__(self) self.setup_pre() for i, k in enumerate(v): if k in lf.m_elements: l = new_labelobject(lf.m_elements[k]['label']) else: l = Gtk.Label(label=k) self.pack_start(l, False, False) if i != len(v) - 1: l = Gtk.Label(label="-") self.pack_start(l, False, False) self.setup_post() self.show_all()
def __init__(self): Gtk.Window.__init__(self, Gtk.WindowType.POPUP) self.set_position(Gtk.WindowPosition.CENTER) self.set_resizable(True) frame = Gtk.Frame() frame.set_shadow_type(Gtk.ShadowType.OUT) self.add(frame) vbox = Gtk.VBox() vbox.set_border_width(20) frame.add(vbox) l = Gtk.Label(label=_("Starting GNU Solfege %s") % buildinfo.VERSION_STRING) l.set_name("Heading1") vbox.pack_start(l, True, True, 0) l = Gtk.Label(label="http://www.solfege.org") vbox.pack_start(l, True, True, 0) self.g_infolabel = Gtk.Label(label='') vbox.pack_start(self.g_infolabel, True, True, 0) self.show_all()
def __init__(self, parent, title, text): Gtk.Dialog.__init__(self, title, parent, 0, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) self.set_default_size(350, 0) self.set_default_response(Gtk.ResponseType.OK) self.label = Gtk.Label(text) self.label.set_margin_start(5) self.label.set_margin_top(5) self.label.set_margin_bottom(5) self.label.set_margin_end(5) self.entry = Gtk.Entry() self.entry.set_margin_start(5) self.entry.set_margin_top(5) self.entry.set_margin_bottom(5) self.entry.set_margin_end(5) self.entry.connect('activate', lambda widget: self.response(Gtk.ResponseType.OK)) self.get_content_area().add(self.label) self.get_content_area().add(self.entry)
def __create_album_flowboxitem(self, album, image, margin): label_album = Gtk.Label(f'{album.Name} ({album.Year})', max_width_chars=0, justify=Gtk.Justification.LEFT, wrap=True, wrap_mode=Pango.WrapMode.WORD_CHAR, xalign=0, margin_top=5) label_artist = Gtk.Label(album.Artist, max_width_chars=0, justify=Gtk.Justification.LEFT, ellipsize=Pango.EllipsizeMode.END, xalign=0, margin_top=5) label_album.get_style_context().add_class('text110') label_artist.get_style_context().add_class('dim-label') flowboxchild = Gtk.FlowBoxChild(halign=Gtk.Align.CENTER) grid = Gtk.Grid(margin=margin, halign=Gtk.Align.CENTER) grid.attach(image, 0, 0, 1, 1) grid.attach(label_album, 0, 1, 1, 1) grid.attach(label_artist, 0, 2, 1, 1) flowboxchild.add(grid) flowboxchild.data = album return flowboxchild
def create_tab(self, title, tab_child, icon=''): tab_box = Gtk.HBox(False, 3) close_button = Gtk.Button() image = Gtk.Image() image.set_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU) label = Gtk.Label(label=title) if icon: i = Gtk.Image() i.set_from_stock(eval('Gtk.STOCK_' + icon), Gtk.IconSize.MENU) tab_box.pack_start(i, False, False, 0) close_button.connect("clicked", self.close_tab, tab_child) close_button.set_image(image) close_button.set_relief(Gtk.ReliefStyle.NONE) tab_box.pack_start(label, True, True, 0) tab_box.pack_end(close_button, False, False, 0) tab_box.show_all() if title in ['Loading dasm...', 'Code', 'Callgraph', 'Flowgraph', 'Interactive', 'Strings', "Sections", 'Hexdump', 'Bindiff', 'File info']: close_button.hide() return tab_box
def __init__(self, tviews, uicore): super(RightCombo,self).__init__(1, 7, False) self.tviews = tviews self.uicore = uicore # Theme Label self.theme_label = Gtk.Label(label='Color theme:') self.attach(self.theme_label, 0, 1, 0, 1) # Theme ComboBox self.theme_combo = Gtk.ComboBoxText() options = ['Classic', 'Cobalt', 'kate', 'Oblivion', 'Tango'] for option in options: self.theme_combo.append_text(option) # Set first by default self.theme_combo.set_active(0) self.theme_combo.connect("changed", self.theme_combo_change) self.attach(self.theme_combo, 1, 2, 0, 1)
def __init__(self, lastWindow, message, value=""): Gtk.Dialog.__init__(self, title="Prompt") self.set_modal(True) self.set_transient_for(lastWindow) self.label = Gtk.Label(message) self.entry = Gtk.Entry() self.entry.set_text(value) self.get_content_area().pack_start(self.label, True, True, 0) self.get_content_area().pack_start(self.entry, True, True, 0) self.add_button("OK", Gtk.ResponseType.OK) self.add_button("Cancel", Gtk.ResponseType.CANCEL) self.connect("key-press-event", self.keyPressed)
def on_delete_learned_data_clicked(self, dummy_widget): ''' The button requesting to delete all data learned from user input or text files has been clicked. ''' SETUP_UI.delete_learned_data_button.set_sensitive(False) confirm_question = Gtk.Dialog( title=_('Are you sure?'), parent=SETUP_UI.builder.get_object('main_dialog'), buttons=( Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) box = confirm_question.get_content_area() box.add(Gtk.Label( _('Do you really want to delete all language \n' + 'data learned from typing or reading files?'))) confirm_question.show_all() response = confirm_question.run() confirm_question.destroy() while Gtk.events_pending(): Gtk.main_iteration() if response == Gtk.ResponseType.OK: SETUP_UI.tabsqlitedb.remove_all_phrases() SETUP_UI.delete_learned_data_button.set_sensitive(True)
def _emoji_label_set_tooltip( # pylint: disable=no-self-use self, emoji, label): ''' Set the tooltip for a label in the flowbox which shows an emoji :param emoji: The emoji :type emoji: String :param label: The label used to show the emoji :type label: Gtk.Label object ''' tooltip_text = _('Left click to copy') + '\n' if len(self._emoji_matcher.skin_tone_variants(emoji)) > 1: tooltip_text += ( _('Long press or middle click for skin tones') + '\n') tooltip_text += _('Right click for info') label.set_tooltip_text(tooltip_text)
def confirm(parent=None, title="", text=""): dialog = Gtk.Dialog(title, parent, 0) dialog.set_default_size(150, 100) dialog.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("white")) label = Gtk.Label() label.set_markup('<span foreground="#494941" face="sans">' + text + '</span>') box = dialog.get_content_area() box.add(label) box.show_all() btn1 = dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL) btn1.set_relief(2) btn2 = dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK) btn2.set_relief(2) result = False response = dialog.run() dialog.destroy() if response == Gtk.ResponseType.OK: result = True elif response == Gtk.ResponseType.CANCEL: result = False return result
def __init__(self, part: Dict[str, Any], core: ApartCore, main_view: 'MainView'): Gtk.Box.__init__(self) self.part = part self.core = core self.main_view = main_view self.add(key_and_val('Name', self.name())) self.add(key_and_val('Type', self.part.get('fstype', 'unknown'))) self.add(key_and_val('Label', self.part.get('label', 'none'))) self.add(key_and_val('Size', humanize.naturalsize(self.part['size'], binary=True))) self.clone_button = Gtk.Button("Clone", halign=Gtk.Align.END) self.restore_button = Gtk.Button("Restore", halign=Gtk.Align.END) if self.is_mounted(): self.clone_button.set_sensitive(False) self.clone_button.set_tooltip_text('Partition is currently mounted') self.restore_button.set_sensitive(False) self.restore_button.set_tooltip_text('Partition is currently mounted') else: self.clone_button.connect('clicked', lambda b: self.main_view.show_new_clone()) self.restore_button.connect('clicked', lambda b: self.main_view.show_new_restore()) buttons = Gtk.Box(hexpand=True, halign=Gtk.Align.END) buttons.add(self.clone_button) buttons.add(self.restore_button) self.add(buttons) main_view.connect('notify::visible-child', self.on_main_view_change)
def __init__(self, root: Gtk.Window, text: str, ok_button_text: str = Gtk.STOCK_OK, cancel_button_text: str = Gtk.STOCK_CANCEL, header: str = '', message_type: Gtk.MessageType = Gtk.MessageType.WARNING): Gtk.MessageDialog.__init__(self, root, 0, message_type=message_type) self.set_title(header) self.icon = Gtk.Image() self.icon.set_from_icon_name(appropriate_icon(message_type), Gtk.IconSize.LARGE_TOOLBAR) self.text = Gtk.Label(text) heading = Gtk.Box() heading.add(self.icon) heading.add(self.text) self.get_message_area().add(heading) self.get_message_area().set_spacing(0) self.add_button(cancel_button_text, Gtk.ResponseType.CANCEL) self.add_button(ok_button_text, Gtk.ResponseType.OK) self.show_all()
def __init__(self, root: Gtk.Window, text: str, ok_button_text: str = Gtk.STOCK_OK, header: str = '', message_type: Gtk.MessageType = Gtk.MessageType.ERROR): Gtk.MessageDialog.__init__(self, root, 0, message_type=message_type) self.set_title(header) self.icon = Gtk.Image() self.icon.set_from_icon_name(appropriate_icon(message_type), Gtk.IconSize.LARGE_TOOLBAR) self.text = Gtk.Label(text) heading = Gtk.Box() heading.add(self.icon) heading.add(self.text) self.get_message_area().add(heading) self.get_message_area().set_spacing(0) self.add_button(ok_button_text, Gtk.ResponseType.OK) self.show_all()
def __init__(self): Gtk.Window.__init__(self,title="Ghetto OMR") self.set_resizable(True) self.connect("configure-event",self.new_dim) self.connect("delete-event",Gtk.main_quit) self.win_width = 200 self.win_height = 200 something = Gtk.Label("SOMETHING") self.maximize() self.count =0 self.main = MainGrid(self) self.add(self.main) # # self.main.destroy() # self.main = Gtk.Label("SOMETHING") # self.add(self.main)
def update_widgets(self): widgets = list(self._widgets) widgets.sort(key=lambda item: item.weight) # remove all widgets from the table for child in self._table.get_children(): self._table.remove(child) # add the current controls for index, widget in enumerate(widgets): if hasattr(widget.widget, "get_label"): # checkbox widget.widget.set_label(widget.label) self._table.attach(widget.widget, 0, 2, index, index + 1, xoptions=gtk.Align.FILL, yoptions=gtk.Align.FILL) elif not widget.label: self._table.attach(widget.widget, 0, 2, index, index + 1, xoptions=gtk.Align.FILL, yoptions=gtk.Align.FILL) else: # spinbutton, combobox, ... label = gtk.Label("%s:" % widget.label) label.set_alignment(0.0, 0.5) self._table.attach(label, 0, 1, index, index + 1, xoptions=gtk.Align.FILL, yoptions=gtk.Align.FILL) self._table.attach(widget.widget, 1, 2, index, index + 1, xoptions=gtk.Align.FILL, yoptions=gtk.Align.FILL) self._update_widgets_visibility()
def add_year(self, year_number): # Create a new grid for the year year_grid = yearGrid(year_number) # Update map of years self.year_map[year_number] = year_grid label_box = Gtk.EventBox() label_box.connect('button-press-event', self.year_clicked) label = Gtk.Label(self.nth[year_number] + " Year") label_box.add(label) left_separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL) left_separator.set_margin_start(1) left_separator.set_margin_end(10) self.attach(left_separator, self.new_column(), 0, 1, 3) self.attach(year_grid, self.new_column(), 2, 1, 1) self.attach(label_box, self.width, 0, 1, 1) right_separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL) right_separator.set_margin_start(10) right_separator.set_margin_end(1) self.attach(right_separator, self.new_column(), 0, 1, 3)
def __init__(self, text=None): Gtk.EventBox.__init__(self) self.text = text self.has_entry = False if text is not None: self.label = Gtk.Label(text) self.add(self.label) else: self.entry = Gtk.Entry() self.entry.connect('activate', self.enter_key) self.add(self.entry) self.has_entry = True self.connect('button-press-event', self.double_click) self.show_all()
def __init__(self): super().__init__() self.set_name('HistoryItemViewShortcutHint') self.set_no_show_all(True) self.set_vexpand(False) self.set_hexpand(False) self.set_valign(Gtk.Align.START) self.set_halign(Gtk.Align.START) self.set_size_request(40, 40) self.label = Gtk.Label() self.label.set_halign(Gtk.Align.CENTER) self.label.set_valign(Gtk.Align.CENTER) self.label.set_vexpand(False) self.label.set_hexpand(True) self.label.show() self.add(self.label)
def addLabel( self, text, styles = None ): label = Gtk.Label() label.set_name("startup-label") if "<b>" in text or "<span" in text: label.set_markup(text.replace('&', '&')) # don't remove our pango else: label.set_text(text) if styles: labelStyle = Pango.AttrList() for attr in styles: labelStyle.insert( attr ) label.set_attributes( labelStyle ) label.set_ellipsize( Pango.EllipsizeMode.END ) label.set_alignment( 0.0, 0.5 ) label.show() self.labelBox.pack_start( label , True, True, 0)
def __init__(self, desc): super(KeybindingWidget, self).__init__() self.desc = desc self.label = Gtk.Label(desc) if self.desc != "": self.pack_start(self.label, False, False, 0) self.button = Gtk.Button() self.button.set_tooltip_text(_("Click to set a new accelerator key for opening and closing the menu. ") + _("Press Escape or click again to cancel the operation. ") + _("Press Backspace to clear the existing keybinding.")) self.button.connect("clicked", self.clicked) self.button.set_size_request(200, -1) self.pack_start(self.button, False, False, 4) self.show_all() self.event_id = None self.teaching = False
def __init__(self, parent): Gtk.Dialog.__init__(self, "Something", parent, Gtk.DialogFlags.MODAL, buttons=( Gtk.STOCK_NEW, Gtk.ResponseType.OK, Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) self.set_default_size(400, 600) box = self.get_content_area() label = Gtk.Label("Insert text you want to search for:") box.add(label) # self.entry = Gtk.Entry() # box.add(self.entry) self.main_area = Gtk.Stack() self.main_area.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT) self.main_area.set_transition_duration(1000) self.entry = Gtk.Entry() self.main_area.add_titled(self.entry, "entry_name", "Entry Url") self.labelS = Gtk.Label() self.label_txt = """<big><i>you have choice to runn the scan directly or after setup the scanning process you want to follow on your target</i></big>""" self.labelS.set_markup(self.label_txt) self.labelS.set_line_wrap(True) self.main_area.add_titled(self.labelS, "label_name", "How Scan will Start") self.our_stackSwitcher = Gtk.StackSwitcher() self.our_stackSwitcher.set_stack(self.main_area) box.add(self.our_stackSwitcher) box.add(self.main_area) self.show_all() #~~~~~~~~~~~~ History Dialog ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
def create_feed_entry(title, url, description): container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) title_label = Gtk.Label(title) link_button = Gtk.LinkButton(url, url) description_view = WebKit2.WebView() description_view.set_size_request(400, 400) description_view.load_html(description) container.add(title_label) container.add(link_button) container.add(description_view) container.show() title_label.show() link_button.show() description_view.show() return container
def add_new_feed_tab(self, title, entries): scrolled_window = Gtk.ScrolledWindow() container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) label = Gtk.Label(title) for entry in entries: box = create_feed_entry(entry.title, entry.link, entry.description) box.show() container.add(box) label.show() scrolled_window.add(container) scrolled_window.set_vexpand(True) scrolled_window.set_overlay_scrolling(False) # show manly scrollbars self.notebook.append_page(scrolled_window, label) scrolled_window.show_all()
def on_video_search1_activated(self,searchbox): """ Start searching when the user presses enter """ # Show a spinner to the user while the results are being retrieved spinner = Gtk.Spinner() searching = Gtk.Label("Buscando...") # iterate through the list items and remove child items self.video_list.foreach(lambda child: self.video_list.remove(child)) # Show the spinner and searching label self.video_list.add(spinner) self.video_list.add(searching) spinner.start() # Update the changes self.video_list.show_all() #we spawn a new thread to consume the api asynchronously def start_search(): #for now we use a single backend self.search_response = self.backend.search(searchbox.get_text()) for search_result in self.search_response.get("items",[]): if search_result["id"]["kind"] == "youtube#video": GLib.idle_add(spinner.destroy) GLib.idle_add(searching.destroy) GLib.idle_add(self.update_list,search_result) GLib.idle_add(self.video_list.show) self.download_thread = threading.Thread(target=start_search) self.download_thread.daemon = True self.download_thread.start()
def create_loading_window(self): self.loading_window = Gtk.Window( title = "Games Nebula", icon = app_icon, type = Gtk.WindowType.POPUP, window_position = Gtk.WindowPosition.CENTER_ALWAYS, resizable = False ) self.box_loading_window = Gtk.Box() loading_icon = app_icon.scale_simple(32, 32, InterpType.BILINEAR) self.image_loading = Gtk.Image( pixbuf = loading_icon, margin_left = 10, margin_right = 10 ) self.label_loading = Gtk.Label( label = _("Launching 'Games Nebula'"), margin_right = 10, margin_left = 10, margin_top = 20, margin_bottom = 20 ) self.box_loading_window.pack_start(self.image_loading, True, True, 0) self.box_loading_window.pack_start(self.label_loading, True, True, 0) self.loading_window.add(self.box_loading_window) self.loading_window.show_all()
def build_contents(self): """ Build the main UI display regions """ self.stack = Gtk.Stack() self.box.pack_start(self.stack, True, True, 0) button = Gtk.Button("Install") lab_disclaimer = Gtk.Label( "This is a third party package and is not officially supported" " by Solus") img_warn = Gtk.Image.new_from_icon_name( "dialog-warning-symbolic", Gtk.IconSize.BUTTON) self.abar.pack_start(img_warn) self.abar.pack_start(lab_disclaimer) self.abar.pack_end(button) button.get_style_context().add_class("destructive-action") # Details dumb = Gtk.Label("Details ...") self._fix_label(dumb) dumb.set_property("margin", 12) self.stack.add_titled(dumb, "desc", "Details") # Files dumb = Gtk.Label("Files ...") self._fix_label(dumb) dumb.set_property("margin", 12) self.stack.add_titled(dumb, "files", "Files")
def __init__(self, adate=None): Gtk.EventBox.__init__(self) self.set_size_request(100, 70) box1 = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0) self.add(box1) self.label = Gtk.Label() box1.pack_start(self.label, True, True, padding=1) self.image = Gtk.Image() box1.pack_start(self.image, True, True, padding=1) if adate is not None: self.set_date(adate) self.image.show()
def get_image_with_text2(text, image=None): vbox = Gtk.VBox() if image: # image = Gtk.Image.new_from_file(os.path.join(comun.IMAGESDIR,image)) image = load_image(os.path.join(comun.IMAGESDIR, image)) image.set_alignment(0.5, 0.5) vbox.pack_start(image, True, True, 0) label = Gtk.Label.new(text) label.set_alignment(0.5, 0.5) vbox.pack_start(label, True, True, 0) return vbox