本文整理汇总了Python中ImageTk.PhotoImage方法的典型用法代码示例。如果您正苦于以下问题:Python ImageTk.PhotoImage方法的具体用法?Python ImageTk.PhotoImage怎么用?Python ImageTk.PhotoImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageTk
的用法示例。
在下文中一共展示了ImageTk.PhotoImage方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: aboutCommand
# 需要导入模块: import ImageTk [as 别名]
# 或者: from ImageTk import PhotoImage [as 别名]
def aboutCommand(self):
if self.aboutroot == None:
self.aboutroot = Toplevel()
self.aboutroot.title('About')
self.aboutroot.protocol("WM_DELETE_WINDOW", lambda: self.on_closing("aboutroot") )
canvas = Canvas(self.aboutroot, width=300, height=300)
image = Image.open("/usr/share/cownewsreader/media/background.png")
image = image.resize((100, 100), Image.ANTIALIAS)
self.img = ImageTk.PhotoImage(image)
canvas.create_image(100, 20, image = self.img, anchor="nw")
name = Label(canvas, text="CowNewsReader" ,anchor='w',font="monosa 11 bold")
name.pack()
canvas.create_window(80, 150, window=name, anchor='w')
version = Label(canvas, text="1.0.0" ,anchor='w')
version.pack()
canvas.create_window(120, 180, window=version, anchor='w')
copyright = Label(canvas, text="© 2016 Shkelqim Memolla" ,anchor='w')
copyright.pack()
canvas.create_window(80, 220, window=copyright, anchor='w')
canvas.pack()
示例2: displayDiff
# 需要导入模块: import ImageTk [as 别名]
# 或者: from ImageTk import PhotoImage [as 别名]
def displayDiff(val):
global oldval
newval=(val,my_var.get())
if newval[0]!=oldval[0] or newval[1]!=oldval[1]:
if my_var.get()==0:
if newval[1]!=oldval[1]:
imD=diffTransImage(img1,img2)
scaletext.config(text="\nSlider has no Affect\n")
elif my_var.get()==1:
imD=diffError(img1,img2,int(val))
scaletext.config(text="\nChange Tolerance\n")
elif my_var.get()==2:
imD=diffErrorOverlay(img1,img2,int(val))
scaletext.config(text="\nChange Tolerance\n")
elif my_var.get()==3:
imD= overlayImage(img1,img2,int(val))
scaletext.config(text="\nChange Image2 Transparency\n")
else:
imD=slideImage(img1,img2,int(val))
scaletext.config(text="\nSlide to Change Images\n")
try:
imD=imD.convert('RGB')
except:
pass
try:
img = ImageTk.PhotoImage(imD)
panel.config(image=img)
panel.image=img
except UnboundLocalError:
pass
oldval=newval
示例3: __init__
# 需要导入模块: import ImageTk [as 别名]
# 或者: from ImageTk import PhotoImage [as 别名]
def __init__(self,val,path,parent):
self.val = int(val)
self.pallete = self.getProminent(path,self.val)
self.Tkimg = ImageTk.PhotoImage(self.pallete)
self.TkL = Tkinter.Label(parent, image = self.Tkimg)
self.TkL.pack(side = "left", fill = "both", expand = "yes")
示例4: __init__
# 需要导入模块: import ImageTk [as 别名]
# 或者: from ImageTk import PhotoImage [as 别名]
def __init__(self):
self.passwd = None
self.do_update = False
# current working directory
self.cwd = os.getcwd()
self.bemoss_dir = self.cwd.replace('bemoss_gui', 'bemoss_os/')
img_path = self.find_img()
self.logo = ImageTk.PhotoImage(Image.open(img_path).resize((350,125)))
self.img = ttk.Label(root, image=self.logo, justify='center')
self.img.pack(fill=Tkinter.Y, expand=True, padx=5, pady=30)
# logoimage
self.ip_addr = self.getIPs()
self.ipframe = Tkinter.LabelFrame(root, text='Your IP address:')
self.ip_label = Tkinter.Label(self.ipframe, text=self.ip_addr, font=('Courier', 12, 'bold'))
self.ip_label.pack()
self.ipframe.pack(fill=Tkinter.X, expand=True, padx=15)
# IP
self.button_quit = ttk.Button(root, text='Run BEMOSS', command=self.run_software)
self.button_quit.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=True, pady=15, padx=10)
self.button_runNode = ttk.Button(root, text='Run BEMOSS Node', command=self.run_software_asnode)
self.button_runNode.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=True, pady=15, padx=10)
self.button_run = ttk.Button(root, text='Stop BEMOSS', command=self.stop_software)
self.button_run.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=True, pady=15, padx=10)
self.button_adv = ttk.Button(root, text='Advanced Setting', command=self.adv_set)
self.button_adv.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=True, pady=15, padx=10)
# buttons
示例5: getPicture
# 需要导入模块: import ImageTk [as 别名]
# 或者: from ImageTk import PhotoImage [as 别名]
def getPicture(self, imgPath):
File = imgPath
image = Image.open(File)
image = image.resize((100, 100), Image.ANTIALIAS)
self.img = ImageTk.PhotoImage(image)
示例6: set_background
# 需要导入模块: import ImageTk [as 别名]
# 或者: from ImageTk import PhotoImage [as 别名]
def set_background(self, np_array, color = False):
"""Takes a (numpy) array and sets this as background."""
if color:
img = Image.fromarray(np.flipud(np.uint8(np_array)), mode="RGB")
else:
img = Image.fromarray(np_array)
if self.background_image_id:
self.world_canvas.delete(self.background_image_id)
img = img.resize(self.extents, Image.NEAREST)
self.background_image = ImageTk.PhotoImage(img)
self.background_id = self.world_canvas.create_image(0, 0,
image=self.background_image, anchor=NW, tag="background")
# Make sure drawing order is correct.
self.set_display_order()
示例7: convert2byte
# 需要导入模块: import ImageTk [as 别名]
# 或者: from ImageTk import PhotoImage [as 别名]
def convert2byte(self, depth=255):
(min, max) = self.getextrema()
m = 1
if max != min:
m = depth / (max-min)
b = -m * min
return self.point(lambda i, m=m, b=b: i * m + b).convert("L")
# returns a ImageTk.PhotoImage object, after rescaling to 0..255
示例8: tkPhotoImage
# 需要导入模块: import ImageTk [as 别名]
# 或者: from ImageTk import PhotoImage [as 别名]
def tkPhotoImage(self):
import ImageTk
return ImageTk.PhotoImage(self.convert2byte(), palette=256)
# --------------------------------------------------------------------
# Image series
# given a list of filenames, return a list of images
示例9: open_image
# 需要导入模块: import ImageTk [as 别名]
# 或者: from ImageTk import PhotoImage [as 别名]
def open_image(self, res, res_label, src_label):
fileName = tkFileDialog.askopenfilename()
folder = path.split(fileName)[0]
baseName = path.basename(fileName)
name = path.splitext(baseName)[0]
pngBaseName = name + '.final.png'
srcImage = Image.open(fileName)
tksrc = ImageTk.PhotoImage(srcImage)
src_label.config(compound=BOTTOM, image=tksrc, text=baseName)
src_label.image = tksrc
top.update()
size = 'png:w' + str(srcImage.size[0]) + ',h' + str(srcImage.size[1])
process.launch_correct(fileName, size)
pngName = path.join(folder, name, pngBaseName)
resImage = Image.open(pngName)
tkres = ImageTk.PhotoImage(resImage)
res_label.config(compound=BOTTOM, image=tkres, text=pngBaseName)
res_label.image = tkres
top.update()
buttonFrame = Frame(res)
buttonFrame.pack(side=BOTTOM)
goodButton = Button(buttonFrame, text="Good", command=self.good)
goodButton.pack(side=LEFT)
badButton = Button(buttonFrame, text="Bad", command=self.bad)
badButton.pack(side=LEFT)
editorButton = Button(buttonFrame, text="Open editor", command=lambda: self.editor(fileName))
editorButton.pack(side=LEFT)