当前位置: 首页>>代码示例>>Python>>正文


Python Gtk.Image方法代码示例

本文整理汇总了Python中gi.repository.Gtk.Image方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.Image方法的具体用法?Python Gtk.Image怎么用?Python Gtk.Image使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gi.repository.Gtk的用法示例。


在下文中一共展示了Gtk.Image方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Image [as 别名]
def __init__(self, **kwargs):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
        GObject.GObject.__init__(self)

        self.is_edit = kwargs.get("edit", False)
        self._account = kwargs.get("account", None)

        self._providers_store = Gtk.ListStore(str, str)

        self.logo_img = Gtk.Image()
        self.username_entry = Gtk.Entry()
        self.provider_combo = Gtk.ComboBox.new_with_model_and_entry(
            self._providers_store)
        self.token_entry = Gtk.Entry()
        self._build_widgets()
        self._fill_data() 
开发者ID:bilelmoussaoui,项目名称:Authenticator,代码行数:18,代码来源:add.py

示例2: _build_widgets

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Image [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) 
开发者ID:bilelmoussaoui,项目名称:Authenticator,代码行数:19,代码来源:list.py

示例3: set_from_name

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Image [as 别名]
def set_from_name(name):
    icon_number = 0
    if name == "green_arrow":
        icon_number = 0
    elif name == "pale_right_arrow":
        icon_number = 1
    elif name == "dark_left_arrow":
        icon_number = 2
    elif name == "dark_right_arrow":
        icon_number = 3
    elif name == "pale_left_arrow":
        icon_number = 4
    elif name == "tick":
        icon_number = 5
    elif name == "cross":
        icon_number = 6
    elif name == "dropdown_arrow":
        icon_number = 7
    # Create main window
    filename = os.path.join(common_images_dir, "icons.png")
    pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(filename, 192, 24)
    subpixbuf = pixbuf.new_subpixbuf(24 * icon_number, 0, 24, 24).add_alpha(True, 255, 255, 255)
    image = Gtk.Image()
    image.set_from_pixbuf(subpixbuf)
    return image 
开发者ID:KanoComputing,项目名称:kano-toolset,代码行数:27,代码来源:icons.py

示例4: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Image [as 别名]
def __init__(self, image_path):
            Gtk.ImageMenuItem.__init__(self)
            self.get_style_context().add_class("KanoComboBox")
            self.set_use_underline(False)
            self.set_always_show_image(True)

            # set the given image
            pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_path)
            image = Gtk.Image.new_from_pixbuf(pixbuf)

            # put the image inside an alignment container for centering
            self.box = Gtk.Alignment()
            self.box.set_padding(0, 0, 0, pixbuf.get_width())
            self.box.add(image)

            # by default, a MenuItem has an AccelLabel widget as it's one and only child
            self.remove(self.get_child())
            self.add(self.box)

            # By overriding this signal we can stop the Menu
            # containing this item from being popped down
            self.connect("button-release-event", self.do_not_popdown_menu) 
开发者ID:KanoComputing,项目名称:kano-toolset,代码行数:24,代码来源:kano_combobox.py

示例5: window_deleted_cb

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Image [as 别名]
def window_deleted_cb(self, widget, event, view):
        if (self._gui_config.get("confirm_close", self.DEFAULT_CONFIRM_CLOSE)
                and self._source_buffer.get_text(self._source_buffer.get_start_iter(),
                                                 self._source_buffer.get_end_iter(), True) != self.text):
            dlg = Gtk.MessageDialog(self._window, Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.NONE)
            dlg.set_markup(
                "<b>Do you want to close TexText without save?</b>\n\n"
                "Your changes will be lost if you don't save them."
            )
            dlg.add_button("Continue editing", Gtk.ResponseType.CLOSE) \
                .set_image(Gtk.Image.new_from_stock(Gtk.STOCK_GO_BACK, Gtk.IconSize.BUTTON))
            dlg.add_button("Close without save", Gtk.ResponseType.YES) \
                .set_image(Gtk.Image.new_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.BUTTON))

            dlg.set_title("Close without save?")
            res = dlg.run()
            dlg.destroy()
            if res in (Gtk.ResponseType.CLOSE, Gtk.ResponseType.DELETE_EVENT):
                return True

        Gtk.main_quit()
        return False 
开发者ID:textext,项目名称:textext,代码行数:24,代码来源:asktext.py

示例6: add_toolitem

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Image [as 别名]
def add_toolitem(self, name, group, position, image_file, description,
                     toggle):
        if toggle:
            tbutton = Gtk.ToggleToolButton()
        else:
            tbutton = Gtk.ToolButton()
        tbutton.set_label(name)

        if image_file is not None:
            image = Gtk.Image()
            image.set_from_file(image_file)
            tbutton.set_icon_widget(image)

        if position is None:
            position = -1

        self._add_button(tbutton, group, position)
        signal = tbutton.connect('clicked', self._call_tool, name)
        tbutton.set_tooltip_text(description)
        tbutton.show_all()
        self._toolitems.setdefault(name, [])
        self._toolitems[name].append((tbutton, signal)) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:24,代码来源:backend_gtk3.py

