How to run a SB-WebApp as a Desktop-Application

Share your advanced knowledge/code with the community.
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

How to run a SB-WebApp as a Desktop-Application

Post by Peter »

Hello,

here is a tip how to run a SpiderBasic-WebApp as an application on the desktop (Windows, Linux, MacOS):

Getting Started:

Download NW.js (https://nwjs.io/) and unpack it at a location of your choice.

Create a new folder named "www" in the unzipped folder.

Create a file called "app.js" in the main folder with the following content:

Code: Select all

var win = nw.Window.open('./www/index.html', {
  position: 'center',
  width: 1000,
  height: 800,
  focus: true
});
Also in the main folder create a file named "package.json" with the following content:

Code: Select all

{
  "name": "HelloWorld",
  "main": "app.js"
}
Create a new file in SpiderBasic:

Code: Select all

Debug "HelloWorld!"
Then select Compiler -> Create App -> Call Web from the menu bar.

Enter the following values:

App Name: HelloWorld
HTML filename: [pathtoyourNwJsfolder]/wwww/index. html
JavaScript filename: HelloWorld. js

Check "Copy SpiderBasic library" and "Enable debugger".

Press "Create App".

Then change to the NwJs folder and start the executable file there:

Image

SpiderBasic NwJs - Modules:

NW.js is easy to control from SpiderBasic. For this I have written some JavaScript wrappers in form of modules, which can be downloaded here: https://github.com/spiderbytes/NwJs

For example, if you want to resize the window, you can bind the NwJsWin.sbi module and call NwJsWin::ResizeTo() with the corresponding values.

Image

Since NW.js has a' built-in' NodeJS, you can also use appropriate commands (such as those of the filesystem) to communicate from SpiderBasic with the 'outside world' (SpiderBasic modules NwJsOs, NwJsFs, NwJsClipboard).

Just give it a try. :)

Have fun... Peter
Dirk Geppert
Posts: 282
Joined: Fri Sep 22, 2017 7:02 am

Re: How to run a SB-WebApp as a Desktop-Application

Post by Dirk Geppert »

Great! Lots of new possibilities! Thanks Peter!
Post Reply