Skip to main content

tkinter-WebView2 widget, based on WebView2.Core

Project description

tkwebview2

tkinter浏览器-网页组件,tkwebview2登场!!!

基于pythonnet-webview绑定和WebView2.Core,将受到微软WebView2的持续改进支持,外观和效能相比tkinterie得到大幅度改进。

依赖

以下是tkwebview2的依赖库:

  • pythonnet(clr)
  • pywebview(webview)

使用方法

WebView2(master,width:int,height:int,url:str='',**kw)
'''
master::父组件
width::初始宽度
height::初始高度
url::网址或html文件,可以为空
**kw::其它Frame参数
'''

例子:

from tkinter import Tk
from tkwebview2 import WebView2

root=Tk()
root.title('pywebview for tkinter test')
root.geometry('1200x600+5+5')

frame=WebView2(root,500,500)
frame.load_html('<h1>hi hi hi</h1>')
frame.pack(side='left')

frame2=WebView2(root,500,500)
frame2.load_url('https://smart-space.com.cn/')
frame2.pack(side='right',fill='x',expand=True)

root.mainloop()

方法

get_url()

返回当前url。

evaluate_js(self,script)

执行JavaScript代码,并返回最终结果。

load_css(self,css)

加载CSS样式。

load_html(self,content,base_uri=None)

加载HTML代码,base_uri为基本URL,默认为本程序启动目录。

load_url(self,url)

加载全新url。


What's new

-1.0.0-

Upload to PYPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

tkwebview2-1.1.0-py3-none-any.whl (7.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page