Python gi.repository.Gtk 模块,Image() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用gi.repository.Gtk.Image()

项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def __init__(self,  filename, init_hilighted=True):
        Gtk.EventBox.__init__(self)
        self.cache = {}
        self.areas = []

        self.connect("motion-notify-event", self.on_mouse_moved)
        self.connect("button-press-event", self.on_mouse_click)
        self.set_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.BUTTON_PRESS_MASK)

        self.size_override = None
        self.image_width = 1
        self.image_height = 1
        self.set_image(filename)
        self.image = Gtk.Image()
        if init_hilighted:
            self.hilight({})
        self.add(self.image)
        self.show_all()
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
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)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
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
项目:apart-gtk    作者:alexheretic    | 项目源码 | 文件源码
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()
项目:apart-gtk    作者:alexheretic    | 项目源码 | 文件源码
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()
项目:poseidon    作者:sidus-dev    | 项目源码 | 文件源码
def data2pixbuf(data, size):

    fp = Image.open(BytesIO(data))
    output = BytesIO()
    fp.thumbnail(size, Image.ANTIALIAS)
    fp.save(output, format="png")
    data = output.getvalue()
    output.close()

    loader = GdkPixbuf.PixbufLoader()
    loader.write(data)
    loader.close()
    pixbuf = loader.get_pixbuf()

    if pixbuf:
        if (pixbuf.get_width(), pixbuf.get_height()) != size: return None
        else: return pixbuf
    else: return None
