我编写了一个python程序,代码如下:
class MainScreen(Widget):
res = True
plastic = True
paper = True
def __init__(self,**kwargs):
super(MainScreen,self).__init__(**kwargs)
self.animate()
class Warn(App):
def build(self):
return MainScreen()和.kv文件:
<MainScreen>:
FloatLayout:
size: root.width, root.height
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: "resources/bg.jpg"
Label:
text: "Do the thing"
color: 0,0,0,0.8
font_size: 100
pos_hint: {"center_x":0.50,"center_y":0.90}
Label:
text: "blabla"
font_size: 47
pos_hint: {"center_x":0.71,"center_y":0.37}
Image:
id: img1
source: "resources/img.jpg"
pos_hint: {"center_x":0.71,"center_y":0.50} 当我手动运行这个程序(在命令行中输入python3 main.py )时,它运行良好,背景图像显示。
但是,当我在crontab /home/pi/project/main.py :1017*** python3中放置以下行时,代码将运行,但没有显示背景图像(bg.jpg)。程序的其余部分工作正常,甚至其他映像(img.jpg)也会很好地加载,即使它与bg.jpg处于同一映射中。
发布于 2019-11-25 06:15:06
我终于修好了。由于某些原因,改变图像大小和图像类型(.jpg和png)解决了这个问题。
谢谢大家的帮助!
https://stackoverflow.com/questions/58960598
复制相似问题