1 Star 1 Fork 0

路庆华/PywebviewVue

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Pywebview+vue

使用pywebview实现python与vue3的集成应用

目录说明

├── dist #python构建后的可执行程序目录 
├── python #后台python文件
├── web #前端vue文件
├── webdist #前端构建后的文件目录
├── README.md #项目说明
└── main.py Python主入口文件

一、前端项目

依赖安装

pnpm i

1 运行

pnpm dev

构建

pnpm build

二、PyWebView环境

获取python安装包(选择对应版本及系统)

安装依赖

pip install  pywebview

运行应用

#使用pnpm支持
#pnpm dev:py
#使用python命令运行
python main.py

三、调试与生成可执行文件

1 本地调试

  • 启动前端项目:pnpm dev
  • 启动pywebview:pnpm dev:py 或者直接使用python命令 python main.py

2 打包应用

  • 首页进行前端项目打包:pnpm build
  • 构建python可执行文件:pnpm build:py,或直接使用pyinstaller命令生成
#pnpm build:py
# 本地集成合体包
pyinstaller --onefile --add-data "webdist;dist" --icon "webdist/favicon.ico" --windowed main.py

参数说明:

  • --add-data "webdist;dist":将前端静态资源添加到程序目录
  • --icon "webdist/favicon.ico":添加自定义图标
  • 其他参数参考pyinstaller参数说明

扩展:Python环境搭建

环境与IDE

VSCode Python格式化插件

  • Black Formatter

程序运行界面

alt text

MIT License Copyright (c) 2025 路庆华 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Python客户端集成Vue示例,通过pywebview实现Pthon与vue的集成 展开 收起
Python
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/lqh4188/pywebview-vue.git
git@gitee.com:lqh4188/pywebview-vue.git
lqh4188
pywebview-vue
PywebviewVue
master

搜索帮助

371d5123 14472233 46e8bd33 14472233