Julia bindings for the webview library, allowing you to create desktop applications with web technologies.
using Pkg
Pkg.add("Webview")using Webview
wv = WebviewObj()
wv.navigate("https://julialang.org")
wv.run()using Webview
run_webview() do w
w.set_title("Test")
w.navigate("https://example.com")
endusing HTTP
using Webview
html = """
<!DOCTYPE html>
<html>
<body>
<h1>Hello from Julia Webview!</h1>
</body>
</html>
"""
wv = WebviewObj()
wv.navigate("data:text/html," * HTTP.escapeuri(html))
wv.run()using Webview
wv = WebviewObj()
wv.navigate("https://julialang.org")
wv.run()#!/usr/bin/env julia
using Webview
using JSON
using HTTP
# 创建HTML内容
html = raw"""
<!DOCTYPE html>
<html>
<body>
<h1>Julia-JavaScript Binding Demo</h1>
<button onclick="callJulia()">Call Julia</button>
<button onclick="callJuliaWithArgs(10, 20)">Add Numbers</button>
<div id="result"></div>
<script>
async function callJulia() {
const result = await window.hello();
document.getElementById('result').innerHTML = result;
}
async function callJuliaWithArgs(a, b) {
const result = await window.add(a, b);
document.getElementById('result').innerHTML = `Result: ${result}`;
}
function updateFromJulia(message) {
document.getElementById('result').innerHTML = message;
}
</script>
</body>
</html>
"""
# TODO
# 创建webview实例
w = WebviewObj(true)
# 定义要从JavaScript调用的Julia函数
function hello()
w.eval("console.log('Hello from Julia!')")
return "Hello from Julia!"
end
function add(a,b)
return a + b
end
# 绑定Julia函数
w.bind("hello", hello)
w.bind("add", add)
# 设置窗口属性
w.set_title("Julia-JavaScript Binding Demo")
w.set_size(640, 480)
# 加载HTML内容
w.navigate("data:text/html," * HTTP.escapeuri(html))
# 运行webview
w.run()
# Configure window
wv.set_title("Binding Demo")
wv.set_size(800, 600)
wv.navigate("data:text/html," * HTTP.escapeuri(html))
wv.run()using PackageCompiler
create_app(".", "compiled_app/bind_example";
force=true,
include_lazy_artifacts=true,
executables=["bind_example.jl" => "bind_example"])- 🚀 Create desktop applications using HTML, CSS, and JavaScript
- 📂 Load local HTML files or remote URLs
- 🔄 Bidirectional Julia-JavaScript communication
- 🖼️ Window size and title customization
- 🐛 Debug mode for development
- 💻 Cross-platform support (Windows, macOS, Linux)
- 📦 Standalone executable creation
WebView.jl/
├── src/
│ ├── WebView.jl # Main implementation
│ └── ffi.jl # Foreign Function Interface
├── examples/ # Example applications
├── test/ # Unit tests
└── README.md # Documentation
] test WebView- Test
# Run tests
julia -e 'using Pkg; Pkg.test("webview_julia")'
# Build documentation
# julia --project=docs/ docs/make.jl- Update Version in Project.toml
version = "x.y.z"- Trigger register bot by commit:
git commit -m "release: vx.y.z
@JuliaRegistrator register"
git pushCheck the examples/ directory for more examples:
- Basic window creation
- JavaScript interaction
- Custom HTML content
- Standalone application
- Window management
- Basic webview functionality
- Julia-JavaScript bindings
- Standalone executable support
- Prebuilt binaries for all platforms
- More comprehensive examples
- Documentation website
- Hot reload support
- Custom window decorations
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.