项目:nautilus-folder-icons    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def set_icon(self, icon_name):
        icon_name = uriparse(icon_name)
        theme = Gtk.IconTheme.get_default()
        # Make sure the icon name doesn't contain any special char
        # Be sure that the icon still exists on the system
        if (is_path(icon_name) and path.exists(icon_name)
                and get_ext(icon_name) in SUPPORTED_EXTS):
            pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(icon_name,
                                                             Image.SIZE, Image.SIZE,
                                                             True)
        elif theme.has_icon(icon_name):
            pixbuf = theme.load_icon_for_scale(icon_name, Image.SIZE, 1, 0)
        else:
            pixbuf = theme.load_icon_for_scale("image-missing",
                                               Image.SIZE, 1, 0)
        self.set_from_pixbuf(pixbuf)
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def __init__(self):
        self.placeholder_image = Gtk.Image.new_from_icon_name(
            Gtk.STOCK_NEW, Gtk.IconSize.DIALOG)
        self.new_feed_button = Gtk.Button("New Feed")

        self.new_feed_vbox = Gtk.Box(Gtk.Orientation.VERTICAL)
        self.new_feed_vbox.set_halign(Gtk.Align.CENTER)
        self.new_feed_vbox.set_valign(Gtk.Align.CENTER)
        _pack_widgets(self.new_feed_vbox,
                      self.placeholder_image,
                      self.new_feed_button)

        self._grid = Gtk.Grid()
        self._grid.set_row_homogeneous(True)
        self._grid.set_column_homogeneous(True)
        self._grid.attach(self.new_feed_vbox, 0, 0, 1, 1)
        self._grid.attach(Gtk.Label("FEED ELEMENT DEBUG1"), 1, 0, 1, 1)  # DEBUG
        self._grid.attach(Gtk.Label("FEED ELEMENT DEBUG2"), 0, 1, 1, 1)  # DEBUG
        self._grid.attach(Gtk.Label("FEED ELEMENT DEBUG3"), 1, 1, 1, 1)  # DEBUG
        self._grid.show_all()

        self.container = self._grid
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def load_icons(self):
        """
        Load all icons used for buttons.
        """
        for icon_path in self.artwork_path.iterdir():
            for key in self.icons:
                filename = icon_path.name.lower()
                if key in filename:
                    icon = Gtk.Image()
                    icon.set_from_file(icon_path.as_posix())
                    if ("_activated_" in filename
                            and "_striked_" not in filename):
                        self.icons[key]["activated"] = icon
                    elif "_striked_" in filename:
                        self.icons[key]["striked"] = icon
                    elif "_16-16_" in filename:
                        self.icons[key]["regular_16px"] = icon
                    else:
                        self.icons[key]["regular"] = icon
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def switch_icon_version(self, icon_id, current_icon):
        """
        Switch version of ``icon``.

        :param icon_id: id of the icon

        :return: :class:`Gtk.Image` or ``None``
        """
        icon_values = self.icons.get(icon_id, None)
        if not icon_values:
            return

        if current_icon is icon_values["regular"]:
            return icon_values["activated"]
        elif current_icon is icon_values["activated"]:
            return icon_values["regular"]
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, name):
        Gtk.Image.__init__(self)

        context = self.get_style_context()
        context.add_class("symbolic-icon")

        # get base dir
        SYMBOLIC_DIR = os.path.join(
            softwarecenter.paths.datadir, "ui/gtk3/art/icons/")

        drop_shadow_path = SYMBOLIC_DIR + self.DROPSHADOW % name
        self.drop_shadow = cairo.ImageSurface.create_from_png(drop_shadow_path)
        icon_path = SYMBOLIC_DIR + self.ICON % name
        self.icon = cairo.ImageSurface.create_from_png(icon_path)

        self.drop_shadow_x_offset = 0
        self.drop_shadow_y_offset = 1

        self.connect("draw", self.on_draw, self.drop_shadow, self.icon,
                     self.drop_shadow_x_offset, self.drop_shadow_y_offset)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, id_, url, cancellable, gallery):
        Gtk.Button.__init__(self)
        self.id_ = id_

        def download_complete_cb(loader, path):
            width, height = ThumbnailGallery.THUMBNAIL_SIZE_CONTRAINTS
            pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
                        path,
                        width, height,  # width, height constraints
                        True)  # respect image proportionality
            im = Gtk.Image.new_from_pixbuf(pixbuf)
            self.add(im)
            self.show_all()

        loader = SimpleFileDownloader()
        loader.connect("file-download-complete", download_complete_cb)
        loader.download_file(
            url, use_cache=ScreenshotGallery.USE_CACHING)

        self.connect("draw", self.on_draw)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, id_, url, cancellable, gallery):
        Gtk.Button.__init__(self)
        self.id_ = id_

        def download_complete_cb(loader, path):
            width, height = ThumbnailGallery.THUMBNAIL_SIZE_CONTRAINTS
            pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
                        path,
                        width, height,  # width, height constraints
                        True)  # respect image proportionality
            im = Gtk.Image.new_from_pixbuf(pixbuf)
            self.add(im)
            self.show_all()

        loader = SimpleFileDownloader()
        loader.connect("file-download-complete", download_complete_cb)
        loader.download_file(
            url, use_cache=ScreenshotGallery.USE_CACHING)

        self.connect("draw", self.on_draw)
项目:batterym    作者:maks-a    | 项目源码 | 文件源码
def battery_monitor(self, _):
        if self.window is None:
            self.window = gtk.Window()
            self.window.connect('delete-event', self.close_window)
            self.window.set_title('Battery Monitor')
            self.window.set_border_width(10)
            self.window.set_size_request(700, 500)
            self.window.set_resizable(False)
            self.window.set_position(gtk.WindowPosition.CENTER)
            self.window.set_icon_from_file(BATTERY_MONITOR_ICON)
            self.window.vbox = gtk.Box()
            self.window.vbox.set_spacing(5)
            self.window.vbox.set_orientation(gtk.Orientation.VERTICAL)
            self.window.add(self.window.vbox)
            self.image = gtk.Image()
            self.image.set_from_file(CAPACITY_HISTORY_CHART)
            self.window.vbox.pack_start(self.image, False, False, 0)
        if not self.window.props.visible:
            self.window.show_all()
