Ejemplo n.º 1
0
 def load_base(self, number):
     # Loads the base page (aka the page without the speech bubbles) from file.
     # We used to use a different system that allowed us to scale the svg to
     # the size of the page, but we can't do that from memory apparently so now
     # we just assume that the svg has the proper width and height setup
     pixbuf_loader = PixbufLoader.new_with_type('png')
     pixbuf_loader.write(self.comic.get_page_base(number))
     pixbuf_loader.close()
     pixbuf = pixbuf_loader.get_pixbuf()
     self.comic_base_pixbuf = pixbuf
Ejemplo n.º 2
0
 def load_translation(self, number):
     # Gets the translation svg and loads it to memory, I used to use a different method that allowed for scaling SVG
     # files to the proper resolution (rendering it again), however this method sucks ass and the authors should just
     # make their SVGs be the proper size.
     pixbuf_loader = PixbufLoader.new_with_type('svg')
     pixbuf_loader.write(
         self.comic.get_page_translation(self.comic_language, number))
     pixbuf_loader.close()
     pixbuf = pixbuf_loader.get_pixbuf()
     self.translated_comic_pixbuf = self.comic_base_pixbuf
     pixbuf.composite(self.translated_comic_pixbuf, 0, 0,
                      self.comic_base_pixbuf.props.width,
                      self.comic_base_pixbuf.props.height, 0, 0, 1.0, 1.0,
                      InterpType.HYPER, 254)
## Add a row with a stock icon (also easy)
iconpixbuf = Gtk.IconTheme.get_default().load_icon("folder", 16, 0)
treestore.append(None, [iconpixbuf, "data with a stock icon"])

## Add a row with an image from disk (still easy, uncomment if you have a suitable image file)
#loadedpixbuf = Pixbuf.new_from_file_at_size("../../img/logo.png", 125, 125) 
#treestore.append(None, [loadedpixbuf, "data with a custom image from disk"])

## Add a row with a flat-painted image (easy, but not always useful...)
from gi.repository import Gtk, Gdk
filledpixbuf = Pixbuf.new(Colorspace.RGB, True, 8, 16, 16)  ## In fact, it is RGBA
filledpixbuf.fill(0xff9922ff) 
treestore.append(None, [filledpixbuf, "data with a custom color filled image"])


px = PixbufLoader.new_with_type('pnm')
#color = b'\xee\xff\x2d'
#px.write(b'P6\n\n1 1\n255\n' + color)
#px.write(color)
iconpnm = b"""P2 24 7 25
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  3  3  3  3  0  0  7  7  7  7  0  0 11 11 11 11  0  0 15 15 15 15  0
0  3  0  0  0  0  0  7  0  0  0  0  0 11  0  0  0  0  0 15  0  0 15  0
0  3  3  3  0  0  0  7  7  7  0  0  0 11 11 11  0  0  0 15 15 15 15  0
0  3  0  0  0  0  0  7  0  0  0  0  0 11  0  0  0  0  0 15  0  0  0  0
0  3  0  0  0  0  0  7  7  7  7  0  0 11 11 11 11  0  0 15  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
"""
px.write(iconpnm)
px.close()
treestore.append(None, [px.get_pixbuf(), "data with an image loaded from a custom inline PNM file (tedious)"])
Ejemplo n.º 4
0
## Add a row with a stock icon (also easy)
iconpixbuf = Gtk.IconTheme.get_default().load_icon("folder", 16, 0)
treestore.append(None, [iconpixbuf, "data with a stock icon"])

## Add a row with an image from disk (still easy, uncomment if you have a suitable image file)
#loadedpixbuf = Pixbuf.new_from_file_at_size("../../img/logo.png", 125, 125)
#treestore.append(None, [loadedpixbuf, "data with a custom image from disk"])

## Add a row with a flat-painted image (easy, but not always useful...)
from gi.repository import Gtk, Gdk
filledpixbuf = Pixbuf.new(Colorspace.RGB, True, 8, 16,
                          16)  ## In fact, it is RGBA
filledpixbuf.fill(0xff9922ff)
treestore.append(None, [filledpixbuf, "data with a custom color filled image"])

px = PixbufLoader.new_with_type('pnm')
#color = b'\xee\xff\x2d'
#px.write(b'P6\n\n1 1\n255\n' + color)
#px.write(color)
iconpnm = b"""P2 24 7 25
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  3  3  3  3  0  0  7  7  7  7  0  0 11 11 11 11  0  0 15 15 15 15  0
0  3  0  0  0  0  0  7  0  0  0  0  0 11  0  0  0  0  0 15  0  0 15  0
0  3  3  3  0  0  0  7  7  7  0  0  0 11 11 11  0  0  0 15 15 15 15  0
0  3  0  0  0  0  0  7  0  0  0  0  0 11  0  0  0  0  0 15  0  0  0  0
0  3  0  0  0  0  0  7  7  7  7  0  0 11 11 11 11  0  0 15  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
"""
px.write(iconpnm)
px.close()
treestore.append(None, [