我正在尝试在我的图像上显示文本,但我不能这样做,任何人都可以帮忙。
代码:
# import Image and the graphics package Tkinter
import Tkinter
import Image, ImageTk
class simpleapp_tk(Tkinter.Tk):
def __init__(self,parent):
Tkinter.Tk.__init__(self,parent)
self.parent = parent
self.initialize()
def initialize(self):
## def create_widgets(self):
# create welcome label
label1 = Tkinter.Label(self, text = "Update User")
label1.grid(row = 0, column = 1, columnspan = 2, sticky = 'W')
# open a SPIDER image and convert to byte format
im = Image.open('C:\Users\JOHN\Desktop\key.jpg')
root = Tkinter.Tk() # A root window for displaying objects
# Convert the Image object into a TkPhoto object
tkimage = ImageTk.PhotoImage(im)
Tkinter.Label(root, image=tkimage).pack() # Put it in the display window
root.mainloop() # Start the GUI