Skip to content

support different pyodide versions #328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 11, 2022
Prev Previous commit
Next Next commit
auto add global config if there's no config set in the page
  • Loading branch information
fpliger committed May 7, 2022
commit 271024a41f23719f4c73262ae1237f03a110dd2b
6 changes: 5 additions & 1 deletion pyscriptjs/examples/simple_clock.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
<div id="outputDiv2" class="font-mono"></div>
<div id="outputDiv3" class="font-mono"></div>
<py-script output="outputDiv">
# demonstrates how use the global PyScript pyscript_loader
# to send operation log messages to it
pyscript_loader.log("HI")
import utils
utils.now()
Expand All @@ -44,7 +46,9 @@
out3.write("It's espresso time!")
else:
out3.clear()
#pyscript_loader.close()

# close the global PyScript pyscript_loader
pyscript_loader.close()
pyscript.run_until_complete(foo())
</py-script>
</body>
Expand Down
5 changes: 3 additions & 2 deletions pyscriptjs/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@
}

// now we call all post initializers AFTER we actually executed all page scripts
loader.log("Running post initializers...")
loader.log("Running post initializers...");

if (appConfig_ && appConfig_.autoclose_loader) {
loader.remove();
loader.close();
console.log("------ loader closed ------");
}

setTimeout(() => {
Expand Down
1 change: 1 addition & 0 deletions pyscriptjs/src/components/pyconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class PyConfig extends BaseEvalElement {
};
}
appConfig.set(this.values);
console.log("config set", this.values);
}

log(msg: string){
Expand Down
8 changes: 7 additions & 1 deletion pyscriptjs/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { PyLoader } from './components/pyloader';
import { globalLoader } from './stores';
import { PyConfig } from './components/pyconfig';


const xPyScript = customElements.define('py-script', PyScript);
const xPyRepl = customElements.define('py-repl', PyRepl);
const xPyEnv = customElements.define('py-env', PyEnv);
Expand All @@ -25,6 +24,13 @@ const xPyLoader = customElements.define('py-loader', PyLoader);
const xPyConfig = customElements.define('py-config', PyConfig);


// As first thing, loop for application configs
const config = document.querySelector('py-config');
if (!config){
const loader = document.createElement('py-config');
document.body.append(loader);
}

// add loader to the page body
const loader = document.createElement('py-loader');
document.body.append(loader);
Expand Down