def show_busy(self):
     self.blank()
     try:
         self['file'] = grailutil.which(os.path.join("icons",
                                                     "image.gif")) or ""
     except TclError:
         pass
 def show_bad(self):
     self.blank()
     try:
         self['file'] = grailutil.which(
             os.path.join("icons", "sadsmiley.gif")) or ""
     except TclError:
         pass
示例#3
0
 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:
         self.label.config(text="<decoding>")
         self.label.update_idletasks()
         data = str.join(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!')
示例#5
0
from tkinter import *
from utils import tktools

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 = tk_tools_make_toplevel(args, kw)
        # icon set up
        try:
            w.iconbitmap('@' + _iconxbm_file)
        except TclError:
            pass
        if _iconmask_file:
            try:
示例#6
0
 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" % repr(url))
     self.url = "file:" + urllib.pathname2url(file)
示例#7
0
import tempfile
import os

from utils.grailutil import getenv, which
from tkinter import *
from formatter import AS_IS

_FILTERCMD = 'djpeg'
_FILTERARG = '-gif'
_FILTERPATH = which(_FILTERCMD, str.split(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,