[Image-SIG] Creating a Transparent Image and Placing it Over Another Image (txt)

Wayne Watson sierra_mtnview at sbcglobal.net
Sat Apr 11 20:20:48 CEST 2009


I thought I posted the solution,

    from Tkinter import *
    import Image, ImageTk
    import tkFileDialog

Maybe as part of another thread. I've found it quite easy to put things 
in the wrong place. That has to do with sometimes not changing my usual 
format from html to plain text, which hangs the msg with  the moderator, 
and  Mozilla's Reply All. In the latter case, if I use Reply, which I 
usually to most mail, it gives me one address and not all. It might not 
include image-sig at python.org. Actually, there's a third way. Some 
posters seem to bet here from a non-image-sig at python.org address, so a 
Reply All won't get to image-sig at python.org.

I'm not that far into Python to comment on the import-from stuff, but 
Chun in his book Core Pyton comments:
"[use the] ... following order:
 Py std lib modules
 Py third party modules
 App specific"

He comments that "from module-x import *" is bad form. However, he cites 
two places where it make sense, page 487.

Christopher Barker wrote:
> Fredrik Lundh wrote:
>> The Tkinter module contains a "Image" class, so doing the "import *"
>> thing after all other imports will stomp out the Import module.
>> Either fix all uses of PIL to use fully qualified names (replace
>> "import Image" with "import PIL.Image", "Image.open" with
>> "PIL.Image.open" etc), or, easier, move the "from Tkinter import *"
>> line to the top of the imports.
>
> but then you can't access the Tkinter Image class.
>
> "import *" is a bad idea, plain and simple, and this is why!
>
> "Namespaces are one honking great idea -- let's do more of those"
>
> note: that's not "less of those".
>
> EVERY package I work with that used to recommend "import *", no longer 
> does: numpy, wxPython, matplotlib, ....
>
> I'd do something like:
>
> import PIL
> import PIL.Image as Image
>
> img=Image.open('white dragon.png')
>
> (By the way, is "import Image" depreciated? it should be.)
>
>
> import Tkinter as TK
>
> root=TK.Tk()
>
> etc.
>
>
> -Chris
>
>
>



Christopher Barker wrote:
> Fredrik Lundh wrote:
>> The Tkinter module contains a "Image" class, so doing the "import *"
>> thing after all other imports will stomp out the Import module.
>> Either fix all uses of PIL to use fully qualified names (replace
>> "import Image" with "import PIL.Image", "Image.open" with
>> "PIL.Image.open" etc), or, easier, move the "from Tkinter import *"
>> line to the top of the imports.
>
> but then you can't access the Tkinter Image class.
>
> "import *" is a bad idea, plain and simple, and this is why!
>
> "Namespaces are one honking great idea -- let's do more of those"
>
> note: that's not "less of those".
>
> EVERY package I work with that used to recommend "import *", no longer 
> does: numpy, wxPython, matplotlib, ....
>
> I'd do something like:
>
> import PIL
> import PIL.Image as Image
>
> img=Image.open('white dragon.png')
>
> (By the way, is "import Image" depreciated? it should be.)
>
>
> import Tkinter as TK
>
> root=TK.Tk()
>
> etc.
>
>
> -Chris
>
>
>

-- 

           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

             (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)****

          "In arithemtic as in politics, the importance of one is
           determined by the number of zeros behind it." -- Anon 
          




More information about the Image-SIG mailing list