2016-07-17 85 views
0

我有借鑑了Canvas部件龜的項目。我已經知道如何保存繪圖,但是如何打開它們。這是我想說的一個例子:Python的龜:如何打開圖形

from tkinter import * 
root = Tk() 
... #Just creating widgets 

def openDrawing: 

...#What goes in here ? 

fileMenu.add_command(label = "Open Drawing",command=openDrawing,accelerator="Ctrl+O") 

root.mainloop() 
+0

取決於你如何保存它(哪種形式?) –

+0

@Billal BEGUERADJ爲PostScript文件(* .PS) –

回答

0

包含圖像數據的PostScript文件格式爲supportedPIL庫。所以,你可以打開你的龜.ps文件是這樣的:

import PIL 

# Load the .ps file using PIL 
ps_file = PIL.Image.open("turtle_file.ps") 
ps_turtle = PIL.ImageTk.PhotoImage(ps_file) 
... 
... 
# Let us suppose you want to display it on a label 
label = Label(image=ps_turtle) 
label.image = ps_turtle # keep a reference 
label.pack() 
+0

感謝。但是,你能告訴我如何使用turtle命令編輯該圖像 –