Use any web browser or WebView as GUI, with your preferred language in the backend and HTML5 in the frontend, all in a lightweight portable lib.
Go to file
2021-09-16 15:29:16 +03:00
.github/workflows Update cmake.yml 2021-07-13 18:31:59 -04:00
cwebui Supporting MSVC19 2021-07-13 19:16:55 -03:00
examples Supporting MSVC19 2021-07-13 19:16:55 -03:00
include/webui add array headers 2021-09-16 15:29:16 +03:00
src fix browser executions to use external shell 2021-09-16 15:27:35 +03:00
test Update WebUI to v1.0.20 2021-07-04 23:05:43 -03:00
.gitignore Clearing Commits History 2021-03-20 19:53:42 -03:00
CMakeLists.txt Supporting MSVC19 2021-07-13 19:16:55 -03:00
LICENSE Clearing Commits History 2021-03-20 19:53:42 -03:00
README.md Supporting MSVC19 2021-07-13 19:16:55 -03:00
screenshot.png Clearing Commits History 2021-03-20 19:53:42 -03:00

WebUI

N|Solid

Build Status

WebUI is a free and open source GUI library that use any installed web browser as your user interface. Basically you can transform an basic console app or any Python script to a nice GUI application, in a easy way.

Why WebUI?

First, web technologies is everywhere now, and web browsers today have everything a modern UI need, your application will look nicer and multi-platform.

How its work?

Basically this library use latest web server and WebSocket standards to maintaine the communication in binary mode between the web browser (UI) and your application. You receive any click events, and of course you can send data or executing JavaScript code.

How I can use it?

  • Include one header file:
#include <webui/webui.hpp>
  • Set your HTML code
const std::string html = R"V0G0N(
<!DOCTYPE html>
<html>
	<head>
		<title>My first WebUI app</title>
	</head>
	<body>
		<h1>Welcome to WebUI!</h1>
		<button id="MyButtonID">Click on me!</button>
	</body>
</html>
)V0G0N";
  • Create a window object
webui::window my_window(&html);
  • Create your handler function
void my_handler(webui::event e){

    std::cout << "You clicked on a button!" << std::endl;
}
  • Bind your HTML element with your handler function
my_window.bind("MyButtonID", my_handler);
  • Show the window!
my_window.show();
  • Make infinit loop and wait for all windows to close
std::thread ui(webui::loop);
ui.join();

You can also show the window using a specific web browser

if(!my_window.show(webui::browser::firefox))    // If Firefox not installed
    my_window.show();                           // then try other web browsers.

Python

def my_function():
    print('You clicked on the first button!')

def my_function_two():
    print('You clicked on the second button!')

# Create a window object
MyWindow = WebUI()

# Bind am HTML element ID with a python function
MyWindow.bind('MyButtonID1', my_function)
MyWindow.bind('MyButtonID2', my_function_two)

# Show the window
MyWindow.show(my_html)

# Wait unitil all windows are closed
MyWindow.loop()

print('Good! All windows are closed now.')
sys.exit(0)

Complete examples

Please see examples folder.

Features

  • C++ 20
  • Lightweight and fast binary mode communication
  • One header file
  • Multiplatform & Multi Browser
  • Private user browser profiles
  • Customized app mode look & feel

Status

OS Browser Status
Windows Firefox Supported
Windows Chrome Supported
Windows Edge Supported
Linux Firefox Supported
Linux Chrome Supported
macOS Firefox Supported
macOS Chrome Supported
macOS Safari Under development

How to use pre-compiled version ?

Build from source - Windows

  • [ ! ] Microsoft Visual Studio 2017 is not supported.
  • Windows SDK 10x. You can download it from http://microsoft.com
  • Microsoft Visual Studio 2019 (or build tools 2019).
  • CMake +3.13.0. You can download it from https://cmake.org/download
  • Boost +1.76
  • Python 3.8 (only if you want cWebUI).

Using MSVC

git clone https://github.com/alifcommunity/webui.git
cd webui
mkdir build
cd build

Generate Visual Studio 2019 solution

cmake .. -G "Visual Studio 16 2019" -DBOOST_ROOT=C:/local/boost_1_76_0 -DBOOST_LIBRARYDIR=C:/local/boost_1_76_0/lib64-msvc-14.2 -DCMAKE_BUILD_TYPE:STRING=Release

Generate Makefile for Microsoft Visual Studio build tools 2019.

cmake .. -G "NMake Makefiles" -DBOOST_ROOT=C:/local/boost_1_76_0 -DBOOST_LIBRARYDIR=C:/local/boost_1_76_0/lib64-msvc-14.2 -DCMAKE_BUILD_TYPE:STRING=Release
nmake

Build cWebUI

nmake cwebui

Using MinGW

git clone https://github.com/alifcommunity/webui.git
cd webui
mkdir build
cd build
cmake .. -G "MinGW Makefiles"
mingw32-make

Build from source - Linux

  • C++20 compiler (GCC/Clang): sudo apt install build-essential
  • Boost lib +1.70.0: sudo apt install libboost-all-dev
  • CMake +3.15.0: sudo apt install cmake
  • Python 3.8 (only if you want cWebUI).
git clone https://github.com/alifcommunity/webui.git
cd webui
mkdir build
cd build
cmake ..
make
sudo make install

Build cWebUI if needed

make cwebui

Build from source - macOS

  • Clang
  • [!] Comming soon!

License

GNU General Public License v3.0