WebView is a powerful Ring library that allows you to create modern, cross-platform desktop applications using web technologies for the frontend, while using Ring as the backend. It provides a simple and intuitive API for building beautiful graphical user interfaces.
This project is made possible by the tiny webview library.
- Cross-Platform: Build applications for Windows, macOS, Linux, and FreeBSD from a single codebase.
- Modern UI: Use familiar web technologies to design your user interface.
- Two-Way Binding: Seamlessly call Ring functions from JavaScript and vice-versa.
- Easy to Use: A simple and clean API makes it easy to get started.
Follow these instructions to get the WebView library up and running on your system.
- Ring: Ensure you have Ring language version 1.24 or higher installed.
Click here for instructions on
Linux
The compiled Linux library in this package requires GTK 4 and WebkitGTK 6.
Click here for instructions on
Windows
The compiled Windows library in this package does not bundle any webview version with itself but rather uses the system-installed one.
The Microsoft Edge WebView2 runtime is required to be installed on the system for any version of Windows before Windows 11. To manually update or install the latest version, follow the steps here.
Click here for instructions on
FreeBSD
The compiled FreeBSD library in this package requires WebKitGTK 6.
- FreeBSD systems:
sudo pkg install webkit2-gtk_60
Click here for instructions on
macOS
The compiled macOS library in this package uses the built-in WebKit framework.
- macOS systems: No additional dependencies required. The WebKit framework is included with macOS.
- Install the library using RingPM:
ringpm install webview from ysdragon
Creating a basic WebView application is straightforward. Hereβs a simple example:
# Load the webview library
load "webview.ring"
# Create a new WebView instance.
oWebView = new WebView()
oWebView {
# Set the title of the native window.
setTitle("My First WebView App")
# Set the size of the window (width, height, hint).
# WEBVIEW_HINT_NONE allows the window to be resized.
setSize(800, 600, WEBVIEW_HINT_NONE)
# Load HTML content into the webview.
setHtml(`<h1>Welcome to Ring WebView!</h1>`)
# Run the main event loop. This will block until the window is closed.
run()
}
# This message will be displayed after the webview window is closed.
see "Application Closed." + nl
This code snippet creates a window, sets its title and size, loads some HTML, and runs the application loop.
For more advanced examples, see the examples/
directory.
For a detailed list of all available functions, classes, and methods, please refer to our API reference documentation.
For practical examples and guides on how to use the library, check out our Usage Guide.
If you want to contribute to the development of Ring WebView or build it from source, follow these steps.
- CMake: Version 3.16 or higher.
- C Compiler: A C compiler compatible with your platform (e.g., GCC, Clang, MSVC).
- Ring: You need to have the Ring language source code available on your machine.
-
Clone the Repository: Clone the WebView repository to your local machine.
git clone https://github.com/ysdragon/webview.git --recursive
NOTE: Skip this step if you have already installed the library using RingPM.
-
Set the
RING
Environment Variable: Before running CMake, you must set theRING
environment variable to point to the root directory of the Ring language source code.-
Windows
- Command Prompt
set RING=X:\path\to\ring
- PowerShell
$env:RING = "X:\path\to\ring"
- Command Prompt
-
Unix
export RING=/path/to/ring
-
-
Configure with CMake: Create a build directory and run CMake from within it.
mkdir build cd build cmake ..
-
Build the Project: Compile the source code using the build toolchain configured by CMake (e.g., Make, Ninja).
cmake --build .
The compiled library will be placed in the lib/<os>/<arch>
directory.
Contributions are welcome! If you have ideas for improvements or have found a bug, please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE
file for details.