Electron.jl wraps the cross-platform desktop application framework Electron. You can use it to build GUI applications in julia.
Blink.jl provides similar functionality (and was a major inspiration for this package!). The main difference between the two packages is that Electron.jl opts for a more minimalistic feature set than Blink.jl. Here are some key differences between the two packages:
- Electron.jl does not have any web server functionality.
- Electron.jl uses named pipes for the communication between julia and the electron process (no more firewall warnings!).
- Electron.jl doesn't integrate with the Juno stack of packages, Blink.jl does in some way (that I don't understand).
- Electron.jl has a high test coverage.
- Electron.jl always installs a private copy of Electron during the build phase.
You can install the package with:
Electron.jl introduces two fundamental types:
Application represents a running electron application,
Window is a visible UI window. A julia process can have arbitrarily many applications running at the same time, each represented by its own
Application instance. If you don't want to deal with
Applications you can also just ignore them, in that case Electron.jl will create a default application for you automatically.
To create a new application, simply call the corresponding constructor:
using Electron app = Application()
To create a new window in an existing application, use the
using Electron, URIParser app = Application() win = Window(app, URI("file://main.html"))
Note that you need to pass a URI that points to an HTML file to the
Window constructor. This HTML file will be displayed in the new window.
You can update pre-existing
Window using function
load(win, URI("http://julialang.org")) load(win, """ <img src="https://raw.githubusercontent.com/JuliaGraphics/julia-logo-graphics/master/images/julia-logo-325-by-225.png"> """)
You can also call the
Window constructor without passing an
Application, in that case Electron.jl creates a default application for you:
using Electron, URIParser win = Window(URI("file://main.html"))
run function and pass an
Application instance as the first argument:
using Electron, URIParser app = Application() result = run(app, "Math.log(10)")
The second argument of the
Window instance as the first argument to
using Electron, URIParser win = Window(URI("file://main.html")) result = run(win, "Math.log(10)")
sendMessageToJulia. On the julia side, every window has a
Channel for these messages. You can access the channel for a given window with the
msgchannel function, and then use the standard julia API to take messages out of this channel:
using Electron win = Window() result = run(win, "sendMessageToJulia('foo')") ch = msgchannel(win) msg = take!(ch) println(msg)
The following packages currently use Electron.jl:
Please add any other packages that depend on Electron.jl to this list via a pull request!