项目:games_nebula    作者:yancharkin    | 项目源码 | 文件源码
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()
项目:my-weather-indicator    作者:atareao    | 项目源码 | 文件源码
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()
项目:Gnome-Authenticator    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def generate(self):
        logo_image = Gtk.Image()
        logo_image.set_from_icon_name("dialog-information-symbolic",
                                      Gtk.IconSize.DIALOG)
        no_apps_label = Gtk.Label()
        no_apps_label.set_text(_("There's no account at the moment"))

        self.pack_start(logo_image, False, False, 6)
        self.pack_start(no_apps_label, False, False, 6)
项目:Gnome-Authenticator    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def __init__(self, window):
        self.parent = window

        self.selected_logo = None
        self.step = 1
        self.account_image = Gtk.Image(xalign=0)
        self.secret_code = Gtk.Entry()
        self.name_entry = Gtk.Entry()
        self.hb = Gtk.HeaderBar()

        self.generate_window()
        self.generate_components()
        self.generate_header_bar()
项目:Gnome-Authenticator    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def generate_header_bar(self):
        """
            Generate the header bar box
        """
        self.hb.props.title = _("Add a new account")
        left_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        right_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

        cancel_button = Gtk.Button.new_with_label(_("Cancel"))
        cancel_button.connect("clicked", self.close_window)
        cancel_button.get_style_context().add_class("destructive-action")
        left_box.add(cancel_button)

        self.apply_button = Gtk.Button.new_with_label(_("Add"))
        self.apply_button.get_style_context().add_class("suggested-action")
        self.apply_button.connect("clicked", self.add_account)
        self.apply_button.set_sensitive(False)

        qr_button = Gtk.Button()
        qr_icon = Gio.ThemedIcon(name="qrscanner-symbolic")
        qr_image = Gtk.Image.new_from_gicon(qr_icon, Gtk.IconSize.BUTTON)
        qr_button.set_tooltip_text(_("Scan a QR code"))
        qr_button.set_image(qr_image)
        qr_button.connect("clicked", self.on_qr_scan)

        right_box.add(qr_button)
        right_box.add(self.apply_button)

        self.hb.pack_start(left_box)
        self.hb.pack_end(right_box)
        self.set_titlebar(self.hb)
项目:mama    作者:maateen    | 项目源码 | 文件源码
def __init__(self, app):
        Gtk.Window.__init__(self, title="Mama Manager", application=app)
        self.set_default_size(800, 400)
        self.set_resizable(True)
        self.set_border_width(0)
        self.get_focus()
        self.set_position(Gtk.WindowPosition.CENTER)
        path = os.path.dirname(os.path.abspath(__file__)).strip('librairy')
        self.icon_path = path + 'resources/icons/'
        self.set_default_icon_from_file(path + '/resources/icons.png')

        # get two button to switch between view
        setup_icon = Gtk.Image()
        setup_icon.set_from_file(self.icon_path + 'setup.png')
        button_config = Gtk.ToolButton(icon_widget=setup_icon)
        button_config.set_label("Setup")
        button_config.set_is_important(True)
        button_config.set_tooltip_text('Open setup window')
        button_config.show()
        button_config.connect("clicked", self.change_page, 1)

        button_back = Gtk.Button.new_from_stock(Gtk.STOCK_OK)
        button_back.connect("clicked", self.change_page, 0)
        button_cancel = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL)
        button_cancel.connect("clicked", self.change_page, 0)

        # get the main view
        content = AddWindow(button_config)
        label_main = Gtk.Label("main")
        config = SetupWindow(button_back, button_cancel)
        label_config = Gtk.Label("config")

        # create a Gtk.Notebook to store both page
        self.notebook = Gtk.Notebook.new()
        self.notebook.set_show_tabs(False)
        self.notebook.append_page(content.get_grid(), label_main)
        self.notebook.append_page(config.getGrid(), label_config)

        # show
        self.add(self.notebook)
        self.show_all()