示例7: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Image [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() 
开发者ID:ImEditor,项目名称:ImEditor,代码行数:27,代码来源:tab.py

示例8: tick_icon

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Image [as 别名]
def tick_icon():
    '''This should return a tick image.  We use this to show which
    WiFi network is already selected
    '''

    width = 24
    height = 24

    icons_path = os.path.join(common_images_dir, 'icons.png')

    tick_pixbuf = GdkPixbuf.Pixbuf.new_from_file(icons_path)

    tick_pixbuf = tick_pixbuf.new_subpixbuf(5 * 24, 0, width, height)
    tick_image = Gtk.Image()
    tick_image.set_from_pixbuf(tick_pixbuf)

    return tick_image 
开发者ID:KanoComputing,项目名称:kano-settings,代码行数:19,代码来源:misc.py

示例9: format_image

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Image [as 别名]
def format_image(self, name):
        '''In the wallpaper, we get a 4 by 3 ratio, so need to change the size
        to 120 by 90 and then crop it
        '''

        width = self.icon_width
        height = self.icon_height

        # Create the wallpaper thumbnail
        try:
            # The original picture is not square, so resize the picture to
            # scale and then crop the picture
            wallpaper_name = name + name_pattern
            wallpaper_path = os.path.join(self.get_path(name), wallpaper_name)
            wallpaper_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                wallpaper_path, 120, 90
            )
            cropped_wallpaper = wallpaper_pixbuf.new_subpixbuf(15, 0, width,
                                                               height)
            image = Gtk.Image()
            image.set_from_pixbuf(cropped_wallpaper)
            return image
        except:
            return None 
开发者ID:KanoComputing,项目名称:kano-settings,代码行数:26,代码来源:set_wallpaper.py

示例10: build_menu_item

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Image [as 别名]
def build_menu_item(self, obj_type, handle):

        if obj_type == 'Person':
            person = self.dbstate.db.get_person_from_handle(handle)
            name = name_displayer.display(person)
        elif obj_type == 'Event':
            event = self.dbstate.db.get_event_from_handle(handle)
            name = str(event.get_type())

        item = Gtk.ImageMenuItem(None)
        image = Gtk.Image.new_from_icon_name('gtk-edit', Gtk.IconSize.MENU)
        image.show()
        label = Gtk.Label(label=_("Edit %s") % name)
        label.show()
        label.set_halign(Gtk.Align.START)

        item.set_image(image)
        item.add(label)

        item.connect('activate', self.edit_menu, handle, obj_type)
        item.show()
        return item 
开发者ID:gramps-project,项目名称:addons-source,代码行数:24,代码来源:combinedview.py

示例11: build_thumbnail_gui

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Image [as 别名]
def build_thumbnail_gui(self, pbloader, width, height):
        """
        builds the thumbnail viewing area.
        """
        main_vbox = Gtk.VBox()
        main_vbox.set_size_request((width - 30), (height - 30))

        hbox = Gtk.HBox(homogeneous=False, spacing=0)
        main_vbox.pack_start(hbox, expand=False, fill=False, padding=5)
        hbox.show()

        # Get the resulting pixbuf and build an image to be displayed
        pixbuf = pbloader.get_pixbuf()
        pbloader.close()

        imgwidget = Gtk.Image()
        imgwidget.set_from_pixbuf(pixbuf)
        hbox.pack_start(imgwidget, expand=False, fill=True, padding=0)
        imgwidget.show()

        main_vbox.show_all()
        return main_vbox 
开发者ID:gramps-project,项目名称:addons-source,代码行数:24,代码来源:editexifmetadata.py

示例12: __convert_dialog

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Image [as 别名]
def __convert_dialog(self, _object):
        """
        Handles the Convert question Dialog
        """
        # Convert and delete original file or just convert
        parent = self.gui.get_container_widget().get_toplevel()
        res = QuestionDialog3(
            _("Edit Image Exif Metadata"),
            _("WARNING: You are about to convert this image into a "
              ".jpeg image.  Are you sure that you want to do this?"),
            _("Convert and Delete"), _("Convert"),
            parent=parent).run()
        if res == -1:
            return
        if res:
            self.__convert_delete()
        else:
            self.__convert_only()
        self.update()
        return 
开发者ID:gramps-project,项目名称:addons-source,代码行数:22,代码来源:editexifmetadata.py

示例13: addButtonToToolbar

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Image [as 别名]
def addButtonToToolbar(self, plugin_api):
        if not self.checkTomboyPresent():
            return
        tb_Taskbutton_image = Gtk.Image()
        tb_Taskbutton_image_path = self.tomboy_icon_path
        tb_Taskbutton_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
            tb_Taskbutton_image_path, 16, 16)
        tb_Taskbutton_image.set_from_pixbuf(tb_Taskbutton_pixbuf)
        self.tb_Taskbutton = Gtk.ToolButton(tb_Taskbutton_image)
        self.tb_Taskbutton.set_label(_("Add Tomboy note"))
        self.tb_Taskbutton.connect('clicked', self.onTbTaskButton,
                                   self.plugin_api)
        self.tb_Taskbutton.show_all()
        self.plugin_api.add_toolbar_item(self.tb_Taskbutton)

    # Converts all the textual tokens in tomboy note widgets 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:18,代码来源:tomboy.py

示例14: set_icon

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Image [as 别名]
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) 
开发者ID:bilelmoussaoui,项目名称:nautilus-folder-icons,代码行数:18,代码来源:utils.py

示例15: _add_scale

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Image [as 别名]
def _add_scale(self, sink):
        # scale
        scale = Gtk.Scale().new(Gtk.Orientation.VERTICAL)
        scale.set_draw_value(False)
        scale.set_value_pos(Gtk.PositionType.BOTTOM)
        scale.set_range(PA_VOLUME_MUTED, PA_VOLUME_NORM)
        scale.set_inverted(True)
        scale.set_size_request(24, 128)
        scale.set_tooltip_text(sink.name)
        self._set_increments_on_scale(scale)

        # icon
        icon = Gtk.Image()
        icon.set_tooltip_text(sink.name)
        icon.set_from_icon_name(sink.icon_name, Gtk.IconSize.SMALL_TOOLBAR)

        return scale, icon 
开发者ID:buzz,项目名称:volctl,代码行数:19,代码来源:slider_win.py


注:本文中的gi.repository.Gtk.Image方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。