本文整理汇总了Python中gi.repository.GdkPixbuf.Pixbuf.new_from_file_at_scale方法的典型用法代码示例。如果您正苦于以下问题:Python Pixbuf.new_from_file_at_scale方法的具体用法?Python Pixbuf.new_from_file_at_scale怎么用?Python Pixbuf.new_from_file_at_scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.GdkPixbuf.Pixbuf
的用法示例。
在下文中一共展示了Pixbuf.new_from_file_at_scale方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: popular_controles
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_scale [as 别名]
def popular_controles(self):
pb = Pixbuf.new_from_file_at_scale("imagem_dia.jpg", width=50, height=50,preserve_aspect_ratio=False)
self.imagem.set_from_pixbuf(pb)
self.cidade.set_text(self.conteudo['cidade'])
self.descricao.set_text(self.conteudo['agora']['descricao'])
self.temperatura.set_text('Temperatura: ' + self.conteudo['agora']['temperatura'] + ' graus')
self.umidade.set_text('Umidade: ' + self.conteudo['agora']['umidade'])
for num, value in enumerate(self.conteudo['previsoes']):
if num == 1:
self.previsao_dia1.set_text(value['data'])
self.descricao_dia1.set_text(value['descricao'])
img_url = value['imagem']
response = urllib.request.urlopen(img_url)
with open("imagem_dia1.jpg", 'wb') as f:
f.write(response.read())
pb = Pixbuf.new_from_file_at_scale("imagem_dia1.jpg", width=50, height=50,preserve_aspect_ratio=False)
self.imagem_dia1.set_from_pixbuf(pb)
self.max_min_dia1.set_text("Max: " + value['temperatura_max'] + " Min: " + value['temperatura_min'])
elif num == 2:
self.previsao_dia2.set_text(value['data'])
self.descricao_dia2.set_text(value['descricao'])
img_url = value['imagem']
response = urllib.request.urlopen(img_url)
with open("imagem_dia2.jpg", 'wb') as f:
f.write(response.read())
pb = Pixbuf.new_from_file_at_scale("imagem_dia2.jpg", width=50, height=50,preserve_aspect_ratio=False)
self.imagem_dia2.set_from_pixbuf(pb)
self.max_min_dia2.set_text("Max: " + value['temperatura_max'] + " Min: " + value['temperatura_min'])
elif num == 3:
self.previsao_dia3.set_text(value['data'])
self.descricao_dia3.set_text(value['descricao'])
img_url = value['imagem']
response = urllib.request.urlopen(img_url)
with open("imagem_dia3.jpg", 'wb') as f:
f.write(response.read())
pb = Pixbuf.new_from_file_at_scale("imagem_dia3.jpg", width=50, height=50,preserve_aspect_ratio=False)
self.imagem_dia3.set_from_pixbuf(pb)
self.max_min_dia3.set_text("Max: " + value['temperatura_max'] + " Min: " + value['temperatura_min'])
elif num == 4:
self.previsao_dia4.set_text(value['data'])
self.descricao_dia4.set_text(value['descricao'])
img_url = value['imagem']
response = urllib.request.urlopen(img_url)
with open("imagem_dia4.jpg", 'wb') as f:
f.write(response.read())
pb = Pixbuf.new_from_file_at_scale("imagem_dia4.jpg", width=50, height=50,preserve_aspect_ratio=False)
self.imagem_dia4.set_from_pixbuf(pb)
self.max_min_dia4.set_text("Max: " + value['temperatura_max'] + " Min: " + value['temperatura_min'])
示例2: setImage
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_scale [as 别名]
def setImage(self, fileName):
if not self.settingsManager.resizeImage:
mpixbuf = Pixbuf.new_from_file(fileName)
else:
mpixbuf = Pixbuf.new_from_file_at_scale(fileName, self.iCurWidth, self.iCurHeight, True)
self.currentFile = fileName
Gdk.threads_add_idle(GLib.PRIORITY_DEFAULT_IDLE, self.GtkSetImage, mpixbuf)
示例3: resizeImage
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_scale [as 别名]
def resizeImage(self, widget, rectangle):
if self.settingsManager.resizeImage and self.currentBooru.getCurrentFile():
iWidth = rectangle.width - 15
iHeight = rectangle.height - 15
mpixbuf = Pixbuf.new_from_file_at_scale(self.currentBooru.getCurrentFile(), iWidth, iHeight, True)
self.iCurHeight = iHeight
self.iCurWidth = iWidth
Gdk.threads_add_idle(GLib.PRIORITY_DEFAULT_IDLE, self.GtkSetImage, mpixbuf)
示例4: getIcon
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_scale [as 别名]
def getIcon(name, mime = None, size = None):
d = os.path.join(r, 'icons')
if mime == None:
mime = 'png'
n = ".".join([name, mime])
p = os.path.join(d, n)
if size == None:
i = Pixbuf.new_from_file(p)
else:
i = Pixbuf.new_from_file_at_scale(p, size, size, False)
return i
示例5: split
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_scale [as 别名]
bin_path = split(argv[0])[0]
icons_path = "icons/formiko.svg"
share_path = join("share/formiko", icons_path)
while (bin_path != '/'):
# this work to /opt /usr /usr/local prefixes
if exists(join(bin_path, share_path)):
return join(bin_path, share_path)
if exists(join(bin_path, icons_path)):
return join(bin_path, icons_path)
bin_path = split(bin_path)[0]
ICON_PATH = get_path()
if ICON_PATH:
icon_16 = Pixbuf.new_from_file_at_scale(ICON_PATH, 16, 16, True)
icon_32 = Pixbuf.new_from_file_at_scale(ICON_PATH, 32, 32, True)
icon_48 = Pixbuf.new_from_file_at_scale(ICON_PATH, 48, 48, True)
icon_64 = Pixbuf.new_from_file_at_scale(ICON_PATH, 64, 64, True)
icon_128 = Pixbuf.new_from_file_at_scale(ICON_PATH, 128, 128, True)
else:
from gi.repository.Gtk import IconTheme
from gi.repository.GLib import log_default_handler, LogLevelFlags
log_default_handler("Application", LogLevelFlags.LEVEL_ERROR,
"Formiko icon not found", 0)
icon_theme = IconTheme.get_default()
icon_16 = icon_theme.load_icon("text-editor-symbolic", 16, 0)
icon_32 = icon_theme.load_icon("text-editor-symbolic", 32, 0)
icon_48 = icon_theme.load_icon("text-editor-symbolic", 48, 0)
icon_64 = icon_theme.load_icon("text-editor-symbolic", 64, 0)