项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def setup_widgets(self):
        # Create
        self._icon = Gtk.Image()
        self._model = Gtk.ListStore(str, object, str)
        self._combo = Gtk.ComboBox.new_with_model(self._model)
        self._box = Gtk.Box(Gtk.Orientation.HORIZONTAL, 0)
        self._savebutton = None
        self._switch_to_button = None

        # Setup
        rend1 = Gtk.CellRendererText()
        rend2 = Gtk.CellRendererText()
        self._icon.set_margin_right(10)
        self._combo.pack_start(rend1, True)
        self._combo.pack_start(rend2, False)
        self._combo.add_attribute(rend1, "text", 0)
        self._combo.add_attribute(rend2, "text", 2)
        self._combo.set_row_separator_func(
            lambda model, iter : model.get_value(iter, 1) is None and model.get_value(iter, 0) == "-" )
        self.update_icon()

        # Signals
        self._combo.connect('changed', self.on_combo_changed)
        self.connect("button_press_event", self.on_button_press)

        # Pack
        self._box.pack_start(self._icon, False, True, 0)
        self._box.pack_start(self._combo, True, True, 0)
        self.add(self._box)
项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def build_button(label, icon_name=None, icon_widget=None, use_stock=False):
        """ Builds button situable for action area """
        b = Gtk.Button.new_from_stock(label) if use_stock \
            else Gtk.Button.new_with_label(label)
        b.set_use_underline(True)
        if not icon_name is None:
            icon_widget = Gtk.Image()
            icon_widget.set_from_icon_name(icon_name, Gtk.IconSize.BUTTON)
        if not icon_widget is None:
            b.set_image(icon_widget)
            b.set_always_show_image(True)
        return b
项目:fux-terminal    作者:fuxprojesi    | 项目源码 | 文件源码
def on_button_press_event(wid, event):
        """
        on_button_press_event: Sa? tu?a t?kland???nda yap?lacak i?lem

        Fare'nin sa? tu?una t?kland???nda bu fonksiyon tetiklenir. Fonksiyon içinde
        T?klanan tu?un sa? tu? olup olmad??? sorgulan?r. E?er do?ru ise aç?l?r menü
        Olu?turulur. Olu?turulam menü argümanlar?na sinyaller atan?r ve gösterilir.
        """
        if event.type == Gdk.EventType.BUTTON_PRESS and event.button == 3:
           menu = Gtk.Menu()

           term = Gtk.ImageMenuItem("Terminal Aç")
           term_img = Gtk.Image()
           term_img.set_from_icon_name("utilities-terminal", Gtk.IconSize.MENU)
           term.set_image(term_img)
           term.set_always_show_image(True)

           copy = Gtk.ImageMenuItem("Kopyala")
           copy_img = Gtk.Image()
           copy_img.set_from_icon_name("edit-copy", Gtk.IconSize.MENU)
           copy.set_image(copy_img)
           copy.set_always_show_image(True)

           paste = Gtk.ImageMenuItem("Yap??t?r")
           paste_img = Gtk.Image()
           paste_img.set_from_icon_name("edit-paste", Gtk.IconSize.MENU)
           paste.set_image(paste_img)
           paste.set_always_show_image(True)

           menu.append(term)
           menu.append(Gtk.SeparatorMenuItem())
           menu.append(copy)
           menu.append(paste)

           term.connect("activate", RightClick.open_terminal)
           copy.connect("activate", RightClick.copy_text)
           paste.connect("activate", RightClick.paste_text)

           menu.show_all()
           menu.popup(None, None, None, None, event.button, event.time)
           return True
项目:nvim-pygtk3    作者:rliang    | 项目源码 | 文件源码
def update(self, buflist: list, bufcurr: int):
        """Updates the widget's buttons.

        Increases the internal button cache if needed, then displays the
        appropriate amount of buttons, updating their state.

        :buflist: list of tuples (buffer-number, buffer-name, buffer-modified).
        :bufcurr: the active buffer's number.

        """
        self.props.updating = True
        self.bids = [id for id, *_ in buflist]
        for _ in range(len(buflist) - len(self.btns)):
            ico = Gtk.Image(icon_name='document-edit-symbolic')
            btn = Gtk.ToggleButton(None, can_focus=False, image=ico)
            btn.connect('toggled', self._do_button_toggled)
            self.btns.append(btn)
        for btn in self.get_children():
            self.remove(btn)
        for btn, (id, name, modified) in zip(self.btns, buflist):
            btn.set_label(name)
            btn.set_active(id == bufcurr)
            btn.set_always_show_image(modified)
            self.add(btn)
        self.show_all()
        self.props.updating = False
