Closed psychemedia closed 4 years ago
Alternatively, the code block magic could accept a parameter that specifies the background to be used for that code.
ev3devsim
master that improves browser generality for background upload here. That may also improve accessibility?We can change the background from py by calling on js via the widget:
roboSim.js_init("""
document.getElementById("map").value = "Lollipop";
// Setting value doesn't seem to raise the event that kicks the loader in?
// So give it an explicit kick...
var event = new Event('change');
document.getElementById("map").dispatchEvent(event);
""")
For the magic, decorate with:
@magic_arguments.argument('--background', '-b', default='', help='Background selection')
and then call eg:
if args.background:
self.shell.user_ns[args.sim].js_init(f'''
var bgSelector = document.getElementById("map")
bgSelector.value = "{args.background}";
''')
BUT THIS DOESN"T WORK... the event doesn't fire to reset the image? Even with:
var event = new Event('change');
document.getElementById("map").dispatchEvent(event);
Ah - maybe it does by changing the event tracked from 'inputto
change`.
I can't figure out how to pass in names containing spaces, eg Background image.
Re: accessibility: provide support for an optional audible response that says which background is loaded. Maybe also allow a keyboard shortcut that says the name of the loaded background.
At the moment this is broken - the image files are hard coded by name in
templates/studio.js
and via a relative path to a./images
directory.Backgrounds available via the package need to be referenced by an appropriate path/
Some solution also needs to be found for allow users to load in their own background files. Originally this was done via an upload dialogue. Perhaps an alternative solution would be to path a local path name in via the<- the upload route via the background selection list is fine for now...%%sim_magic
call that loads the simulator?