Я новичок в хаквопии и сталкивался с проблемами с тех пор, как я начал. Это тот, с которым я сейчас сталкиваюсь. Я обратился к этому, поместив свой скрипт в Android/App/SRC/Python. Placeholder.py практически тот же код, что и сценарий Python, который у меня есть ниже. < /P>
Future _analyzeImage() async {
// Show loading dialog
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => const AlertDialog(
content: Row(
children: [
CircularProgressIndicator(),
SizedBox(width: 20),
Text("Running analysis..."),
],
),
),
);
try {
// Load and execute the Python script
final pythonScript = await rootBundle.loadString('assets/python/placeholder.py');
final result = await Chaquopy.executeCode(pythonScript);
// Close loading dialog
Navigator.pop(context);
// Extract the result
String output = '';
if (result is Map) {
output = result['textOutput']?.toString() ?? 'No output';
} else {
output = result?.toString() ?? 'No result';
}
// Show result dialog
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Row(
children: [
Icon(Icons.check_circle, color: Colors.green),
SizedBox(width: 8),
Text('Analysis Result'),
],
),
content: Text(
output,
style: const TextStyle(fontSize: 16),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('OK'),
),
],
),
);
} catch (e) {
// Close loading dialog if still open
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
// Show simple error dialog
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Row(
children: [
Icon(Icons.error, color: Colors.red),
SizedBox(width: 8),
Text('Error'),
],
),
content: Text('Failed to run analysis: ${e.toString()}'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('OK'),
),
],
),
);
}
}
< /code>
Теперь вот код Python. < /p>
import random
def get_random_number():
return random.randint(1, 100)
< /code>
Как это исправить? Приносим извинения, если когда -либо это основная проблема. Я действительно новичок в хакуопии.
Заранее.
Подробнее здесь: https://stackoverflow.com/questions/796 ... bute-maint
Сложность в хакуопии | AttrubtError: модуль «Скрипт» не имеет атрибута «MANEXTEXTCODE» ⇐ Android
Форум для тех, кто программирует под Android
1749471452
Anonymous
Я новичок в хаквопии и сталкивался с проблемами с тех пор, как я начал. Это тот, с которым я сейчас сталкиваюсь. Я обратился к этому, поместив свой скрипт в Android/App/SRC/Python. Placeholder.py практически тот же код, что и сценарий Python, который у меня есть ниже. < /P>
Future _analyzeImage() async {
// Show loading dialog
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => const AlertDialog(
content: Row(
children: [
CircularProgressIndicator(),
SizedBox(width: 20),
Text("Running analysis..."),
],
),
),
);
try {
// Load and execute the Python script
final pythonScript = await rootBundle.loadString('assets/python/placeholder.py');
final result = await Chaquopy.executeCode(pythonScript);
// Close loading dialog
Navigator.pop(context);
// Extract the result
String output = '';
if (result is Map) {
output = result['textOutput']?.toString() ?? 'No output';
} else {
output = result?.toString() ?? 'No result';
}
// Show result dialog
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Row(
children: [
Icon(Icons.check_circle, color: Colors.green),
SizedBox(width: 8),
Text('Analysis Result'),
],
),
content: Text(
output,
style: const TextStyle(fontSize: 16),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('OK'),
),
],
),
);
} catch (e) {
// Close loading dialog if still open
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
// Show simple error dialog
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Row(
children: [
Icon(Icons.error, color: Colors.red),
SizedBox(width: 8),
Text('Error'),
],
),
content: Text('Failed to run analysis: ${e.toString()}'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('OK'),
),
],
),
);
}
}
< /code>
Теперь вот код Python. < /p>
import random
def get_random_number():
return random.randint(1, 100)
< /code>
Как это исправить? Приносим извинения, если когда -либо это основная проблема. Я действительно новичок в хакуопии.
Заранее.
Подробнее здесь: [url]https://stackoverflow.com/questions/79658825/difficulty-in-chaquopy-attributeerror-module-script-has-no-attribute-maint[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия