本文整理汇总了Python中gi.repository.GdkPixbuf.Pixbuf.new_from_file方法的典型用法代码示例。如果您正苦于以下问题:Python Pixbuf.new_from_file方法的具体用法?Python Pixbuf.new_from_file怎么用?Python Pixbuf.new_from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.GdkPixbuf.Pixbuf
的用法示例。
在下文中一共展示了Pixbuf.new_from_file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_plants
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file [as 别名]
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)
示例2: setImage
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file [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: load_map
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file [as 别名]
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
示例4: __init__
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file [as 别名]
def __init__(self, winParent, show = False):
# Retrieve the translators list
translators = []
for line in readlines(FILE_TRANSLATORS, False):
if ':' in line:
line = line.split(':', 1)[1]
line = line.replace('(at)', '@').strip()
if line not in translators:
translators.append(line)
# Load the user interface
builder = Gtk.Builder()
builder.add_from_file(FILE_UI_ABOUT)
# Obtain widget references
self.dialog = builder.get_object("dialogAbout")
# Set various properties
self.dialog.set_program_name(APP_NAME)
self.dialog.set_version('Version %s' % APP_VERSION)
self.dialog.set_comments(APP_DESCRIPTION)
self.dialog.set_website(APP_URL)
self.dialog.set_copyright(APP_COPYRIGHT)
self.dialog.set_authors(['%s <%s>' % (APP_AUTHOR, APP_AUTHOR_EMAIL)])
#self.dialog.set_license_type(Gtk.License.GPL_2_0)
self.dialog.set_license('\n'.join(readlines(FILE_LICENSE, True)))
self.dialog.set_translator_credits('\n'.join(translators))
# Retrieve the external resources links
for line in readlines(FILE_RESOURCES, False):
resource_type, resource_url = line.split(':', 1)
self.dialog.add_credit_section(resource_type, (resource_url,))
icon_logo = Pixbuf.new_from_file(FILE_ICON)
self.dialog.set_logo(icon_logo)
self.dialog.set_transient_for(winParent)
# Optionally show the dialog
if show:
self.show()
示例5: best_zoom
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file [as 别名]
def best_zoom(self,widget):
self.zoom_actual = 2
rect = self.view_port_img.get_allocation()
pixbuf = Pixbuf.new_from_file(self.v_item_actual)
ancho_pixbuf = pixbuf.get_width()
alto_pixbuf = pixbuf.get_height()
if ancho_pixbuf > alto_pixbuf:
ancho = int(rect.width - 4)
relacion = (alto_pixbuf*100)/ancho_pixbuf
alto = int(ancho * relacion/100)
else:
alto = int(rect.height - 4)
relacion = (ancho_pixbuf*100 - 4)/alto_pixbuf
ancho = int(alto * (relacion/100))
if alto > rect.height:
alto = int(rect.height - 4)
relacion = (ancho_pixbuf*100 - 4)/alto_pixbuf
ancho = int(alto * (relacion/100))
elif ancho > rect.width:
ancho = int(rect.width - 4)
relacion = (alto_pixbuf*100)/ancho_pixbuf
alto = int(ancho * relacion/100)
prev_pixbuf = pixbuf.scale_simple(ancho, alto, v_inter)
self.image.set_from_pixbuf(prev_pixbuf)
self.image.show()
示例6: set_cover_from_tags
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file [as 别名]
def set_cover_from_tags(bean):
try:
ext = get_file_extension(bean.path)
if ext == ".mp3":
data = _get_pic_from_mp3(ID3(bean.path))
elif ext == ".flac":
data = _get_pic_from_flac(FLAC(bean.path))
else:
return None
if data:
filename = os.path.join(COVERS_DIR, str(crc32(bean.path)) + '.jpg')
fd = NamedTemporaryFile()
fd.write(data.data)
pixbuf = Pixbuf.new_from_file(fd.name)
pixbuf.savev(filename, "jpeg", ["quality"], ["90"])
fd.close()
bean.image = filename
basename = os.path.splitext(os.path.basename(filename))[0]
cache_dict = FCache().covers
if basename in cache_dict:
cache_dict[basename].append(bean.text)
else:
cache_dict[basename] = [bean.text]
return filename
except Exception, e:
pass
示例7: dec_zoom
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file [as 别名]
def dec_zoom(self,widget):
if self.zoom_actual <= 6:
self.zoom_actual = self.zoom_actual + 1
if self.zoom_actual == 1:
v_zoom = 1.0
elif self.zoom_actual == 2:
v_zoom = 1.5
elif self.zoom_actual == 3:
v_zoom = 2.0
elif self.zoom_actual == 4:
v_zoom = 2.5
elif self.zoom_actual == 5:
v_zoom = 3.0
elif self.zoom_actual == 6:
v_zoom = 3.5
elif self.zoom_actual == 7:
v_zoom = 4.0
pixbuf = Pixbuf.new_from_file(self.v_item_actual)
ancho_pixbuf = pixbuf.get_width()
alto_pixbuf = pixbuf.get_height()
ancho = ancho_pixbuf / v_zoom
alto = alto_pixbuf / v_zoom
prev_pixbuf = pixbuf.scale_simple(ancho, alto, v_inter)
self.image.set_from_pixbuf(prev_pixbuf)
self.image.show()
示例8: load_icons
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file [as 别名]
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: get_scaled_image
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file [as 别名]
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
示例10: main
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file [as 别名]
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()
示例11: main
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file [as 别名]
def main():
global browser
global window
frontend = frontend_fill()
window = gtk.Window()
window.connect('destroy', gtk.main_quit)
window.set_title(appname)
window.set_icon(Pixbuf.new_from_file(app_icon))
rootsize = tkinter.Tk()
if rootsize.winfo_screenheight() > 700:
window.set_resizable(False)
window.set_size_request(800, 550)
else:
window.set_resizable(True)
window.set_size_request(600, 500)
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))
settings = browser.get_settings()
settings.set_property('enable-default-context-menu', False)
browser.set_settings(settings)
gtk.main()
示例12: thread_scanning
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file [as 别名]
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: run
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file [as 别名]
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()
示例14: functions
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file [as 别名]
def functions(view, frame, req, data=None):
uri = req.get_uri()
lllink, path = uri.split('://', 1)
path = path.replace("%20", " ")
if lllink == "file":
return False
elif lllink == "about":
about = gtk.AboutDialog()
about.set_program_name(appname)
about.set_version(appver)
about.set_copyright('Copyright Johnathan Jenkins 2016')
about.set_wrap_license
about.set_license(
'''This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. ''')
about.set_authors([
"Johnathan 'ShaggyTwoDope'" +
" Jenkins\n<[email protected]>\n",
"Jerry Bezencon\n<[email protected]>\n",
"Milos Pavlovic\n<[email protected]>\n",
"Brian 'DarthLukan' Tomlinson\n<[email protected]>\n",
"Josh Erickson\n<[email protected]>"
])
about.set_comments("Control it all.")
about.set_website("https://github.com/nixheads/nixcontrolcenter")
about.set_logo(Pixbuf.new_from_file(app_icon))
about.set_transient_for(window)
about.run()
about.destroy()
elif lllink == "admin":
subprocess.Popen(path, shell=True, executable='/bin/bash')
elif lllink == "script":
execute("{0}/scripts/{1}".format(app_dir, path))
elif lllink == "help":
webbrowser.open('file:///usr/share/doc/litemanual/index.html')
elif lllink == "screenshot":
os.system("/bin/bash -c 'scrot -u $HOME/nixccshot.png'")
subprocess.Popen(['/bin/bash', '-c',
'/usr/share/nixcc/scripts/screenshot'])
elif lllink == "report":
subprocess.Popen(['/bin/bash', '-c', 'gksudo /usr/scripts/systemreport'
])
elif lllink == "update":
subprocess.Popen(['gpk-update-viewer'
])
elif lllink == "refresh":
reload()
return True
示例15: orig_zoom
# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file [as 别名]
def orig_zoom(self,widget):
self.zoom_actual = 1
pixbuf = Pixbuf.new_from_file(self.v_item_actual)
ancho_pixbuf = pixbuf.get_width()
alto_pixbuf = pixbuf.get_height()
prev_pixbuf = pixbuf.scale_simple(ancho_pixbuf, alto_pixbuf, v_inter)
self.image.set_from_pixbuf(prev_pixbuf)
self.image.show()