我们从Python开源项目中,提取了以下28个代码示例,用于说明如何使用gi.repository.Gtk.ListBoxRow()。
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 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 __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 make_2x_row(text1, text2): box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) label1 = Gtk.Label() label1.set_text(text1) label1.set_margin_left(12) label1.set_margin_right(12) label2 = Gtk.Label() text2_for_label=text2 if not text2_for_label: text2_for_label="Unassigned" label2.set_markup("<span color=\"#818181\">"+text2_for_label+"</span>") label2.set_margin_left(12) label2.set_margin_right(12) box.set_margin_top(12) box.set_margin_bottom(12) label1.set_size_request(200, 0) label2.set_size_request(200, 0) box.pack_start(label1, True, True, 0) box.pack_start(label2, True, False, 0) row = Gtk.ListBoxRow() row.add(box) row.value={'key': text1, 'val': text2} return row
def __init__(self, parent, window, account): Gtk.ListBoxRow.__init__(self) AccountRow.__init__(self, parent, window, account) self.create_row()
def __init__(self, name, image): Gtk.ListBoxRow.__init__(self) self.name = name self.image = image # Create the list row self.create_row()
def create_row(self): """ Create ListBoxRow """ self.builder = Gtk.Builder.new_from_resource("/org/gnome/Authenticator/application_row.ui") self.builder.get_object("ApplicationLogo").set_from_pixbuf(self.get_icon()) self.builder.get_object("ApplicationName").set_text(self.name) self.add(self.builder.get_object("MainBox"))
def __create_sidebar_row(self, playlist): list_box_row = Gtk.ListBoxRow() list_box_row.playlist = playlist list_box_row.set_size_request(0, 40) list_box_row.add(Gtk.Label(playlist.name, margin_left=20, halign=Gtk.Align.START)) return list_box_row
def __create_sidebar_header(self, name): list_box_row = Gtk.ListBoxRow(activatable=False, selectable=False) list_box_row.set_size_request(0, 40) label = Gtk.Label(f'<b>{name}</b>', margin_left=10, halign=Gtk.Align.START, use_markup=True) list_box_row.add(label) return list_box_row
def addReminder(self,desc,date): row = Gtk.ListBoxRow() hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50) row.add(hbox) ldesc = Gtk.Label(desc, xalign=0) ldate = Gtk.Label(date, xalign=0) cdone = Gtk.CheckButton() hbox.pack_start(ldesc, True, True, 0) hbox.pack_start(ldate, False, True, 0) hbox.pack_start(cdone, False, True, 0) self.lsbReminders.add(row) ############# # Events # #############
def on_font_selected(self, dummy_listbox, listbox_row): ''' Signal handler for selecting a font :param dummy_listbox: The list box used to select a font :type dummy_listbox: Gtk.ListBox object :param listbox_row: A row containing a font name :type listbox_row: Gtk.ListBoxRow object ''' font = listbox_row.get_child().get_text().split(' ')[0] if _ARGS.debug: sys.stdout.write( 'on_font_selected() font = %s\n' %repr(font)) if font == '': font = 'emoji' if font != self._font and font == 'emoji': self._fallback = True self._fallback_check_button.set_active(True) else: self._fallback = False self._fallback_check_button.set_active(False) if GTK_VERSION >= (3, 22, 0): self._font_popover.popdown() self._font_popover.hide() self._font = font self._font_button.set_label(self._font) self._save_options() self._busy_start() GLib.idle_add(self._change_flowbox_font)
def __init__(self, model, *args, **kwargs): super().__init__(*args, **kwargs) builder = Gtk.Builder() builder.add_from_resource(get_resource_path('ui/entity-list.ui')) builder.connect_signals(self) self.content = builder.get_object('content-wrapper') self.list = builder.get_object('list') for entity in model: self.list.add(ListBoxRow(entity)) self.add(self.content)
def populate_gestures_listbox(): for g in gestureHelper.GESTURES_POSSIBLE: box=Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) box.set_margin_top(6) box.set_margin_left(6) box.set_margin_right(6) box.set_margin_bottom(6) label=Gtk.Label() label.set_text(str(g)) box.pack_start(label, False, True, 0) row=Gtk.ListBoxRow() row.add(box) row.value=g listbox_gestures.add(row) listbox_gestures.show_all()
def refreshProfiles(self): # empty list first for child in self.profilesListBox.get_children(): self.profilesListBox.remove(child) for p in custom_profiles.profiles: box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) labelName = Gtk.Label() labelName.set_text(p['name']) box.pack_start(labelName, True, True, 0) box.set_margin_top(6) box.set_margin_bottom(6) if not p['name'] == 'Empty': rmIcon = Gtk.Image() rmIcon.set_from_icon_name('gtk-delete', Gtk.IconSize.BUTTON) rmButton = Gtk.Button() rmButton.add(rmIcon) rmButton.preset = p['name'] rmButton.connect("button-press-event", self.onRmProfile) box.pack_end(rmButton, False, False, 0) row = Gtk.ListBoxRow() row.add(box) row.value = p['name'] self.profilesListBox.add(row) self.profilesListBox.unselect_all() if self.popoverProfiles.get_visible(): self.popoverProfiles.show_all()
def make_image_row(text, img_path): box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) label = Gtk.Label() label.set_text(text) icon = Gtk.Image() icon.set_from_resource(img_path) label.set_margin_left(12) label.set_margin_right(12) box.pack_start(icon, False, False, 0) box.pack_start(label, False, False, 0) row = Gtk.ListBoxRow() row.add(box) return row
def make_row(text): box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) label = Gtk.Label() label.set_text(text) label.set_margin_left(12) label.set_margin_right(12) box.set_margin_top(12) box.set_margin_bottom(12) box.pack_start(label, False, False, 0) row = Gtk.ListBoxRow() row.add(box) return row
def generateParamBox(self): if len(self.procNode.getParams()) == 0: return sep = Gtk.Separator.new(Gtk.Orientation.HORIZONTAL) self.vbox.pack_start(sep, False, False, 0) self.expander = Gtk.Expander.new('Parameters') self.expander.set_resize_toplevel(True) self.paramBox = Gtk.ListBox() for k,v in self.procNode.getParams().items(): hbox = Gtk.Box(Gtk.Orientation.HORIZONTAL, 0) label = Gtk.Label(k) label.set_xalign(0) hbox.pack_start(label, True, True, 0) entry = Gtk.Entry() entry.set_text(str(v)) entry.set_alignment(1) entry.set_has_frame(False) entry.connect('changed', lambda w, d=None, key=k: self.__paramChanged(w, key)) hbox.pack_start(entry, True, True, 0) row = Gtk.ListBoxRow() row.add(hbox) self.paramBox.add(row) self.expander.add(self.paramBox) self.vbox.pack_end(self.expander, True, True, 0)
def __init__(self, desktop_file, notification): GObject.GObject.__init__(self) Gtk.ListBoxRow.__init__(self) self.desktop_file = desktop_file self.notification = notification self.spinner = Gtk.Spinner() self.generate()
def __init__(self, data, bold=False): super(Gtk.ListBoxRow, self).__init__() self.data = data label = Gtk.Label.new(data) if bold: label.set_markup("<b>" + data + "</b>") label.set_xalign(0.0) label.set_margin_top(self.MARGIN) label.set_margin_bottom(self.MARGIN) label.set_margin_start(7) self.add(label)
def __init__(self, table_name): super(Gtk.ListBoxRow, self).__init__() self.data = table_name label = Gtk.Label(table_name) label.set_alignment(0, 1) label.set_padding(5, 2.5) label.set_ellipsize(Pango.EllipsizeMode.END) self.add(label)
def __init__(self, data): super(Gtk.ListBoxRow, self).__init__() self.data = data label = Gtk.Label(data['label']) label.set_alignment(0, 1) self.add(label)
def __init__(self, label, main_widget, alternative_widget=None): self.main_widget = main_widget self.alternative_widget = alternative_widget self.label = label self.stack = Gtk.Stack() self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT) self.stack.set_transition_duration(1000) self.stack.add_named(main_widget, "main_widget") if alternative_widget is not None: self.stack.add_named(self.alternative_widget, "alternative_widget") Gtk.ListBoxRow.__init__(self) hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) hbox.set_border_width(5) hbox.set_margin_left(20) hbox.set_margin_right(20) self.add(hbox) grid = Gtk.Grid() grid.set_column_spacing(15) hbox.pack_start(grid, True, True, 0) self.description_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.description_box.props.hexpand = True self.description_box.props.halign = Gtk.Align.START self.description_box.props.valign = Gtk.Align.CENTER self.label.props.xalign = 0.0 self.description_box.add(self.label) grid.attach(self.description_box, 0, 0, 1, 1) grid.attach_next_to(self.stack, self.description_box, Gtk.PositionType.RIGHT, 1, 1)
def __init__(self, *args, **kwargs): Gtk.ListBoxRow.__init__(self, *args, **kwargs) self.stream = self.get_property('stream') self.callback = self.get_property('callback') self.connect('realize', self.on_fixture_updated) self.connect('notify::stream', self.on_fixture_updated) add_widget_class(self, 'stream-item') self.show()
def __init__(self, *args, **kwargs): Gtk.ListBoxRow.__init__(self, *args, **kwargs) self.filter_name = self.get_property('filter-name') self.filter_label = self.do_filter_label() self.connect('realize', self.on_filter_name_updated) self.connect('notify::filter_name', self.on_filter_name_updated) self.show()
def add_image(self, name): row = Gtk.ListBoxRow() row.set_activatable(True) row.set_selectable(True) row.connect('activate', self.popup_menu) label = Gtk.Label(name) label.set_justify(Gtk.Justification.LEFT) label.set_halign(Gtk.Justification.LEFT) label.set_xalign(0) layout_box = Gtk.Box() layout_box.pack_start(label, True, False, 5) if self.showing_local_images is True: remove_button = Gtk.Button(label='Remove') remove_button.connect('button_press_event', self.remove_image, name) layout_box.add(remove_button) else: pull_button = Gtk.Button(label='Pull') pull_button.connect('button_press_event', self.pull_image, name) layout_box.add(pull_button) run_button = Gtk.Button(label='Run') run_button.connect('button_press_event', self.launch_image, name) layout_box.add(run_button) row.add(layout_box) self.widget_image_list.add(row)
def __init__(self, lights, initial_selection, *args, **kwargs): super().__init__( *args, can_focus=False, shadow_type=Gtk.ShadowType.NONE, visible=True, **kwargs ) builder = Gtk.Builder() builder.add_from_resource(get_resource_path('ui/group-detail.ui')) builder.connect_signals(self) content = builder.get_object('content-wrapper') lights_list = builder.get_object('light-list') self.lights = lights self._selected_lights = initial_selection for light in self.lights: row = Gtk.ListBoxRow( activatable=False, can_focus=False, visible=True ) box = Gtk.Box( can_focus=False, visible=True, margin_start=12, margin_end=6, margin_top=8, margin_bottom=8 ) check_box = Gtk.CheckButton( active=light.light_id in self.selected_lights, border_width=6, can_focus=True, draw_indicator=True, label=light.name, receives_default=False, visible=True ) check_box.connect('toggled', self._on_light_toggle, light) box.add(check_box) row.add(box) lights_list.add(row) self.add(content)
def _on_search_complete(self, results): if results: for row in self.available_bridges.keys(): self.results_list.remove(row) self.available_bridges = {} def make_bridge_row(bridge): row = Gtk.ListBoxRow( can_focus=False, visible=True ) box = Gtk.Box( can_focus=False, margin_start=12, margin_end=12, margin_top=8, margin_bottom=8, valign=Gtk.Align.CENTER, visible=True ) label = Gtk.Label( can_focus=False, label=bridge['display'], visible=True, xalign=0 ) box.add(label) row.add(box) return row row = make_bridge_row(results[0]) self.results_list.add(row) self.available_bridges[row] = results[0] self.selected_bridge = results[0]['address'] for result in results[1:]: row = make_bridge_row(result) self.results_list.add(row) self.available_bridges[row] = result self.set_page_complete(self.search_page, True) self.results_page.set_visible_child_name('results') self.set_page_complete(self.results_page, True) else: self.results_page.set_visible_child_name('no-bridges-found') self.next_page() return False
def __init__(self, game): def buy_cb(k, o, m, ke): self.game.buy_rs(k, o, m, ke) def cb(*_): self.buttons.update_totals(*map(int, (self.coal, self.oil, self.trash, self.nuclear))) def stock_cb(_, rs): k, o, m, ke = rs self.coal.update_count(k) self.oil.update_count(o) self.trash.update_count(m) self.nuclear.update_count(ke) self.buttons.update_stock(k, o, m, ke) super(ResourceView, self).__init__() self.game = game name_row = Gtk.ListBoxRow() name = Gtk.Label(xalign = 0) name.set_markup('<b>Resources Market</b>') hbox = Gtk.Box(orientation = Gtk.Orientation.HORIZONTAL, spacing = 5) hbox.pack_start(name, True, True, 5) name_row.add(hbox) self.coal = ResourceRow('Coal', 0) self.oil = ResourceRow('Oil', 0) self.trash = ResourceRow('Trash', 0) self.nuclear = ResourceRow('Nuclear', 0) self.buttons = ButtonRow(buy_cb) self.coal.p.connect('changed', cb) self.oil.p.connect('changed', cb) self.trash.p.connect('changed', cb) self.nuclear.p.connect('changed', cb) self.insert(name_row, -1) self.insert(self.coal, -1) self.insert(self.oil, -1) self.insert(self.trash, -1) self.insert(self.nuclear, -1) self.insert(self.buttons, -1) self.set_can_focus(False) self.set_selection_mode(Gtk.SelectionMode.NONE) self.game.connect('update_stock', stock_cb)