Created
March 24, 2015 17:04
-
-
Save andik/17c9872d6bd5f0e3dbe0 to your computer and use it in GitHub Desktop.
package flask using node-webkit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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