def show_bad(self): self.blank() try: self['file'] = grailutil.which( os.path.join("icons", "sadsmiley.gif")) or "" except TclError: pass
def show_busy(self): self.blank() try: self['file'] = grailutil.which( os.path.join("icons", "image.gif")) or "" except TclError: pass
def show_busy(self): self.blank() try: self['file'] = grailutil.which(os.path.join("icons", "image.gif")) or "" except TclError: pass
def load_dingbat(self, entname): if self.dingbatimages.has_key(entname): return self.dingbatimages[entname] gifname = grailutil.which(entname + '.gif', self.iconpath) if gifname: img = PhotoImage(file=gifname, master=self.root) self.dingbatimages[entname] = img return img self.dingbatimages[entname] = None return None
def close(self): if self.buf: try: self.buf = string.joinfields(self.buf, "") im = Image.open(StringIO.StringIO(self.buf)) im.load() # benchmark decoding tkim = ImageTk.PhotoImage(im.mode, im.size) tkim.paste(im) self.label.image = tkim self.label.config(image = self.label.image) except: self.broken = 1 if self.broken: file = grailutil.which(os.path.join('icons', 'sadsmiley.gif')) self.label.image = Tkinter.PhotoImage(file = file) self.label.config(image = self.label.image) self.viewer.text.insert(Tkinter.END, '\nBroken Image!')
def close(self): if self.buf: self.label.config(text="<decoding>") self.label.update_idletasks() data = string.joinfields(self.buf, "") self.buf = None # free lots of memory! try: self.im = im = Image.open(StringIO(data)) im.load() self.tkim = tkim = ImageTk.PhotoImage(im.mode, im.size) tkim.paste(im) except: # XXX What was I trying to catch here? # I think (EOFError, IOError). self.broken = 1 stdout = sys.stdout try: sys.stdout = sys.stderr print "Error decoding image:" print str(sys.exc_type) + ":", sys.exc_value finally: sys.stdout = stdout else: self.label.config(image=tkim) if im.info.has_key("duration"): self.duration = im.info["duration"] if im.info.has_key("loop"): self.duration = self.duration or 100 self.loop = im.info["loop"] self.data = data if self.duration or self.loop: self.viewer.register_reset_interest(self.cancel_loop) self.after_id = self.label.after(self.duration, self.next_image) if self.broken: self.label.image = Tkinter.PhotoImage( file=grailutil.which(ERROR_FILE)) self.label.config(image = self.label.image) self.viewer.text.insert(Tkinter.END, '\nBroken Image!')
import tempfile import os import string from grailutil import getenv, which from Tkinter import * from formatter import AS_IS _FILTERCMD = 'djpeg' _FILTERARG = '-gif' _FILTERPATH = which(_FILTERCMD, string.splitfields(getenv('PATH'), ':')) if hasattr(os, 'popen') and _FILTERPATH: _FILTER = _FILTERPATH + ' ' + _FILTERARG class parse_image_jpeg: """Parser for image/jpeg files. Collect all the data on a temp file and then create an in-line image from it. """ def __init__(self, viewer, reload=0): self.broken = None self.tf = self.tfname = None self.viewer = viewer self.viewer.new_font((AS_IS, AS_IS, AS_IS, 1)) self.tfname = tempfile.mktemp() self.tf = os.popen(_FILTER + '>' + self.tfname, 'wb') self.label = Label(self.viewer.text, text=self.tfname, highlightthickness=0,
import tempfile import os import string from grailutil import getenv, which from Tkinter import * from formatter import AS_IS from PIL import Image, ImageTk SVG_WIDTH_PX = 600 _FILTERCMD = 'inkscape' _FILTERARG = '-z -w %u -e %s.png %s' _FILTERPATH = which("inkscape", string.splitfields(getenv('PATH'), ':')) if hasattr(os, 'popen') and _FILTERPATH: _FILTER = _FILTERPATH + ' ' + _FILTERARG class parse_image_svgxml: """Parser for image/svg+xml files. Collect all the data on a temp file and then create an in-line image from it. """ def __init__(self, viewer, reload=0): self.broken = None self.tf = self.tfname = None self.viewer = viewer self.viewer.new_font((AS_IS, AS_IS, AS_IS, 1)) self.tfname = tempfile.mktemp() self.tf = os.popen('cat >' + self.tfname, 'wb')
def __init__(self, url, method, params): null_access.__init__(self, url, method, params) file = grailutil.which(url) if not file: raise IOError, "Grail file %s not found" % ` url ` self.url = "file:" + urllib.pathname2url(file)
from Viewer import Viewer LOGO_IMAGES = "logo:" FIRST_LOGO_IMAGE = LOGO_IMAGES + "T1.gif" # Window title prefix TITLE_PREFIX = "Grail: " # If we have an icon file, replace tktools.make_toplevel so that it gets # set up as the icon, otherwise don't do anything magic. # _mydir = os.path.dirname(grailutil.abspath(__file__)) _iconxbm_file = grailutil.which( 'icon.xbm', (_mydir, os.path.join(_mydir, "data"))) if _iconxbm_file: _iconmask_file = os.path.join(os.path.dirname(_iconxbm_file), "iconmask.xbm") if not os.path.isfile(_iconmask_file): _iconmask_file = None def make_toplevel(*args, **kw): w = apply(tktools_make_toplevel, args, kw) # icon set up try: w.iconbitmap('@' + _iconxbm_file) except TclError: pass if _iconmask_file: try: w.iconmask('@' + _iconmask_file) except TclError: pass return w #
def __init__(self, url, method, params): null_access.__init__(self, url, method, params) file = grailutil.which(url) if not file: raise IOError, "Grail file %s not found" % `url` self.url = "file:" + urllib.pathname2url(file)
import tempfile import os import string from grailutil import getenv, which from Tkinter import * from formatter import AS_IS _FILTERCMD = 'djpeg' _FILTERARG = '-gif' _FILTERPATH = which(_FILTERCMD, string.splitfields(getenv('PATH'), ':')) if hasattr(os, 'popen') and _FILTERPATH: _FILTER = _FILTERPATH + ' ' + _FILTERARG class parse_image_jpeg: """Parser for image/jpeg files. Collect all the data on a temp file and then create an in-line image from it. """ def __init__(self, viewer, reload=0): self.broken = None self.tf = self.tfname = None self.viewer = viewer self.viewer.new_font((AS_IS, AS_IS, AS_IS, 1)) self.tfname = tempfile.mktemp() self.tf = os.popen(_FILTER + '>' + self.tfname, 'wb') self.label = Label(self.viewer.text, text=self.tfname,
import tempfile import os import string from grailutil import getenv, which from Tkinter import * from formatter import AS_IS from PIL import Image, ImageTk SVG_WIDTH_PX = 600 _FILTERCMD = 'inkscape' _FILTERARG = '-z -w %u -e %s.png %s' _FILTERPATH = which("inkscape", string.splitfields(getenv('PATH'), ':')) if hasattr(os, 'popen') and _FILTERPATH: _FILTER = _FILTERPATH + ' ' + _FILTERARG class parse_image_svgxml: """Parser for image/svg+xml files. Collect all the data on a temp file and then create an in-line image from it. """ def __init__(self, viewer, reload=0): self.broken = None self.tf = self.tfname = None self.viewer = viewer self.viewer.new_font((AS_IS, AS_IS, AS_IS, 1))