项目:mastodon-gtk    作者:GabMus    | 项目源码 | 文件源码
def add_image_to_flowbox(path):
    pbuf=GdkPixbuf.Pixbuf().new_from_file_at_scale(path, -1, 100, True)
    img_w=Gtk.Image()
    img_w.set_from_pixbuf(pbuf)
    toot_image_flowbox.insert(img_w, -1)
    img_w.show()
    img_w.value=path
    images_to_toot.append(path)
    update_show_delete()
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def sad_face(self):
        l = gu.HarmonicProgressionLabel(_("Wrong"))
        l.show()
        self.g_box.pack_start(l, False, False, 0)
        self.g_face = Gtk.EventBox()
        self.g_face.connect('button_press_event', self.on_sadface_event)
        self.g_face.show()
        im = Gtk.Image()
        im.set_from_stock('solfege-sadface', Gtk.IconSize.LARGE_TOOLBAR)
        im.show()
        self.g_face.add(im)
        self.g_box.pack_start(self.g_face, False, False, 0)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def happy_face(self):
        l = gu.HarmonicProgressionLabel(_("Correct"))
        l.show()
        self.g_box.pack_start(l, False, False, 0)
        self.g_face = Gtk.EventBox()
        self.g_face.connect('button_press_event', self.on_happyface_event)
        self.g_face.show()
        im = Gtk.Image()
        im.set_from_stock('solfege-happyface', Gtk.IconSize.LARGE_TOOLBAR)
        im.show()
        self.g_face.add(im)
        self.g_box.pack_start(self.g_face, False, False, 0)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def pngbutton(self, i):
        "used by the constructor"
        btn = Gtk.Button()
        if i > len(const.RHYTHMS):
            im = Gtk.Image()
            im.set_from_stock("gtk-missing-image", Gtk.IconSize.LARGE_TOOLBAR)
            im.show()
            btn.add(im)
        else:
            btn.add(gu.create_rhythm_image(const.RHYTHMS[i]))
        btn.show()
        btn.connect('clicked', self.guess_element, i)
        return btn
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def create_pixmap_button(self):
        im = Gtk.Image()
        im.set_from_stock("solfege-rhythm-c4", Gtk.IconSize.LARGE_TOOLBAR)
        im.show()
        btn = Gtk.Button()
        btn.add(im)
        return btn
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def happy_face(self):
        l = gu.HarmonicProgressionLabel(_("Correct"))
        l.show()
        self.g_box.pack_start(l, False, False, 0)
        self.g_face = Gtk.EventBox()
        self.g_face.connect('button_press_event', self.on_happyface_event)
        self.g_face.show()
        im = Gtk.Image()
        im.set_from_stock('solfege-happyface', Gtk.IconSize.LARGE_TOOLBAR)
        im.show()
        self.g_face.add(im)
        self.g_box.pack_start(self.g_face, False, False, 0)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def create_stock_menu_item(stock, txt, callback, ag, accel_key, accel_mod):
    box = Gtk.HBox(False, 0)
    box.set_spacing(PAD_SMALL)
    im = Gtk.Image()
    im.set_from_stock(stock, Gtk.IconSize.MENU)
    item = Gtk.ImageMenuItem(txt)
    item.set_image(im)
    if accel_key != 0:
        item.add_accelerator('activate', ag, accel_key, accel_mod, Gtk.AccelFlags.VISIBLE)
    item.connect('activate', callback)
    return item
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def create_png_image(fn):
    """
    Create an image by loading a png file from graphics dir
    """
    im = Gtk.Image()
    im.set_from_file(os.path.join('graphics', fn)+'.png')
    im.show()
    return im
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def create_rhythm_image(rhythm):
    """
    rhythm : a string like 'c8 c8' or 'c8 c16 c16'
    The image returned is shown.
    """
    im = Gtk.Image()
    im.set_from_file(os.path.join('graphics', 'rhythm-%s.png' % (rhythm.replace(" ", ""))))
    im.show()
    return im
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def make_warning(self):
        im = Gtk.Image()
        im.set_from_stock(Gtk.STOCK_DIALOG_WARNING, Gtk.IconSize.MENU)
        self.set_image(im)
        self.set_alignment(0.0, 0.5)
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def __init__(self, parent, app, info):
        super().__init__(_('Verification..'), app.window,
                         Gtk.DialogFlags.MODAL,
                         (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                          Gtk.STOCK_OK, Gtk.ResponseType.OK))

        self.set_default_response(Gtk.ResponseType.OK)
        self.set_default_size(320, 200)
        self.set_border_width(10)
        self.app = app

        box = self.get_content_area()
        box.set_spacing(10)

        gutil.async_call(net.urlopen, info['img'],
                         {'Cookie': app.cookie.header_output()},
                         callback=self.update_img)
        self.img = Gtk.Image()
        box.pack_start(self.img, False, False, 0)

        self.entry = Gtk.Entry()
        self.entry.connect('activate',
                lambda *args: self.response(Gtk.ResponseType.OK))
        box.pack_start(self.entry, False, False, 0)

        box.show_all()
