英文:
how to embed html iframe on Python tkinter app
问题
我想知道如何将来自Web应用的图表iframe HTML内容嵌入到tkinter中。
我还没有尝试过,但我看到了一些模块,比如tkhtmlview,但它不是一个网页浏览器,所以它可能不太适合我想要的功能。
我还看到了CEFPython,但最新版本是在2021年2月发布的。
还有其他选择吗?
谢谢。
英文:
I would like to know how its possible to embed a chart iframe html content from a web app into tkinter
I haven't tried yet, but I have seen a few modules such as tkhtmlview, but it isn't a web browser, so it probably won't work well for what I am looking for
I've seen also CEFPython, but the latest release dates to Feb 2021.
Any other choices?
Thanks
答案1
得分: 1
使用tkinter的Frame小部件和"pywebview"库中的"WebView"小部件。
pip install pywebview
import tkinter as tk
import webview
def load_webpage():
webview.load_url('path/to/your/html/file.html')
root = tk.Tk()
frame = tk.Frame(root)
frame.pack()
button = tk.Button(frame, text="加载网页", command=load_webpage)
button.pack()
root.mainloop()
上面的代码演示了如何在tkinter中嵌入HTML iframe。
英文:
Use the tkinter Frame widget and the "WebView" widget from the "pywebview" library.
pip install pywebview
import tkinter as tk
import webview
def load_webpage():
webview.load_url('path/to/your/html/file.html')
root = tk.Tk()
frame = tk.Frame(root)
frame.pack()
button = tk.Button(frame, text="Load webpage", command=load_webpage)
button.pack()
root.mainloop()
The above code demonstrates the way you can achieve embedding html iframe in tkinter
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论