Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/mmm_modules/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'mmm_modules/utils.py')
-rw-r--r--mmm_modules/utils.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/mmm_modules/utils.py b/mmm_modules/utils.py
index 1db4fca..3eeade0 100644
--- a/mmm_modules/utils.py
+++ b/mmm_modules/utils.py
@@ -18,9 +18,7 @@
# own creations we would love to hear from you at info@WorldWideWorkshop.org !
#
-import pygtk
-pygtk.require('2.0')
-import gtk
+from gi.repository import Gtk, GdkPixbuf
import logging
RESIZE_STRETCH = 1
@@ -92,7 +90,7 @@ def load_image (filename, width=-1, height=-1, method=RESIZE_CUT):
# slider.prepare_stringed(2,2)
# return slider
#
- img = gtk.Image()
+ img = Gtk.Image()
try:
img.set_from_file(filename)
pb = img.get_pixbuf()
@@ -106,7 +104,7 @@ def resize_image (pb, width=-1, height=-1, method=RESIZE_CUT):
logging.debug("utils: method=%i" % method)
if method == RESIZE_STRETCH or width == -1 or height == -1:
w,h = calculate_relative_size(pb.get_width(), pb.get_height(), width, height)
- scaled_pb = pb.scale_simple(w,h, gtk.gdk.INTERP_BILINEAR)
+ scaled_pb = pb.scale_simple(w,h, GdkPixbuf.InterpType.BILINEAR)
elif method == RESIZE_PAD:
w,h = pb.get_width(), pb.get_height()
hr = float(height)/h
@@ -115,7 +113,7 @@ def resize_image (pb, width=-1, height=-1, method=RESIZE_CUT):
w = w * factor
h = h * factor
logging.debug("RESIZE_PAD: %i,%i,%f" % (w,h,factor))
- scaled_pb = pb.scale_simple(int(w), int(h), gtk.gdk.INTERP_BILINEAR)
+ scaled_pb = pb.scale_simple(int(w), int(h), GdkPixbuf.InterpType.BILINEAR)
else: # RESIZE_CUT / default
w,h = pb.get_width(), pb.get_height()
if width > w:
@@ -151,7 +149,7 @@ def resize_image (pb, width=-1, height=-1, method=RESIZE_CUT):
# w, h now have -1 for the side that should be relatively scaled, to keep the aspect ratio and
# assuring that the image is at least as big as the request.
w,h = calculate_relative_size(pb.get_width(), pb.get_height(), w,h)
- scaled_pb = pb.scale_simple(w,h, gtk.gdk.INTERP_BILINEAR)
+ scaled_pb = pb.scale_simple(w,h, GdkPixbuf.InterpType.BILINEAR)
# now we cut whatever is left to make the requested size
scaled_pb = scaled_pb.subpixbuf(abs((width-w)/2),abs((height-h)/2), width, height)
return scaled_pb