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


Python Pixbuf.new_from_stream方法代码示例

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


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

示例1: open

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_stream [as 别名]
    def open(self, *args):
        search = Search()
        links = search.search(self.entry.get_text())

        self.grid_helper.refresh()

        for link in links:
            url = link.img
            text = Gtk.Label(link.title)

            #text.set_size_request(50, 50)
            text.set_line_wrap(True)
            response = urllib2.urlopen(url)
            input_stream = Gio.MemoryInputStream.new_from_data(response.read(), None)
            pixbuf = Pixbuf.new_from_stream(input_stream, None)
            image = Gtk.Image()
            image.set_from_pixbuf(pixbuf)

            box = Gtk.VBox()
            box.pack_start(image, False, False, 0)
            box.pack_start(text, False, False, 0)
            event_box = Gtk.EventBox()
            event_box.add(box)

            event_box.connect("button-press-event", self.serie_clicked, link)

            self.grid_helper.add_widget(event_box)

        self.grid_helper.load_widgets()
        self.window.show_all()
开发者ID:Faianca,项目名称:Anime-Tv-shows-Scrapper,代码行数:32,代码来源:guitest3.py

示例2: set_picture

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_stream [as 别名]
 def set_picture(self, url):
     response = urllib2.urlopen(url) 
     input_stream = Gio.MemoryInputStream.new_from_data(response.read(), None) 
     pixbuf = Pixbuf.new_from_stream(input_stream, None) 
     image = Gtk.Image() 
     image.set_from_pixbuf(pixbuf)
     image.set_pixel_size(50)
     #image = Gtk.Image.new_from_file(image);
     #self.chatbox.draw
     self.grid.attach(image, 3, 1,1,1);
开发者ID:johan-bjareholt,项目名称:tiny-gtk-chat,代码行数:12,代码来源:client.py

示例3: __init__

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_stream [as 别名]
    def __init__(self, query):
        self.query = query

        image_url = \
            "http://gatherer.wizards.com/Handlers/Image.ashx?type=card&name=%s" % \
            self.query
        self.split = False
        # rotate split cards
        if '//' in self.query:
            self.split = True
            image_url= '%s&options=rotate90' % image_url
        image_raw = get(image_url).content
        input_stream = Gio.MemoryInputStream.new_from_data(image_raw, None)
        self.pixbuf = Pixbuf.new_from_stream(input_stream, None)

        # handle split cards
        html_url = \
            "http://gatherer.wizards.com/Pages/Card/Details.aspx?name=%s" % \
            re.sub("(.*) // (.*)", r"[\1]+[//]+[\2]", self.query)
        html = get(html_url).text
        self.dom = parse(html, treebuilder='etree', namespaceHTMLElements=False)
开发者ID:kaikubasta,项目名称:mtg-deck-editor,代码行数:23,代码来源:__main__.py

示例4: pixbuf_from_url

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_stream [as 别名]
def pixbuf_from_url(url):
    image_data = urllib.request.urlopen(url)
    input_stream = Gio.MemoryInputStream.new_from_data(image_data.read(), None)
    pixbuf = Pixbuf.new_from_stream(input_stream, None)
    return pixbuf
开发者ID:atticae,项目名称:RandomDilbert,代码行数:7,代码来源:ComicUtils.py

示例5: __init__

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_stream [as 别名]
    def __init__(self, parent, title, info, extra_info):
        """Create the dialog."""

        # Create the dialog.
        Gtk.Dialog.__init__(self, title, parent, Gtk.DialogFlags.MODAL)
        self.set_default_size(500, -1)
        self.add_button("View Profile", DialogResponse.VIEW_PROFILE)

        # Create the avatar image.
        dlg_box = self.get_content_area()
        avatar_img = Gtk.Image()
        try:
            response = urllib2.urlopen(info["avatar_url"])
            input_stream = Gio.MemoryInputStream.new_from_data(response.read(), None)
            pixbuf = Pixbuf.new_from_stream(input_stream, None)
            avatar_img.set_from_pixbuf(pixbuf)
        except urllib2.URLError:
            pass
        avatar_img.props.halign = Gtk.Align.CENTER
        avatar_img.set_hexpand(True)
        dlg_box.add(avatar_img)

        # Create the labels.
        name_lbl = Gtk.Label()
        name_lbl.set_markup("<span size=\"xx-large\"><a href=\"https://pastebin.com/u/" + info["name"] + "\">" + info["name"] + "</a></span>")
        name_lbl.set_margin_top(10)
        dlg_box.add(name_lbl)
        account_lbl = Gtk.Label()
        account_lbl.set_markup("<span size=\"medium\">" + ACCOUNT_TYPE[info["account_type"]] + " account</span>")
        account_lbl.set_margin_top(5)
        dlg_box.add(account_lbl)
        if len(extra_info) > 0:
            join_lbl = Gtk.Label()
            join_lbl.set_markup("<span size=\"medium\">Joined " + " ".join(extra_info[2][1].split(" ")[0:5]) + "</span>")
            join_lbl.set_margin_top(5)
            dlg_box.add(join_lbl)
        email_lbl = Gtk.Label()
        email_lbl.set_markup("<span size=\"medium\"><a href=\"mailto:" + info["email"] + "\">" + info["email"] + "</a></span>")
        email_lbl.set_margin_top(10)
        dlg_box.add(email_lbl)
        website_lbl = Gtk.Label()
        if info["website"]:
            website_lbl.set_markup("<span size=\"medium\"><a href=\"" + info["website"] + "\">" + info["website"] + "</a></span>")
        else:
            website_lbl.set_markup("<span size=\"medium\">No website provided</span>")
        website_lbl.set_margin_top(5)
        dlg_box.add(website_lbl)
        location_lbl = Gtk.Label()
        if info["location"]:
            location_lbl.set_markup("<span size=\"medium\">Located at " + info["location"] + "</span>")
        else:
            location_lbl.set_markup("<span size=\"medium\">No location provided</span>")
        location_lbl.set_margin_top(5)
        dlg_box.add(location_lbl)
        if len(extra_info) > 0:
            profile_view_lbl = Gtk.Label()
            profile_view_lbl.set_markup("<span size=\"medium\">" + extra_info[0][1] + " profile views</span>")
            profile_view_lbl.set_margin_top(10)
            dlg_box.add(profile_view_lbl)
            paste_view_lbl = Gtk.Label()
            paste_view_lbl.set_markup("<span size=\"medium\">" + extra_info[1][1] + " total paste views</span>")
            paste_view_lbl.set_margin_top(5)
            dlg_box.add(paste_view_lbl)

        # Show the dialog.
        self.show_all()
开发者ID:achesak,项目名称:pastebingtk,代码行数:68,代码来源:user_details_dialog.py


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