项目:MokaPlayer    作者:vedard    | 项目源码 | 文件源码
def __create_flowbox(self, flowbox):
        self.logger.info('Creating Flowbox')
        start = time.perf_counter()

        image_loading_queue = []
        children = []

        order = AbstractPlaylist.OrderBy[self.userconfig['grid']['sort']['field']]
        desc = self.userconfig['grid']['sort']['desc']
        image_size = self.userconfig['flowbox']['image_size']
        margin = self.userconfig['flowbox']['margin']
        collections = self.current_playlist.collections(order, desc, self.txt_search.get_text())

        for child in flowbox.get_children():
            flowbox.remove(child)

        for item in collections:
            image = Gtk.Image()
            image.set_size_request(image_size, image_size)
            image.get_style_context().add_class('cover')
            image_loading_queue.append((image, item.Cover, image_size, image_size))

            if isinstance(item, Album):
                children.append(self.__create_album_flowboxitem(item, image, margin))
            elif isinstance(item, Artist):
                children.append(self.__create_artist_flowboxitem(item, image, margin))

        for child in children:
            flowbox.add(child)
        flowbox.show_all()

        image_helper.set_multiple_image(image_loading_queue)

        end = time.perf_counter()
        self.logger.info('Flowbox created in {:.3f} seconds'.format(end - start))
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def _hide_tb_toggled(self, widget):
        if widget.get_active():
            self.main.tviews.term_nb.show()
            i = Gtk.Image()
            i.set_from_stock(Gtk.STOCK_GO_DOWN, Gtk.IconSize.MENU)
            widget.set_image(i)
        else:
            self.main.tviews.term_nb.hide()
            i = Gtk.Image()
            i.set_from_stock(Gtk.STOCK_GO_UP, Gtk.IconSize.MENU)
            widget.set_image(i)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def __init__(self):
        self.img_static = Gtk.Image()
        self.img_static.set_from_file(datafile_path('throbber_static.gif'))
        self.img_static.show()
        self.img_animat = Gtk.Image()
        self.img_animat.set_from_file(datafile_path('throbber_animat.gif'))
        self.img_animat.show()

        super(Throbber,self).__init__(self.img_static, "")
        self.set_sensitive(False)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def __init__(self, text, menu):
        GObject.GObject.__init__(self)
        self.menu = menu
        hbox1 = Gtk.HBox()
        hbox2 = Gtk.HBox()
        icon = Gtk.Image()
        icon.set_from_file(datafile_path('bokken-small.svg'))
        hbox1.pack_start(icon, True, True, 3)
        label = Gtk.Label()
        label.set_markup("<b>"+ text + "</b>")
        hbox1.pack_start(label, True, True, 3)
        arrow = Gtk.Arrow(Gtk.ArrowType.DOWN, Gtk.ShadowType.IN)
        hbox1.pack_start(arrow, False, False, 3)
        hbox2.pack_start(hbox1, True, True, 0)

        # MEOW Text settings
        #attrs = Pango.AttrList()
        #attrs.change(Pango.AttrWeight(Pango.Weight.SEMIBOLD, 0, -1))
        #label.set_attributes(attrs)

        self.add(hbox2)
        self.set_relief(Gtk.ReliefStyle.NORMAL)
        self.set_can_focus(True)
        self.set_can_default(False)
        self.connect("toggled", self.on_toggled)

        for sig in "selection-done", "deactivate", "cancel":
            menu.connect(sig, self.on_menu_dismiss)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create_seek_buttons(self):
        self.hbox = Gtk.HBox(False, 1)

        self.back = Gtk.Button()
        self.back_img = Gtk.Image()
        self.back_img.set_from_stock(Gtk.STOCK_GO_BACK, Gtk.IconSize.MENU)
        self.back.set_image(self.back_img)
        self.back.set_relief(Gtk.ReliefStyle.NONE)
        self.back.connect('clicked', self.do_seek, 'b')

        self.forward = Gtk.Button()
        self.forward_img = Gtk.Image()
        self.forward_img.set_from_stock(Gtk.STOCK_GO_FORWARD, Gtk.IconSize.MENU)
        self.forward.set_image(self.forward_img)
        self.forward.set_relief(Gtk.ReliefStyle.NONE)
        self.forward.connect('clicked', self.do_seek, 'f')

        self.seek = Gtk.Entry()
        self.seek.set_max_length(30)
        self.seek.set_icon_from_stock(1, Gtk.STOCK_JUMP_TO)
        self.seek.set_activates_default(True)
        self.seek.connect("activate", self.goto)
        self.seek.connect("icon-press", self.goto)
        self.seek.set_icon_tooltip_text(1, 'Go')

        self.hbox.pack_start(self.back, False, False, 0)
        self.hbox.pack_start(self.forward, False, False, 0)
        self.hbox.pack_start(self.seek, True, True, 0)

        return self.hbox
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def popup_registers(self, widget):
        dialog = Gtk.Dialog('16-bit and 8-bit registers', self, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CLOSE,Gtk.ResponseType.CLOSE))
        ui.gtk3.common.set_bokken_icon(dialog)
        reg_img = Gtk.Image()
        reg_img.set_from_file(datafile_path('registers.png'))
        reg_label = Gtk.Label("The four primary general purpose registers (EAX, EBX, ECX and EDX)\nhave 16 and 8 bit overlapping aliases.")
        reg_label.set_alignment(0.1, 0.1)
        reg_label.set_padding (0, 3)
        dialog.vbox.pack_start(reg_label, False, False, 2)
        dialog.vbox.pack_start(reg_img, True, True, 2)
        dialog.show_all()
        dialog.run()
        dialog.destroy()
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def _hide_tb_toggled(self, widget):
        if widget.get_active():
            self.main.topbuttons.hide()
            self.main.mbar.hide()
            i = Gtk.Image()
            i.set_from_stock(Gtk.STOCK_GO_DOWN, Gtk.IconSize.MENU)
            widget.set_image(i)
        else:
            self.main.topbuttons.show()
            self.main.mbar.show()
            i = Gtk.Image()
            i.set_from_stock(Gtk.STOCK_GO_UP, Gtk.IconSize.MENU)
            widget.set_image(i)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def generate_thumbnail(self, dotcode):
        #size = self.tree.allocation.width
        size = self.side_hb.get_allocated_width()
        tmp_dot = tempfile.NamedTemporaryFile(delete = False)
        tmp_dot.write(dotcode)
        tmp_dot.close()

        cmd = "dot -Tpng " + tmp_dot.name + " > " + tmp_dot.name + ".png" 
        os.system(cmd)

        im = Image.open(tmp_dot.name + ".png")
        im.convert('RGBA')
        im.thumbnail([size,size], Image.ANTIALIAS)
        #im.save(tmp_dot.name + ".png.thumbnail", "JPEG")

        # Add white backgound as image is transparent
        offset_tuple = (im.size[0], im.size[1])
        final_thumb = Image.new(mode='RGBA',size=offset_tuple, color=(255,255,255,0))
        final_thumb.paste(im)
        final_thumb.save(tmp_dot.name + ".png.thumbnail", "PNG")

        self.fill_preview(tmp_dot.name + ".png.thumbnail")

        os.remove(tmp_dot.name)
        os.remove(tmp_dot.name + ".png")
        os.remove(tmp_dot.name + ".png.thumbnail")
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create_preview(self):
        # Create Image window for graph preview
        self.preview = Gtk.Image()
        self.preview.show()
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def _hide_tb_toggled(self, widget):
        if widget.get_active():
            self.main.topbuttons.main_tb.hide()
            i = Gtk.Image()
            i.set_from_stock(Gtk.STOCK_GO_DOWN, Gtk.IconSize.MENU)
            widget.set_image(i)
        else:
            self.main.topbuttons.main_tb.show()
            i = Gtk.Image()
            i.set_from_stock(Gtk.STOCK_GO_UP, Gtk.IconSize.MENU)
            widget.set_image(i)
