本文整理汇总了Python中gi.repository.GdkPixbuf.Pixbuf类的典型用法代码示例。如果您正苦于以下问题:Python Pixbuf类的具体用法?Python Pixbuf怎么用?Python Pixbuf使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pixbuf类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setImage
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)
示例2: get_pixbuf_for_game
def get_pixbuf_for_game(game_slug, icon_type="banner", is_installed=True):
if icon_type in ("banner", "banner_small"):
size = BANNER_SIZE if icon_type == "banner" else BANNER_SMALL_SIZE
default_icon = DEFAULT_BANNER
icon_path = os.path.join(settings.BANNER_PATH,
"%s.jpg" % game_slug)
elif icon_type == "icon":
size = ICON_SIZE
default_icon = DEFAULT_ICON
icon_path = os.path.join(settings.ICON_PATH,
"lutris_%s.png" % game_slug)
if not os.path.exists(icon_path):
icon_path = default_icon
try:
pixbuf = Pixbuf.new_from_file_at_size(icon_path, size[0], size[1])
except GLib.GError:
pixbuf = Pixbuf.new_from_file_at_size(default_icon, size[0], size[1])
if not is_installed:
transparent_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
UNAVAILABLE_GAME_OVERLAY, size[0], size[1]
)
transparent_pixbuf = transparent_pixbuf.scale_simple(
size[0], size[1], GdkPixbuf.InterpType.NEAREST
)
pixbuf.composite(transparent_pixbuf, 0, 0, size[0], size[1],
0, 0, 1, 1, GdkPixbuf.InterpType.NEAREST, 100)
return transparent_pixbuf
return pixbuf
示例3: show_app
def show_app(builder,iconview,treepath):
global stage
global SubCategoryList
global ProgramList
#Is AlreadyOpen Bool
global ProgramViewOpen
#Which Subcategory
global ProgramName
#ShowDialog if not already open
if ProgramViewOpen != True:
AppWin = builder.get_object('ApplicationDialog_Install')
ProgramName = ProgramList[treepath.get_indices()[0]]
Data = db.read_attributes(ProgramName)
#Set Name, Short and Long description, Symbol, Screenshot
Title = builder.get_object('AD_App_Label')
Title.set_text(Data[1])
#Short Description
ShortDescription = builder.get_object('AD_ShortDescription')
ShortDescription.set_text(Data[2])
#Long Description
LongDescription = builder.get_object('AD_LongDescription')
LongDescription.set_text(Data[3])
#Symbol
Symbol = builder.get_object('AD_Symbol')
try:
SymbolPixbuf = Pixbuf.new_from_file_at_size(conf.get_entry('DB','dblocation') + Data[8],64 ,64)
Symbol.set_from_pixbuf(SymbolPixbuf)
except:
Symbol.set_from_icon_name('error-dialog',10)
print('Failed To Load Symbol')
#Screenshot
Screenshot = builder.get_object('AD_Screenshot')
try:
ScreenshotPixbuf = Pixbuf.new_from_file_at_size(conf.get_entry('DB','dblocation') + Data[4],512 ,512)
Screenshot.set_from_pixbuf(ScreenshotPixbuf)
except:
Screenshot.set_from_icon_name('error-dialog',10)
print('Failed to load Screenshot')
AppWin.show_all()
ProgramViewOpen = True
else:
ErrorWinAppView = builder.get_object('AD_AVIsOpen')
ErrorWinAppView.show_all()
示例4: popular_controles
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'])
示例5: getIcon
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
示例6: load_map
def load_map(map_nr):
subdir = 'localized/en/images/Funkenschlag/'
path = join(base_dir, subdir)
fns = ('usa.jpg', 'deut.jpg',
'frankreich.jpg', 'italien.jpg', 'bw.jpg')
pix = Pixbuf.new_from_file(join(path, fns[map_nr]))
return pix
示例7: get_pixbuf_for_game
def get_pixbuf_for_game(game_slug, size=ICON_SIZE, is_installed=True):
width = size[0]
height = size[1]
icon_path = os.path.join(settings.DATA_DIR, "banners", "%s.jpg" % game_slug)
if not os.path.exists(icon_path):
icon_path = MISSING_ICON
try:
pixbuf = Pixbuf.new_from_file_at_size(icon_path, width, height)
except GLib.GError:
pixbuf = Pixbuf.new_from_file_at_size(MISSING_ICON, width, height)
if not is_installed:
transparent_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(UNAVAILABLE_GAME_OVERLAY, width, height)
transparent_pixbuf = transparent_pixbuf.scale_simple(width, height, GdkPixbuf.InterpType.NEAREST)
pixbuf.composite(transparent_pixbuf, 0, 0, width, height, 0, 0, 1, 1, GdkPixbuf.InterpType.NEAREST, 100)
return transparent_pixbuf
return pixbuf
示例8: load_icons
def load_icons():
"""
Load pympress icons from the pixmaps directory (usually
:file:`/usr/share/pixmaps` or something similar).
:return: loaded icons
:rtype: list of :class:`Gtk.gdk.Pixbuf`
"""
# If pkg_resources fails, load from directory
icon_path = "/usr/share/pixmaps/"
icon_names = glob.glob(icon_path + "pympress*")
if not icon_names:
icon_path = "share/pixmaps/"
icon_names = glob.glob(icon_path + "pympress*")
icons = []
for icon_name in icon_names:
if os.path.splitext(icon_name)[1].lower() != ".png":
continue
# If pkg_resources fails, load from directory
try:
icon_pixbuf = Pixbuf.new_from_file(icon_name)
icons.append(icon_pixbuf)
except Exception as e:
print(e)
return icons
示例9: main
def main():
global browser
global window
frontend = frontend_fill()
window = gtk.Window()
window.connect('destroy', gtk.main_quit)
window.set_title("Linux Lite Control Center")
window.set_icon(Pixbuf.new_from_file("{0}/litecc.png".format(app_dir)))
window.set_size_request(880, 660)
# Valtam do we need to resize window?
window.set_resizable(False)
window.set_position(gtk.WindowPosition.CENTER),
browser = webkit.WebView()
swindow = gtk.ScrolledWindow()
window.add(swindow)
swindow.add(browser)
window.show_all()
browser.connect("navigation-requested", functions)
browser.load_html_string(frontend, "file://{0}/frontend/".format(app_dir))
# no right click menu
settings = browser.get_settings()
settings.set_property('enable-default-context-menu', False)
browser.set_settings(settings)
# Engage
gtk.main()
示例10: get_scaled_image
def get_scaled_image(path,image_width):
"""
Get a image scaled according to specified image_width.
A new GDK Pixbuf is obtained for the given image path.
New height of image is calculated according to specified image width.
Pixbuf is scaled simply with parameters :
destination image_width
destination image_height
the interpolation of the transformation(GDK Interp_Type)
@param : path (Image location)
@param : image_width
@return : scaled_pix
"""
default_image_width = image_width
try:
pixbuf = Pixbuf.new_from_file(path)
except Exception as msg:
return get_scaled_image(p2psp_logo_path,image_width)
pix_w = pixbuf.get_width()
pix_h = pixbuf.get_height()
new_h = (pix_h * default_image_width) / pix_w
scaled_pix = pixbuf.scale_simple(default_image_width, new_h, 1)
return scaled_pix
示例11: on_about
def on_about(self, btn):
""""""
about = AboutDialog()
about.set_program_name(conf.PRG_NAME)
about.set_version("v " + conf.PRG_VERS)
about.set_copyright(conf.PRG_ABOUT_COPYRIGHT)
about.set_comments(conf.PRG_ABOUT_COMMENTS)
about.set_website(conf.PRG_WEBSITE)
about.set_website_label(conf.PRG_WEBSITE)
about.set_license(Io.get_data(conf.PRG_LICENSE_PATH))
pixbuf = Pixbuf.new_from_file_at_size(conf.PRG_LOGO_PATH, conf.PRG_ABOUT_LOGO_SIZE, conf.PRG_ABOUT_LOGO_SIZE)
about.set_logo(pixbuf)
pixbuf = Pixbuf.new_from_file_at_size(conf.PRG_LOGO_PATH, conf.PRG_ABOUT_LOGO_SIZE, conf.PRG_ABOUT_LOGO_SIZE)
about.set_icon(pixbuf)
about.run()
about.destroy()
示例12: thread_scanning
def thread_scanning(self,flag,ip_range,start,end):
for i in range(int(start),int(end)):
ip=ip_range[0]+"."+ip_range[1]+"."+ip_range[2]+"."+str(i)
proc1 = subprocess.Popen("arping -c 1 "+ip+" | head -n 2 | tail -n 1 | awk '{print $5,$6}'" , shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
proc = subprocess.Popen("smbclient -NL "+ip, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
str1=["",""]
for line in proc1.stdout:
str1 = line.replace("[","").replace("]","").split(" ")
if str1[0]=="broadcast(s))":
proc2 = subprocess.Popen("ifconfig | head -n 1 | awk '{print $5}'", shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
for line2 in proc2.stdout:
str1[0]=line2.upper()
str1[1]="0ms"
for line in proc.stderr:
if('Domain' in line):
hostname =line[line.find("[")+1:line.find("]")]
if hostname=="WORKGROUP":
proc_nmblookup = subprocess.Popen("nmblookup -A "+ip+" | head -n 2 | tail -n 1 | awk '{print $1 }'", shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
for line in proc_nmblookup.stdout:
hostname=line.replace("\n","").upper()
pixbuf = Pixbuf.new_from_file("/usr/share/shareviewer/media/computer.png")
self.devices+=1
par = self.model.append(None ,[pixbuf,ip.strip(),hostname,str1[0].replace("\n",""),str1[1].replace("ms"," ms").replace("\n","")])
break;
for line1 in proc.stdout:
if line1.find("Disk")!=-1:
share=line1.strip().replace("Disk","").replace("Printer Drivers","").replace("Remote Admin","").replace("Default share","").replace("\n","")
pixbuf = Gtk.IconTheme.get_default().load_icon("gtk-directory", 16, 0)
child = self.model.append(par,[pixbuf,share,"","",""])
self.count+=1
示例13: _cb_open
def _cb_open(self, button):
dlg_open = Gtk.FileChooserDialog(
"Open Image",
button.get_toplevel(),
Gtk.FileChooserAction.OPEN,
(
Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK
))
dlg_open.set_default_response(1)
dlg_open.set_select_multiple(True)
filef = Gtk.FileFilter()
filef.add_pixbuf_formats()
dlg_open.set_filter(filef)
if dlg_open.run() == Gtk.ResponseType.OK:
for f in dlg_open.get_filenames():
img = Pixbuf.new_from_file_at_size(f, 128, 128)
name = f.split('/')[-1]
if len(name) > 18:
name = name[:8] + '...' + name[-8:]
self.queue_ls.append([img, name, f])
dlg_open.destroy()
示例14: run
def run(self):
builder.get_object('spinner_overlay').show()
url = "/".join([self.api.API_BASE,"users",self.user,"wallpapers"])
data = json.loads(urllib2.urlopen(url).read())
done = 0
currWallpaperNr = 0;
while not done:
for wallpaper in data['response']:
# print wallpaper
currWallpaperNr = currWallpaperNr + 1;
if currWallpaperNr == 1:
txt = "Wallpaper"
else:
txt = "Wallpapers"
self.headerBar.set_subtitle(str(currWallpaperNr) + " " + txt)
if not os.path.isfile(self.CACHE_DIR + str(wallpaper['id'])):
file = open(self.CACHE_DIR + str(wallpaper['id']),'w')
file.write(urllib2.urlopen(wallpaper['image']['thumb']['url']).read())
file.close()
pxbf = Pixbuf.new_from_file(self.CACHE_DIR + str(wallpaper['id']))
self.listStore.append([
str(wallpaper["id"]),
wallpaper["image"]["url"],
pxbf])
if not data['pagination']['next']:
data['pagination']['next'] = data['pagination']['current']+1
data = json.loads(urllib2.urlopen(url + "?page=" + str(data['pagination']['next'])).read())
#print "> URL: %s\n> PAGE: %s \n ===========\n" % (url + "?page=" + str(data['pagination']['next']),str(data['pagination']['current'])), data['response']
if len(data['response']) == 0:
done = 1
builder.get_object('spinner_overlay').hide()
示例15: load_plants
def load_plants():
subdir = 'funkenschlagPics/kw'
path = join(base_dir, subdir)
fns = (
'funkkart_03a.jpg', 'funkkart_04a.jpg',
'funkkart_05a.jpg', 'funkkart_06a.jpg',
'funkkart_07a.jpg', 'funkkart_08a.jpg',
'funkkart_09a.jpg', 'funkkart_10a.jpg',
'funkkart_11a.jpg', 'funkkart_12a.jpg',
'funkkart_13a.jpg', 'funkkart_14a.jpg',
'funkkart_15a.jpg', 'funkkart_16a.jpg',
'funkkart_17a.jpg', 'funkkart_18a.jpg',
'funkkart_19a.jpg', 'funkkart_20a.jpg',
'funkkart_21a.jpg', 'funkkart_22a.jpg',
'funkkart_23a.jpg', 'funkkart_24a.jpg',
'funkkart_25a.jpg', 'funkkart_26a.jpg',
'funkkart_27a.jpg', 'funkkart_28a.jpg',
'funkkart_29a.jpg', 'funkkart_30a.jpg',
'funkkart_31a.jpg', 'funkkart_32a.jpg',
'funkkart_33a.jpg', 'funkkart_34a.jpg',
'funkkart_35a.jpg', 'funkkart_36a.jpg',
'funkkart_37a.jpg', 'funkkart_38a.jpg',
'funkkart_39a.jpg', 'funkkart_40a.jpg',
'funkkart_42a.jpg', 'funkkart_44a.jpg',
'funkkart_46a.jpg', 'funkkart_50a.jpg',
'stufe_3_a.jpg', 'blass.png', 'blocker.jpg'
)
out = []
for fn in map(lambda x:join(path, x), fns):
pix = Pixbuf.new_from_file(fn)
#pix = pix.scale_simple(48, 48, InterpType.HYPER)
out.append(pix)
return tuple(out)