您好我正在使用Python中的Google Map API。我正在使用可在此处找到的源代码website在Python中显示Google Map API Tkinter窗口
此代码在编译时生成一个'htm'文件,显示放置在地图上的标记的Google Map。
所以我创建了如下图所示窗口框架:
from Tkinter import * # order seems to matter: import Tkinter first
import Image, ImageTk # then import ImageTk
class MyFrame(Frame):
def __init__(self, master, im):
Frame.__init__(self, master)
self.caption = Label(self, text="Some text about the map")
self.caption.grid()
self.image = ImageTk.PhotoImage(im) # <--- results of PhotoImage() must be stored
self.image_label = Label(self, image=self.image, bd=0) # <--- will not work if 'image = ImageTk.PhotoImage(im)'
self.image_label.grid()
self.grid()
im = Image.open("test.html") # read map from disk
# or you could use the PIL image you created directly via option 2 from the URL request ...
mainw = Tk()
mainw.frame = MyFrame(mainw, im)
mainw.mainloop()
并与窗框我想在窗框显示谷歌地图的“HTM”的形象。
什么问题? – 2011-03-26 20:22:52