mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-04 21:50:54 +03:00
py3k: Tkinter module is now tkinter
This commit is contained in:
parent
fa348ee9fe
commit
dda0e9a3ed
|
@ -25,7 +25,13 @@
|
||||||
# See the README file for information on usage and redistribution.
|
# See the README file for information on usage and redistribution.
|
||||||
#
|
#
|
||||||
|
|
||||||
import Tkinter
|
try:
|
||||||
|
import tkinter
|
||||||
|
except ImportError:
|
||||||
|
import Tkinter
|
||||||
|
tkinter = Tkinter
|
||||||
|
del Tkinter
|
||||||
|
|
||||||
from . import Image
|
from . import Image
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -46,9 +52,9 @@ def _pilbitmap_check():
|
||||||
if _pilbitmap_ok is None:
|
if _pilbitmap_ok is None:
|
||||||
try:
|
try:
|
||||||
im = Image.new("1", (1,1))
|
im = Image.new("1", (1,1))
|
||||||
Tkinter.BitmapImage(data="PIL:%d" % im.im.id)
|
tkinter.BitmapImage(data="PIL:%d" % im.im.id)
|
||||||
_pilbitmap_ok = 1
|
_pilbitmap_ok = 1
|
||||||
except Tkinter.TclError:
|
except tkinter.TclError:
|
||||||
_pilbitmap_ok = 0
|
_pilbitmap_ok = 0
|
||||||
return _pilbitmap_ok
|
return _pilbitmap_ok
|
||||||
|
|
||||||
|
@ -111,7 +117,7 @@ class PhotoImage:
|
||||||
|
|
||||||
self.__mode = mode
|
self.__mode = mode
|
||||||
self.__size = size
|
self.__size = size
|
||||||
self.__photo = apply(Tkinter.PhotoImage, (), kw)
|
self.__photo = apply(tkinter.PhotoImage, (), kw)
|
||||||
self.tk = self.__photo.tk
|
self.tk = self.__photo.tk
|
||||||
if image:
|
if image:
|
||||||
self.paste(image)
|
self.paste(image)
|
||||||
|
@ -176,7 +182,7 @@ class PhotoImage:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tk.call("PyImagingPhoto", self.__photo, block.id)
|
tk.call("PyImagingPhoto", self.__photo, block.id)
|
||||||
except Tkinter.TclError as v:
|
except tkinter.TclError as v:
|
||||||
# activate Tkinter hook
|
# activate Tkinter hook
|
||||||
try:
|
try:
|
||||||
import _imagingtk
|
import _imagingtk
|
||||||
|
@ -185,7 +191,7 @@ class PhotoImage:
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
_imagingtk.tkinit(id(tk), 0)
|
_imagingtk.tkinit(id(tk), 0)
|
||||||
tk.call("PyImagingPhoto", self.__photo, block.id)
|
tk.call("PyImagingPhoto", self.__photo, block.id)
|
||||||
except (ImportError, AttributeError, Tkinter.TclError):
|
except (ImportError, AttributeError, tkinter.TclError):
|
||||||
raise # configuration problem; cannot attach to Tkinter
|
raise # configuration problem; cannot attach to Tkinter
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
@ -233,7 +239,7 @@ class BitmapImage:
|
||||||
else:
|
else:
|
||||||
# slow but safe way
|
# slow but safe way
|
||||||
kw["data"] = image.tobitmap()
|
kw["data"] = image.tobitmap()
|
||||||
self.__photo = apply(Tkinter.BitmapImage, (), kw)
|
self.__photo = apply(tkinter.BitmapImage, (), kw)
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
name = self.__photo.name
|
name = self.__photo.name
|
||||||
|
@ -280,18 +286,18 @@ def getimage(photo):
|
||||||
|
|
||||||
def _show(image, title):
|
def _show(image, title):
|
||||||
|
|
||||||
class UI(Tkinter.Label):
|
class UI(tkinter.Label):
|
||||||
def __init__(self, master, im):
|
def __init__(self, master, im):
|
||||||
if im.mode == "1":
|
if im.mode == "1":
|
||||||
self.image = BitmapImage(im, foreground="white", master=master)
|
self.image = BitmapImage(im, foreground="white", master=master)
|
||||||
else:
|
else:
|
||||||
self.image = PhotoImage(im, master=master)
|
self.image = PhotoImage(im, master=master)
|
||||||
Tkinter.Label.__init__(self, master, image=self.image,
|
tkinter.Label.__init__(self, master, image=self.image,
|
||||||
bg="black", bd=0)
|
bg="black", bd=0)
|
||||||
|
|
||||||
if not Tkinter._default_root:
|
if not tkinter._default_root:
|
||||||
raise IOError("tkinter not initialized")
|
raise IOError("tkinter not initialized")
|
||||||
top = Tkinter.Toplevel()
|
top = tkinter.Toplevel()
|
||||||
if title:
|
if title:
|
||||||
top.title(title)
|
top.title(title)
|
||||||
UI(top, image).pack()
|
UI(top, image).pack()
|
||||||
|
|
|
@ -6,7 +6,11 @@
|
||||||
# drag the slider to modify the image.
|
# drag the slider to modify the image.
|
||||||
#
|
#
|
||||||
|
|
||||||
from Tkinter import *
|
try:
|
||||||
|
from tkinter import *
|
||||||
|
except ImportError:
|
||||||
|
from Tkinter import *
|
||||||
|
|
||||||
from PIL import Image, ImageTk, ImageEnhance
|
from PIL import Image, ImageTk, ImageEnhance
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,11 @@
|
||||||
# the image into a set of tiles.
|
# the image into a set of tiles.
|
||||||
#
|
#
|
||||||
|
|
||||||
from Tkinter import *
|
try:
|
||||||
|
from tkinter import *
|
||||||
|
except ImportError:
|
||||||
|
from Tkinter import *
|
||||||
|
|
||||||
from PIL import Image, ImageTk
|
from PIL import Image, ImageTk
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,11 @@
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from Tkinter import *
|
try:
|
||||||
|
from tkinter import *
|
||||||
|
except ImportError:
|
||||||
|
from Tkinter import *
|
||||||
|
|
||||||
from PIL import Image, ImageTk
|
from PIL import Image, ImageTk
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,11 @@
|
||||||
# as a dynamically updated overlay
|
# as a dynamically updated overlay
|
||||||
#
|
#
|
||||||
|
|
||||||
from Tkinter import *
|
try:
|
||||||
|
from tkinter import *
|
||||||
|
except ImportError:
|
||||||
|
from Tkinter import *
|
||||||
|
|
||||||
from PIL import Image, ImageTk
|
from PIL import Image, ImageTk
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,11 @@
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from Tkinter import *
|
try:
|
||||||
|
from tkinter import *
|
||||||
|
except ImportError:
|
||||||
|
from Tkinter import *
|
||||||
|
|
||||||
from PIL import Image, ImageTk
|
from PIL import Image, ImageTk
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue
Block a user