用 aardio 创建一个窗体, 添加两个按钮,添加一个文本框。 点击按钮 1 时创建一个数组包含 从 221 到 12的数值, 将这个数组转换为 JSON , 然后将…
- User
用 aardio 创建一个窗体, 添加两个按钮,添加一个文本框。 点击按钮 1 时创建一个数组包含 从 221 到 12的数值, 将这个数组转换为 JSON , 然后将 JSON 与当前时间连接并输出到文本框,最后将文本框的内容保存到文件。
Assistant
使用 Aardio 创建窗体并实现功能
下面是一个使用 Aardio 创建窗体并实现您要求功能的完整代码示例:
// 创建窗体 const window = aardio.createWindow({ title: "数组处理示例", width: 400, height: 300 }); // 添加文本框 const textBox = window.addTextBox({ x: 20, y: 20, width: 360, height: 150, multiline: true, readOnly: true }); // 添加按钮1 const button1 = window.addButton({ x: 20, y: 190, width: 150, height: 30, text: "生成数组并保存" }); // 添加按钮2 const button2 = window.addButton({ x: 200, y: 190, width: 150, height: 30, text: "清除文本" }); // 按钮1的点击事件处理 button1.onClick = function() { // 创建从221到12的数组 const numbers = []; for (let i = 221; i >= 12; i--) { numbers.push(i); } // 转换为JSON const jsonData = JSON.stringify(numbers); // 获取当前时间 const currentTime = new Date().toLocaleString(); // 将JSON和时间连接 const outputText = `当前时间: ${currentTime}\n\n数组JSON: ${jsonData}`; // 输出到文本框 textBox.text = outputText; // 保存到文件 const fileName = `array_data_${new Date().getTime()}.txt`; aardio.saveFile(fileName, outputText); aardio.showMessage(`数据已保存到文件: ${fileName}`); }; // 按钮2的点击事件处理 button2.onClick = function() { textBox.text = ""; aardio.showMessage("文本已清除"); }; // 显示窗体 window.show();
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.