本文整理汇总了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()
示例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);
示例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)
示例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
示例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()