Skip to content

Instantly share code, notes, and snippets.

@andik
Created March 24, 2015 17:04
Show Gist options
  • Save andik/17c9872d6bd5f0e3dbe0 to your computer and use it in GitHub Desktop.
Save andik/17c9872d6bd5f0e3dbe0 to your computer and use it in GitHub Desktop.
package flask using node-webkit
You can create a loading page and render the actual app after the web server has started.
The loading page (loading.html) will load a js file that launches your actual application page as a hidden window and you can then show it when the server is running.
<script>
var currentWindow = gui.Window.get(); // Get reference to loading.html
var exec = require('child_process').execFile;
exec('home.py', {cwd:'.'}, function (error, stdout, stderr){ // Runs your python code
var appWindow = gui.Window.open('app.html', // Starts your application
{ width: 800,
height: 600,
position: 'center',
focus: false,
transparent: true // This hides the application window
}
);
appWindow.on('loaded', function() { // Waits for application to be loaded
currentWindow.close({force: 'true'}); // Closes loading.html
appWindow.show(); // Shows app.html
appWindow.focus(); // Set the focus on app.html
});
});
</script>
Anyway that is the gist of it, but you may need to make changes for your particular setup. Hope it helps.
{
"name": "pythonApp",
"version": "0.0.0",
"main": "loading.html",
"window": {
"title": "App Name",
"width": 800,
"height": 600,
"position": "center",
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment