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


Python Pixbuf.new_from_file_at_size方法代码示例

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


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

示例1: get_pixbuf_for_game

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_size [as 别名]
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
开发者ID:nsteenv,项目名称:lutris,代码行数:31,代码来源:widgets.py

示例2: show_app

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_size [as 别名]
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()
开发者ID:SiebenCorgie,项目名称:BELL_CustomPackageFramework,代码行数:59,代码来源:Install_UI.py

示例3: get_pixbuf_for_game

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_size [as 别名]
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
开发者ID:Cybolic,项目名称:lutris,代码行数:18,代码来源:widgets.py

示例4: on_about

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_size [as 别名]
 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()
开发者ID:necrose99,项目名称:Kirmah,代码行数:18,代码来源:ui.py

示例5: go_Sub

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_size [as 别名]
def go_Sub(builder,iconview,treepath,SelectedMain):
	
	global stage
	global SubCategoryList
	global ProgramList
	global liststore
	
	global SelectedSubCat
	
	SelectedSubCat = SubCategoryList[treepath.get_indices()[0]]
	
	#Clear Icons
	liststore = iconview.get_model()
	liststore.clear()
	
	ProgramList = db.db_read(SelectedSubCat)

	for i in ProgramList:
		pixbuf = Pixbuf.new_from_file_at_size(str(conf.get_entry('DB','dblocation') + db.read_attributes(i)[8]),64,64)
		liststore.append([pixbuf, i])
	iconview.show_all()


	stage = 'Prog'

	feedback.status_push(conf.get_entry("Status","menuprogram"))
开发者ID:SiebenCorgie,项目名称:BELL_CustomPackageFramework,代码行数:28,代码来源:Install_UI.py

示例6: _cb_open

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_size [as 别名]
 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()
开发者ID:vaurelios,项目名称:pyis-uploader,代码行数:28,代码来源:gtk.py

示例7: get_pixbuf_for_game

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_size [as 别名]
def get_pixbuf_for_game(game_slug, icon_type, is_installed):
    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):
        pixbuf = get_default_icon(default_icon, size)
    else:
        try:
            pixbuf = Pixbuf.new_from_file_at_size(icon_path, size[0], size[1])
        except GLib.GError:
            pixbuf = get_default_icon(default_icon, size)
    if not is_installed:
        transparent_pixbuf = get_overlay(size).copy()
        pixbuf.composite(transparent_pixbuf, 0, 0, size[0], size[1],
                         0, 0, 1, 1, GdkPixbuf.InterpType.NEAREST, 100)
        return transparent_pixbuf
    return pixbuf
开发者ID:dacp17,项目名称:lutris,代码行数:27,代码来源:gameviews.py

示例8: add_commands

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_size [as 别名]
    def add_commands(self, commands):

        command_icon = Pixbuf.new_from_file_at_size(
            "{base_path}/res/command.svg".format(base_path=os.path.dirname(os.path.realpath(__file__))), 16, 16
        )

        for name, command in commands.items():
            self.append({"type": "command", "name": name, "keyword": command, "command": command, "icon": command_icon})
开发者ID:whouweling,项目名称:launch-o-matic,代码行数:10,代码来源:launchomatic.py

示例9: getThumbnail

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_size [as 别名]
def getThumbnail(path, size):
    """Gets thumbnail for file at path. The function will try to create
    one if it is not found. Returns None if this fails."""
    defaultIcon = Gtk.IconTheme.get_default().load_icon("gtk-file", size, 0)
    thumbnailPath = pathToThumbnailPath(path, size)
    thumbnailers = loadThumbnailers()
    pixbuf = None
    try: 
        return Pixbuf.new_from_file_at_size(thumbnailPath, size, size)
    except: 
        pass
    if size>128:
        tsize = 256
    else:
        tsize = 128
    try:    
        pixbuf = Pixbuf.new_from_file_at_size(path, tsize, tsize)
    except:
        pass
    if pixbuf is None and guess_type(path)[0] in thumbnailers.keys():
        o = '"{}"'.format(thumbnailPath)
        u = '"file://{}"'.format(path)
        i = '"{}"'.format(path)
        s = str(tsize)
        command = thumbnailers[guess_type(path)[0]]
        for (pat, sub) in [("%o", o), ("%i", i), ("%u", u), ("%s", s)]:
            command = re.sub(pat, sub, command)       
        os.system(command)
        try:
            pixbuf = Pixbuf.new_from_file_at_size(thumbnailPath, tsize, tsize)
        except:
            return defaultIcon
    if pixbuf is None:
        return defaultIcon
    pixbuf.savev(thumbnailPath, "png", [], [])
    width = pixbuf.get_width()
    height = pixbuf.get_height()
    if height > width:
        width = size * width / height
        height = size
    else:
        height = size * height / width
        width = size
    pixbuf = pixbuf.scale_simple(width, height, GdkPixbuf.InterpType.BILINEAR)
    return pixbuf
开发者ID:arkocal,项目名称:filebrowser,代码行数:47,代码来源:dirFrame.py