项目:ghetto_omr    作者:pohzhiee    | 项目源码 | 文件源码
def __init__(self,parent):
        Gtk.Grid.__init__(self)
        self.set_border_width(10)

        self.vbox = Gtk.VBox(spacing=6)
        self.vbox = Gtk.Box(spacing=6)
        self.add(self.vbox)

        self.button1 = Gtk.ToggleButton("Button1")
        self.button1.connect("toggled", self.on_button_toggled, "1")
        self.button1.set_active(True)
        #self.button1img = Gtk.Image.new_from_icon_name("filenew", Gtk.IconSize.MENU)
        #self.button1.set_image(self.button1img)

        self.vbox.pack_start(self.button1, True, True, 0)

        self.button2 = Gtk.ToggleButton("Button 2")
        self.button2.connect("toggled", self.on_button_toggled, "2")
        self.vbox.pack_start(self.button2, True, True, 0)

        self.button3 = Gtk.ToggleButton("Button 3")
        self.button3.connect("toggled", self.on_button_toggled, "3")
        self.vbox.pack_start(self.button3, True, True, 0)

        self.attach(self.button1, 0, 0, 1, 1)
        self.attach(self.button2, 1, 0, 3, 1)
        self.attach(self.button3, 2, 0, 1, 1)
项目:ghetto_omr    作者:pohzhiee    | 项目源码 | 文件源码
def on_button_press(self, w, e):

        if e.type == Gdk.EventType.BUTTON_PRESS \
                and e.button == 1: #Left Button
            self.coords.append([e.x, e.y])

        if e.type == Gdk.EventType.BUTTON_PRESS \
                and e.button == 3: #Right Button
            self.queue_draw()


            # class image(Gtk.Image):
#     def __init__(self, parent):
#         x
项目:poseidon    作者:sidus-dev    | 项目源码 | 文件源码
def is_image_valid(file):

    try: Image.open(file)
    except IOError: return False
    return True
项目:poseidon    作者:sidus-dev    | 项目源码 | 文件源码
def make_icon(filename):

    icon = Gtk.Image()
    icon.set_from_file("{}{}".format(icns, filename))

    return icon
项目:nautilus-folder-icons    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Image.__init__(self)
        self.props.icon_size = Image.SIZE