Traceback error导入tkinter 进口PIL 从tkinter导入* 将tkinter.ttk导入为ttk;
来自tkinter导入文件对话框 从PIL导入ImageTk,图像
类根(Tk): def init (自己): 超级(root,self)。初始化() self.title(“使用深度学习进行脑肿瘤检测”) self.minsize(400,200) #self.wm_iconbitmap('icon.ico')
HTTP 1.1/201 Created
{
"user_id": 1,
"name": "John",
"gender": "male",
"books": [
{
"book_id": 1,
"title": "A new Adventure"
},
{
"book_id": 3,
"title": "The Last Standing Man"
}
]
}
``def open_img(): #从文件夹中选择图像名称 x = self.fileDialog() #打印(x) #打开图片 img = Image.open(x)
self.labelFrame = ttk.LabelFrame(self, text = "Choose Here")
self.labelFrame.grid(column = 0, row = 5, padx = 150, pady = 150)
self.button()
def button(self):
self.button = ttk.Button(self.labelFrame, text = "Browse A File",command=self.open_img)
self.button.grid(column = 1, row = 1)
def fileDialog(self):
self.filename = filedialog.askopenfilename(initialdir = "/", title = "Select A File", filetype =
(("jpeg files","*.jpg"),("all files","*.*")) )
print(self.filename)
#print(self.filename)
#photo = PhotoImage(self.filename)
self.label = ttk.Label(self.labelFrame, text = "")
self.label.grid(column = 1, row = 2)
self.label.configure(text = self.filename)