当前位置:网站首页>移动端 开源低代码工具 beeware 和 kivy
移动端 开源低代码工具 beeware 和 kivy
2022-08-04 09:57:00 【Leibniz infinity sml】
移动端 开源低代码工具 beeware 和 kivy
kivy
#anaconda3 @ win10
python --version
#Python 3.8.5
pip install virtualenv
python -m virtualenv kivy_venv
#若virtualenv 报错, 试试:#conda create python=3.8 -n kivy_venv
kivy_venv\Scripts\activate.bat
##: conda activate kivy_venv
python -m pip install "kivy[base]" kivy_examples
#显示例子
python kivy_venv\share\kivy-examples\demo\showcase\main.py
#centos 8 x64 stream @"win10x64 hyperv"
/home/z/python_root/Miniconda3-4.10.3/bin/activate kivy_venv
cd /home/z/
git clone https://github.com/kivy/buildozer.git
cd buildozer
sudo python setup.py install
cd /home/z/python_root/Miniconda3-4.10.3/envs/kivy_venv/share/kivy-examples/demo/
buildozer init
#安装buildozer所需依赖
#https://buildozer.readthedocs.io/en/latest/installation.html#targeting-android
buildozer android release
#编译***python***时, 报错 ctypes 找不到,
beeware
#构建好py虚拟环境
conda create python=3.8 -n beeware_venv
conda activate beeware_venv
pip install briefcase
briefcase new
#一路默认 novelz
#novelz/src/novelz/*.py
#如果要用pycharm 打开novelz/src/novelz/, 则应该安装: pip install toga==v0.3.0.dev35
#set JAVA_HOME=D:\jdk1.8.0_111
briefcase create android
briefcase build android
beeware win10 手动激活conda环境
可以在cmd.exe下, 执行 D:\Miniconda3\Scripts\activate.bat , 激活base环境. 再执行conda activate beeware_venv 激活bee
#打开一个cmd窗口执性以下内容:
D:\Miniconda3\Scripts\activate.bat
conda activate beeware_venv
echo %PATH%
#手工找出环境变量PATH中beeware_venv的部分, 这就是下面 git bash中手工激活beeware_venv的脚本
git bash 执行以下命令,手工激活 beeware_venv
beeware_env_path=/d/Miniconda3/envs/beeware_venv:/d/Miniconda3/envs/beeware_venv/Library/mingw-w64/bin:/d/Miniconda3/envs/beeware_venv/Library/usr/bin:/d/Miniconda3/envs/beeware_venv/Library/bin:/d/Miniconda3/envs/beeware_venv/Scripts:/d/Miniconda3/envs/beeware_venv/bin
export PATH=$PATH:$beeware_env_path
beeware create android 下载慢解决: github镜像、下载地址改本地
Python-3.8-Android-support.b5.zip 下载地址改为本地
briefcase create android
#create步会卡在下载 https://briefcase-support.org/python?platform=android&version=3.8
# 手工下载 放到路径 /home/z/beeware_demo/Python-3.8-Android-support.b5.zip
#修改 /home/z/python_root/Miniconda3-4.10.3/envs/beeware_venv/lib/python3.8/site-packages/briefcase/commands/create.py : install_app_support_package 函数
#将
# support_package_url = app.support_package
#改成:
# support_package_url = "/home/z/beeware_demo/Python-3.8-Android-support.b5.zip"
#再次运行briefcase create android可以通过
briefcase-android-gradle-template.git 改为镜像地址
#如果 它慢: "Using app template: https://github.com/beeware/briefcase-android-gradle-template.git, branch 3.8"
#修改 /home/z/python_root/Miniconda3-4.10.3/envs/beeware_venv/lib/python3.8/site-packages/briefcase/commands/create.py
""" @property def app_template_url(self): """The URL for a cookiecutter repository to use when creating apps.""" #return f"https://github.com/beeware/briefcase-{self.platform}-{self.output_format}-template.git" #本行改成 github镜像加速地址:, 即可解决慢问题 return f"https://github.91chi.fun//https://github.com/beeware/briefcase-{self.platform}-{self.output_format}-template.git" """
beeware build android 错误解决
centos8stream x64下beeware build android报错: libssl.so not recognized as a valid object file
briefcase build android
#运行中
#有以下报错:
""" /home/z/.briefcase/tools/android_sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip: error: '/home/z/beeware_weather/weather/android/gradle/weather/app/build/intermediates/merged_native_libs/debug/out/lib/x86_64/libssl.so': The file was not recognized as a valid object file /home/z/.briefcase/tools/android_sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip: error: '/home/z/beeware_weather/weather/android/gradle/weather/app/build/intermediates/merged_native_libs/debug/out/lib/x86_64/libcrypto.so': The file was not recognized as a valid object file """
#解决
cd /home/z/beeware_wth/wth/android/gradle/wth/app/build/intermediates/merged_native_libs/debug/out/lib/armeabi-v7a/
unlink libcrypto.so
unlink libssl.so
ln -s `pwd`/libcrypto1.1.so `pwd`/libcrypto.so
ln -s `pwd`/libssl1.1.so `pwd`/libssl.so
win10下 beeware build android报错 : utf8 codec can’t decode byte 0xd3
python --version
#Python 3.8.13
briefcase --version
#0.3.8
briefcase build android
#报错详情
""" > Task :app:compileDebugJavaWithJavac Exception in thread D:\weather\android\gradle\weather\gradlew.bat output streamer: Traceback (most recent call last): File "D:\Miniconda3\envs\beeware_venv\lib\threading.py", line 932, in _bootstrap_inner self.run() File "D:\Miniconda3\envs\beeware_venv\lib\threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "D:\Miniconda3\envs\beeware_venv\lib\site-packages\briefcase\integrations\subprocess.py", line 404, in _stream_output_thread print(popen_process.stdout.readline()) File "D:\Miniconda3\envs\beeware_venv\lib\codecs.py", line 323, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 95: invalid continuation byte """
#解决办法:
export PYTHONIOENCODING=utf-8
beeware example
app.py
""" A simple weather app. """
from pprint import pprint
import toga
from toga.style import Pack
from toga.style.pack import COLUMN, ROW, LEFT, RIGHT
import httpx
TOKEN = "7eadee4312991c2935a8f9109645f19e" #Enter your weatherstack.com token here.
#http://api.weatherstack.com/current?access_key=7eadee4312991c2935a8f9109645f19e&query=New%20York
BASE_URL="http://api.weatherstack.com/current"
class weatherman(toga.App):
def startup(self):
""" Construct and show the Toga application. Usually, you would add your application to a main content box. We then create a main window (with a name matching the app), and show the main window. """
main_box = toga.Box(style=Pack(direction=COLUMN))
location_label = toga.Label("Location", style=Pack(padding=(0, 5)))
self.location_input = toga.TextInput(style=Pack(flex=1))
location_box = toga.Box(style=Pack(direction=ROW, padding=5))
location_box.add(location_label)
location_box.add(self.location_input)
weather_box_label = toga.Label("Weather Results", style=Pack(padding=(0, 5)))
self.weather_box_input = toga.TextInput(readonly=True, style=Pack(flex=1))
weather_box = toga.Box(style=Pack(direction=ROW, padding=5))
weather_box.add(weather_box_label)
weather_box.add(self.weather_box_input)
button = toga.Button("Fetch weather", on_press=self.weather, style=Pack(padding=5))
main_box.add(location_box)
main_box.add(button)
main_box.add(weather_box)
self.main_window = toga.MainWindow(title=self.formal_name)
self.main_window.content = main_box
self.main_window.show()
def weather(self, widget):
params = dict(access_key=TOKEN, query=self.location_input.value)
resp = httpx.get(BASE_URL, params=params).json()
try:
self.weather_box_input.value = f'The weather report for {
resp["request"]["query"]} \
{
resp["current"]["temperature"]} \
{
resp["current"]["weather_descriptions"][0]} \
{
resp["current"]["feelslike"]}'
except ValueError:
self.weather_box_input.value = "Location unknown!"
def main():
return weatherman()
pyproject.toml
[tool.briefcase.app.wth]
formal_name = "wth"
description = "My first application"
icon = "src/wth/resources/wth"
sources = ['src/wth']
requires = [
'httpx~=0.23.0' #这行是新增的, 因为app.py中用到了此库
]
cd /home/z/
mkdir /home/z/beeware_demo_wth
cd /home/z/beeware_demo_wth
briefcase new
#应用名为:wth
cd /home/z/beeware_demo_wth/wth/
vi /home/z/beeware_demo_wth/wth/src/app.py
#替换为上面app.py的内容
briefcase create android
#注意慢问题, 参照上一节
#将会创建android项目结构 :/home/z/beeware_demo_wth/wth/android/
briefcase build android
#会报错 libcrypt.so, libssl.so找不到, 解决办法上一节已经写了. 这里复制来
cd /home/z/beeware_wth/wth/android/gradle/wth/app/build/intermediates/merged_native_libs/debug/out/lib/armeabi-v7a/
unlink libcrypto.so
unlink libssl.so
ln -s `pwd`/libcrypto1.1.so `pwd`/libcrypto.so
ln -s `pwd`/libssl1.1.so `pwd`/libssl.so
#再build一次即可
briefcase build android
#下载apk, 到手机上试一下:
/home/z/beeware_demo_wth/wth/android/gradle/wth/app/build/outputs/apk/debug/app-debug.apk
边栏推荐
- 罗克韦尔AB PLC RSLogix5000中定时器指令使用方法介绍
- How Oracle for current library or certain library data on the same server number?
- Win7C盘不能扩大怎么办?Win7C盘扩展卷不能点怎么解决
- 数据万象内容审核 — 共建安全互联网,专项开展“清朗”直播整治行动
- 二叉树的基础练习
- safe-point(safepoint 安全点) 和 safe-region(安全区域)「建议收藏」
- sync-diff-inspector 使用实践
- TiFlash 源码阅读(五) DeltaTree 存储引擎设计及实现分析 - Part 2
- LVGL's multi-language conversion tool -- a good assistant for font settings
- XCTF-reverse-signin
猜你喜欢
MindSpore:Ascend运行出现问题
Post-94 Byte P7 posted the salary slip: It's really good to make up for this...
MindSpore:Batchnorm only support nchw input!
MindSpore:【model_zoo】【resnet】尝试用THOR优化器运行时报cannot import name ‘THOR‘
XCTF-easy_Maze
MindSpore:model.train中的dataset_sink_mode该如何理解?
[Punctuality Atom STM32 Serial] Chapter 4 STM32 First Experience Excerpted from [Punctual Atom] MiniPro STM32H750 Development Guide_V1.1
二叉树与堆
Apache APISIX 2.15 版本发布,为插件增加更多灵活性
被Win11安全中心误删除的文件怎么恢复?
随机推荐
[论文阅读] Unpaired Image-to-Image Translation Using Adversarial Consistency Loss
leetcode动态规划系列(求路径篇)
canvas画图时的bug记录
浅聊偏函数
MindSpore:mirrorpad算子速度过慢的问题
IDEA 自动导入的配置(Auto import)
Win10电脑经常发出叮咚声音怎么关闭
I am 37 this year, and I was rushed by a big factory to...
无线Mesh自组网方案,CV5200无线模组应用,支持高清数据远距离传输
双指针方法
冰蝎工具开发实现动态二进制加密WebShell
无代码平台附件上传入门教程
v-model原理,在“radio”、“checkbox”、“select”、修饰符
2022-08-03 第六小组 瞒春 学习笔记
JS工厂模式_工厂模式进行封装
多媒体和物联网技术让版本“活”起来 129张黑胶唱片“百年留声”
二叉树与堆
关于技术学习的6个观点
JDBC知识点
leetcode经典例题——49.字母异位词分组