feat(board): python_pyodide下添加 Teachable Machine (待完善)

This commit is contained in:
王立帮
2025-09-18 16:30:56 +08:00
parent f9b7f4a13e
commit 8dbd1370db
6 changed files with 83 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ import {
import { KernelLoader } from '@basthon/kernel-loader';
import StatusBarImage from './statusbar-image';
import StatusBarFileSystem from './statusbar-filesystem';
import StatusBarTool from './statusbar-tool';
import LOADER_TEMPLATE from '../templates/html/loader.html';
@@ -55,6 +56,7 @@ export default class PythonShell {
this.kernel = kernel;
this.statusBarImage = StatusBarImage.init();
this.statusBarFileSystem = StatusBarFileSystem.init();
this.statusBarTool = StatusBarTool.init();
this.pythonShell = new PythonShell();
this.pyodide = window.pyodide;
this.interruptBuffer = new Uint8Array(new ArrayBuffer(1));

View File

@@ -0,0 +1,51 @@
import $ from 'jquery';
import { Msg } from 'blockly/core';
import {
PageBase,
HTMLTemplate,
StatusBarsManager,
Workspace
} from 'mixly';
import '../language/loader';
import STATUS_BAR_TOOL_TEMPLATE from '../templates/html/statusbar-tool.html';
export default class StatusBarTool extends PageBase {
static {
HTMLTemplate.add(
'html/statusbar/statusbar-tool.html',
new HTMLTemplate(STATUS_BAR_TOOL_TEMPLATE)
);
this.init = function () {
StatusBarsManager.typesRegistry.register(['tool'], StatusBarTool);
const mainWorkspace = Workspace.getMain();
const statusBarsManager = mainWorkspace.getStatusBarsManager();
statusBarsManager.add({
type: 'tool',
id: 'tool',
name: Msg.PYTHON_PYODIDE_TOOL,
title: Msg.PYTHON_PYODIDE_TOOL
});
statusBarsManager.changeTo('output');
return statusBarsManager.get('tool');
}
}
constructor() {
super();
const $content = $(HTMLTemplate.get('html/statusbar/statusbar-tool.html').render());
this.setContent($content);
}
init() {
super.init();
this.hideCloseBtn();
}
onMounted() { }
onUnmounted() { }
resize() { }
}