def _generate_content(self, entries=None): if entries: for idx, name in enumerate(entries): if idx % self.column_count == 0: row = layout.Box() row.spacing = self.spacing self.space.add_child(row) button = widgets.Button() button.set_style_class("PisakSymbolerButton") button.set_label(name) button.ratio_width = self.tile_ratio_width button.ratio_height = self.tile_ratio_height button.connect("clicked", self._on_select, name, entries[name]) row.add_child(button) row = layout.Box() row.spacing = self.spacing self.space.add_child(row) button = widgets.Button() row.add_child(button) button.set_style_class("PisakSymbolerButton") button.ratio_width = self.tile_ratio_width button.ratio_height = self.tile_ratio_height button.connect("clicked", self._close) if entries: button.set_label(self.exit_button_label) else: button.set_label(self.continue_button_label)
def _generate_content(self, text_files=None): if text_files: for idx, file in enumerate(text_files): if idx % self.column_count == 0: row = layout.Box() row.spacing = self.spacing self.space.add_child(row) button = widgets.Button() button.set_style_class("PisakSpellerButton") button.set_label(file.name) button.ratio_width = self.tile_ratio_width button.ratio_height = self.tile_ratio_height button.connect("clicked", self._on_select, file.path) row.add_child(button) row = layout.Box() row.spacing = self.spacing self.space.add_child(row) button = pisak.widgets.Button() row.add_child(button) button.set_style_class("PisakSpellerButton") button.ratio_width = self.tile_ratio_width button.ratio_height = self.tile_ratio_height button.connect("clicked", self._close) if text_files: button.set_label(self.exit_button_label) else: button.set_label(self.continue_button_label)
def __init__(self, mailbox): super().__init__() self.hilite_tool = widgets.Aperture() self.label = layout.Box() self.box.add_child(self.label) self.label.orientation = Clutter.Orientation.VERTICAL self.label.ratio_spacing = 0.03 frame = widgets.Frame() frame.set_style_class('PisakEmailMessageTile') self.add_child(frame) margin = unit.h(0.0095) # create separate label for each header, specific to the given # `mailbox`; each label is set as an attribute of `self` with a # name of the corresponding header's lower-cased name; # list of headers is at the moment taken from the `imap_client` module. for header in imap_client.MAILBOX_HEADERS[mailbox]: label = Mx.Label() setattr(self, header.lower(), label) label.set_margin_right(margin) label.set_margin_left(margin) label.get_clutter_text().set_line_alignment(Pango.Alignment.CENTER) label.set_style_class('PisakEmailMessageTile' + header) self.label.add_child(label)
def _add_items(self, items, spacing): for index, row in enumerate(items): group = scanning.Group() group.strategy = scanning.RowStrategy() try: group.sound = self.row_sounds[index] except IndexError: group.sound = str(index + 1) if index + 1 < 10 else 'scan' group.strategy.unwind_to = self.strategy.unwind_to or self group.strategy.max_cycle_count = self.strategy.max_cycle_count group.strategy.interval = self.strategy.interval group_box = layout.Box() group_box.spacing = spacing group.add_child(group_box) self.add_child(group) for item in row: group_box.add_child(item) self.items.append(item)
def __init__(self): super().__init__() margin = 8 self.label = layout.Box() self.box.add_child(self.label) self.label.orientation = Clutter.Orientation.VERTICAL self.label.spacing = 20 self.title = widgets.Label() self.date = widgets.Label() self.title.set_margin_right(margin) self.title.set_margin_left(margin) self.date.set_margin_right(margin) self.date.set_margin_left(margin) self.title.get_clutter_text().set_line_alignment( Pango.Alignment.CENTER) self.date.get_clutter_text().set_line_alignment(Pango.Alignment.CENTER) self.title.set_style_class("PisakBlogPostTileTitle") self.date.set_style_class("PisakBlogPostTileDate") self.label.add_child(self.title) self.label.add_child(self.date) self.label.get_text = self.title.get_text
def _add_tiles(self, rows, columns, tiles, ratio_spacing): index = 0 for _row in range(rows): group = scanning.Group() group.strategy = scanning.RowStrategy() group.selector = self.selector group.strategy.unwind_to = self group.strategy.max_cycle_count = self.strategy.max_cycle_count group.strategy.interval = self.strategy.interval group_box = layout.Box() group_box.ratio_spacing = ratio_spacing group.add_child(group_box) self.add_child(group) for _col in range(columns): if index < len(tiles): actor = tiles[index] group_box.add_child(actor) else: actor = Clutter.Actor() group_box.add_child(actor) actor.set_x_expand(True) actor.set_y_expand(True) index += 1