如何解决无限循环:“尝试首次构建 kivy 以获取自定义 cython 文件:这预计会失败......工作:kivy/graphics/fbo.c:1:xx:警告:nul......”
我已经构建了一个小推车,我可以使用我使用 Kivy 用 Python 编写的应用程序(下面的代码)来控制它,但是当在虚拟 Linux 机器中使用 Buildozer 和以下命令时(Android 手机通过 USB 插入我的计算机启用调试):
$ buildozer android debug deploy run logcat
它仍然停留在以下部分:
[INFO]: -> running python3 -c import sys; print(sys.path)
[INFO]: Trying first build of kivy to get cython files: this is expected to fail
[INFO]: -> running python 3 setup.py build_ext -v
working: kivy/graphics/fbo.c:1:xxxxxxx: warning nul...(and 38 more)
除了 xxxxxxx 之外,整个消息在大约 1.5 小时内保持不变,这是一个不断增加的数字,最近达到了七位数字。
main.py
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.core.window import Window
import socket
kv = """
Screen:
MDLabel:
text: ""
id: txt
pos_hint: {'center_x': 0.5,'center_y': 0.85}
halign: 'center'
MDIconButton:
id: socket_connect
icon: "cellphone-off"
pos_hint: {"center_x": .9,"center_y": .9}
on_press:
app.socket_connect()
MDFillRoundFlatButton:
pos_hint: {'center_x': 0.5,'center_y': 0.27}
width: dp(150)
height: dp(150)
md_bg_color: 0,1,1
on_press:
app.send_direction(0,1)
on_release:
app.send_direction(0,0)
MDFillRoundFlatButton:
pos_hint: {'center_x': 0.5,'center_y': 0.1}
width: dp(150)
height: dp(150)
md_bg_color: 1,1
on_press:
app.send_direction(2,0)
MDFillRoundFlatButton:
pos_hint: {'center_x': 0.2,'center_y': 0.1}
width: dp(150)
height: dp(150)
md_bg_color: 0,1
on_press:
app.send_direction(1,0)
MDFillRoundFlatButton:
pos_hint: {'center_x': 0.8,1
on_press:
app.send_direction(3,0)
"""
class Main(MDApp):
data = {"direction": 0,"speed": 0,"autodrive": 0}
Window.size = (1080 / 2,1920 / 2)
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
def socket_connect(self):
button = self.root.ids.socket_connect
button.icon = "cellphone_cog"
label = self.root.ids.txt
try:
self.s.connect(("charlie.local",5432))
label.text = "Socket successfully connected!"
button.icon = "cellphone-sound"
except:
label.text = "Socket connection unsuccessful."
button.icon = "cellphone-off"
return
def send_direction(self,direction,speed):
label = self.root.ids.txt
message = "d: " + str(direction) + ",s: " + str(speed)
label.text = message
self.data["direction"] = direction
self.data["speed"] = speed
message = str(self.data["direction"])+str(self.data["speed"])+str(self.data["autodrive"])
try:
self.s.send(message.encode("utf-8"))
except:
label.text = "Socket not connected."
def action(self):
label = self.root.ids.txt
label.text = "This text is displayed after pressing button"
def build(self):
return Builder.load_string(kv)
Main().run()
当我使用 PyCharm 在我的 Windows PC 上运行该应用程序时,它运行良好。
任何帮助将不胜感激!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。