Python bindings for Sciter
Check this page for other language bindings (Delphi / D / Go / .NET / Python / Rust).
Sciter is an embeddable multiplatform HTML/CSS/script engine with GPU accelerated rendering designed to render modern desktop application UI. It's a compact, single dll/dylib/so file (4-8 mb) engine without any additional dependencies.
Check the screenshot gallery of the desktop UI examples.
Physically Sciter is a mono library which contains:
Internally it contains the following modules:
<input>
, <select>
, <textarea>
, etc.Sciter supports all standard elements defined in HTML5 specification with some additions. CSS is extended to better support the Desktop UI development, e.g. flow and flex units, vertical and horizontal alignment, OS theming.
Sciter SDK comes with a demo "browser" with a builtin DOM inspector, script debugger and documentation viewer:
Check https://sciter.com website and its documentation resources for engine principles, architecture and more.
bin.win/x64
, bin.osx
or bin.lnx/x64
) and install Sciter shared library to your LIBRARY_PATH.python3 setup.py install
or pip install pysciter
.python3 examples/minimal.py
. Also you can run script from zip archive directly: python3 ./archive.zip
:)Minimal sciter app is extremely small:
import sciter
if __name__ == '__main__':
frame = sciter.Window(ismain=True, uni_theme=True)
frame.load_file("minimal.htm")
frame.expand()
frame.run_app()
It looks similar to this:
In respect of tiscript or JavaScript functions calling:
answer = self.call_function('script_function', "hello, python!", "and", ["other", 3, "arguments"])
Calling python from script can be implemented as following:
def GetNativeApi(): # called from sciter.EventHandler.on_script_call
def on_add(a, b):
return a + b
def on_sub(a, b):
raise Exception("sub(%d,%d) raised exception" % (a, b))
api = { 'add': on_add, # plain function
'sub': on_sub, # raise exception at script
'mul': lambda a,b: a * b } # lambdas supported too
return api
So, we can access our api now from TIScript:
// `view` represents window where script is runnung.
// `stdout` stream is a standard output stream (shell or debugger console, for example)
var api = view.GetNativeApi();
// returned `api` object looks like {add: function(a,b) { return a + b; }};
stdout.println("2 + 3 = " + api.add(2, 3));
or from JavaScript:
// `Window.this` represents the window where this script is running.
const api = Window.this.GetNativeApi();
console.log("2 + 3", api.add(2, 3));
Check pysciter/examples folder for more complex usage.
sciter::script_error
and sciter::native_function
support.sdk/bin/packfolder
.Python 3.x.
Bindings library licensed under MIT license. Sciter Engine has the own license terms and end used license agreement for SDK usage.