示例10: __loadPath__

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_size [as 别名]
    def __loadPath__(self, path):
        self.liststore.clear()
        needGenerateMiniature = False
        
        for targetDir in self.__getDirs__(path):
            if targetDir == '..':
                pixbuf = Pixbuf.new_from_file_at_size(self.configuration.getTheme().getBackIcon(), self.configuration.getFolderIconSize(), self.configuration.getFolderIconSize())
                backPath = path[0:path.rindex('/')]
                self.liststore.append([pixbuf, '', backPath, True])
            else:
                pixbuf = Pixbuf.new_from_file_at_size(self.configuration.getTheme().getFolderIcon(), self.configuration.getFolderIconSize(), self.configuration.getFolderIconSize())
                self.liststore.append([pixbuf, targetDir, join(path, targetDir), True])

        for targetFile in self.__getFiles__(path):
            miniature = self.__getMiniature__(path, targetFile)
            if (miniature != None):
                try:
                    pixbuf = Pixbuf.new_from_file_at_size(miniature, self.configuration.getFileIconSize(), self.configuration.getFileIconSize())
                except GLib.GError:
                    pixbuf = Pixbuf.new_from_file_at_size(self.configuration.getTheme().getVideoIcon(), self.configuration.getFolderIconSize(), self.configuration.getFolderIconSize())
            else:
                pixbuf = Pixbuf.new_from_file_at_size(self.configuration.getTheme().getVideoIcon(), self.configuration.getFolderIconSize(), self.configuration.getFolderIconSize())
                needGenerateMiniature = True

            self.liststore.append([pixbuf, targetFile, join(path, targetFile), False])

        self.currentPath = path;

        if self.selectedItem != None:
            self.configuration.getLogger().debug('Reset selected item to ' + unicode(self.selectedItem))
            self.catalogView.select_path(self.selectedItem)
            self.catalogView.set_cursor(self.selectedItem, None, False)
            
        if (needGenerateMiniature == True):
            subprocess.Popen(['python', self.configuration.getAppStartDir() + 'worker/miniaturegenerator.py',
                              '-i', self.currentPath, 
                              '-o', self.configuration.getMiniatureDir(), 
                              '-e', self.configuration.getEncoding()])
开发者ID:DmitryErmolchik,项目名称:MediaCatalog,代码行数:40,代码来源:catalog.py

示例11: add_launchers

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_size [as 别名]
    def add_launchers(self):

        command_icon = Pixbuf.new_from_file_at_size(
            "{base_path}/res/command.svg".format(base_path=os.path.dirname(os.path.realpath(__file__))), 16, 16
        )

        theme = IconTheme()

        for launcher_directory in ["/home/wouter/.local/share/applications", "/usr/share/applications"]:

            for launcher in os.listdir(launcher_directory):

                try:
                    config = ConfigParser.ConfigParser()
                    config.read("%s/%s" % (launcher_directory, launcher))

                    if not config.has_section("Desktop Entry"):
                        continue

                    if not config.get("Desktop Entry", "type") == "Application":
                        continue

                    icon_name = config.get("Desktop Entry", "icon")

                    icon = command_icon

                    if icon_name != "eclipse.png":
                        print icon_name
                        try:
                            icon = theme.load_icon(icon_name, 20, 0)
                        except:
                            pass

                    self.append(
                        {
                            "type": "command",
                            "name": config.get("Desktop Entry", "name"),
                            "keyword": "",
                            "command": config.get("Desktop Entry", "exec"),
                            "icon": icon,
                        }
                    )

                except ConfigParser.Error:
                    pass
开发者ID:whouweling,项目名称:launch-o-matic,代码行数:47,代码来源:launchomatic.py

示例12: _action_to_menuitem

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_size [as 别名]
    def _action_to_menuitem(self, ctx, action):
        menuitem = Gtk.ImageMenuItem(action["title"])

        # the icon could have been read from the config, or set in one of the modules
        if "icon" in action: # and os.path.exists(action["icon"]):

            # nota: pode ser absoluto já e nesse caso o cfgdir é ignorado
            iconfile = os.path.join(self.cfg.cfgdir, "icons", action["icon"])

            if os.path.exists(iconfile):
                pixbuf = Pixbuf.new_from_file_at_size(iconfile, self.MENU_ICON_SIZE, self.MENU_ICON_SIZE)
                img = Gtk.Image()
                img.set_from_pixbuf(pixbuf)

                menuitem.set_image(img)

                # if I don't call this, the image will only appear if gnome is configured to show images in menus!
                # But I reallly want the images!!!
                menuitem.set_always_show_image(True)

        menuitem.connect('activate', self.on_menu_action, ctx, action)
        return menuitem
开发者ID:idnael,项目名称:ctxsearch,代码行数:24,代码来源:actions.py

示例13: addFile

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_size [as 别名]
    def addFile(self, widget):
        """
        Add file (image) dialog.
        """
        dialog = Gtk.FileChooserDialog(
            "Please choose a file",
            self,
            Gtk.FileChooserAction.OPEN,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK),
        )

        # self.add_filters(dialog)

        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            fileName = dialog.get_filename()
            self.fileList.append(fileName)
            pixBuf = Pixbuf.new_from_file_at_size(fileName, 120, 120)
            self.listStore.append([pixBuf])
        elif response == Gtk.ResponseType.CANCEL:
            print("Cancel clicked")

        dialog.destroy()
开发者ID:rodolfovick,项目名称:png2pdf,代码行数:25,代码来源:png2pdf.py

示例14: get_default_icon

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_size [as 别名]
def get_default_icon(icon, size):
    x, y = size
    return Pixbuf.new_from_file_at_size(icon, x, y)
开发者ID:dacp17,项目名称:lutris,代码行数:5,代码来源:gameviews.py

示例15: populate_with_data

# 需要导入模块: from gi.repository.GdkPixbuf import Pixbuf [as 别名]
# 或者: from gi.repository.GdkPixbuf.Pixbuf import new_from_file_at_size [as 别名]
 def populate_with_data(self):
     for floc in glob.glob(os.path.join(self.data_dir, "tiles", "*.json")):
         f = json.load(open(floc))
         td = TileData(f["solid"], f["visible"], f["name"], f["icon"])
         pb = Pixbuf.new_from_file_at_size(os.path.join(self.data_dir, "icons", f["icon"]), 64, 64)
         self.tilestore.append([pb, td])
开发者ID:windwarrior,项目名称:minimalism,代码行数:8,代码来源:main_window.py


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