Configs2026年7月28日·1 分钟阅读

pywebview — Lightweight Python GUI with Web Technologies

A cross-platform Python library that creates native GUI windows with embedded web views, letting you build desktop applications using HTML, CSS, and JavaScript for the frontend with Python for the backend.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
pywebview
直接安装命令
npx -y tokrepo@latest install 9fbf37a7-8a61-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

pywebview provides a simple way to create desktop GUI applications in Python using web technologies for the interface. Instead of bundling a full browser engine, it uses the system's native webview component (WebKit on macOS, WebView2 on Windows, WebKitGTK on Linux), keeping your application lightweight.

What pywebview Does

  • Creates native desktop windows with an embedded web renderer
  • Exposes Python functions to JavaScript for bidirectional communication
  • Supports loading local HTML files, remote URLs, or inline HTML content
  • Provides a built-in HTTP server for serving local web assets
  • Handles file dialogs, window management, and system tray integration

Architecture Overview

pywebview uses the platform's native webview: Cocoa WebKit on macOS, Microsoft Edge WebView2 on Windows, and WebKitGTK or QtWebEngine on Linux. The Python process creates the window and optionally starts a local HTTP server. A JavaScript bridge lets frontend code call Python functions and receive results. All rendering happens in the native webview process, so the Python process handles only application logic and API calls.

Self-Hosting & Configuration

  • Install with pip; no additional build tools required for basic usage
  • On Windows, WebView2 runtime is included with Windows 10/11 or installable separately
  • On Linux, install the webkitgtk package from your distribution's repository
  • Configure window properties like size, resizability, and transparency at creation time
  • Use the built-in server or bring your own Flask, FastAPI, or Django backend

Key Features

  • Uses native webview rather than bundling Chromium, resulting in minimal overhead
  • Python-to-JavaScript API bridge with automatic JSON serialization
  • Multiple window support with independent content and event handling
  • File open and save dialogs through native OS interfaces
  • Frameless and transparent window modes for custom UI designs

Comparison with Similar Tools

  • Electron is more powerful but bundles Chromium, adding 150 MB+; pywebview uses the system webview
  • Eel is a similar Python library but uses Chrome in app mode rather than native webview
  • Tauri uses Rust for the backend; pywebview keeps everything in Python
  • NiceGUI and Streamlit serve UIs in a browser tab; pywebview opens a native window
  • Tkinter and PyQt require learning their widget APIs; pywebview lets you use standard HTML/CSS/JS

FAQ

Q: What is the minimum application size? A: Since pywebview uses the system webview, your distribution is just the Python code and assets. A packaged app with PyInstaller can be as small as 15-30 MB.

Q: Can I use frontend frameworks like React or Vue? A: Yes. Build your frontend with any framework and either serve the built files through pywebview's local server or load them from a dist folder.

Q: Does pywebview work with virtual environments? A: Yes. Install pywebview in any virtualenv or conda environment as you would any other Python package.

Q: How do I package the app for distribution? A: Use PyInstaller, cx_Freeze, or Nuitka to bundle the Python code, pywebview, and your web assets into a standalone executable.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产