python - Python - 在标签中加载图像
问题描述
我很难使用PAGE GUI Generator在标签中加载图像。下面是我的用户界面:
每次单击“浏览文档”按钮时,它都会调用一个open_file_dialog_function
,下面是函数:
def open_file_dialog(self):
self.filename = filedialog.askopenfilename(initialdir = "/", title = "Select A File", filetype = (("jpeg", "*.jpg"), ("All Files", "*.*")))
#Display Document Path
self.label_document_path1 = ttk.Label(self.label_document_path, text = "")
self.label_document_path1.grid(column = 1, row = 2)
self.label_document_path1.configure(text = self.filename)
#Load Damaged Document
load = Image.open(self.filename)
render = ImageTk.PhotoImage(load)
self.label_input_document1 = ttk.Label(self.label_input_document, image = render)
self.label_input_document1.grid(column = 1, row = 3)
self.label_input_document1.configure(image = render)
每次执行该功能时,它只在假定的图像中显示白色。为什么?请帮我。
解决方案
推荐阅读
- python - 当按下 Flutter 中编程的按钮时,有没有办法可以运行 python 脚本?
- graphql - 如何使用 gatsby 从内容中显示媒体内容
- python - 如何从命令行使用已安装的 pip3 包?
- javascript - 在 Card 组件中居中 Avatar 组件
- python-3.x - 指定 Spark Schema 不会显示正确的显示结果
- javascript - CKEditor 4 冻结
- javascript - Javascript - 倒数计时器
- vue.js - 将scss文件预编译为css
- python-3.x - Python - 没有名为 cv2 的模块
- python - .transform('first') 有什么作用?