我已经通过这个路径在android中添加了一些txt文件 /data/data/package-name/files/app/filefolder/file.txt
txt 文件与main.py类似在同一目录中/same_directory_with_main.py/filefolder/file.txt
基于这种经验,我正在尝试在我的应用程序中添加一些自定义字体。我创建目录的方式与添加 txt 文件的方式完全相同。
部分 main.py
from kivy.config import Config
Config.set('kivy', 'default_font', [
'/data/data/org.test.tubuc/files/app/font/NanumSquareR.ttfs',
'/data/data/org.test.tubuc/files/app/font/NanumSquareL.ttfs',
])
Run Code Online (Sandbox Code Playgroud)
但 logcat 说找不到字体路径。这里是日志。
09-24 10:47:57.506 18392 18581 I python : ('Android kivy bootstrap done. __name__ is', '__main__')
09-24 10:47:57.540 18392 18581 I python : ['/data/user/0/org.test.tubuc/files/app/lib/python2.7/site-packages', '/data/user/0/org.test.tubuc/files/app/lib/site-python']
09-24 10:47:57.540 18392 18581 I python : AND: Ran string
09-24 10:47:57.540 18392 18581 I python : Run user program, change dir and execute entrypoint
09-24 10:47:57.650 18392 18581 I python : …Run Code Online (Sandbox Code Playgroud) 我想按 排列此列表list[i][1]。
List lst =
[
['a',2],
['b',5],
['c',3],
['d',1],
];
Run Code Online (Sandbox Code Playgroud)
所以才会变成这样。
[
['d',1],
['a',2],
['c',3],
['b',5],
];
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?是否可以通过for循环和sort()组合来实现?
我正在尝试使用从 python 文件到.kv文件的变量,所以我搜索了类似的问题并找到了使用Property和编码的方式:
# in python file
class Test2App(App):
abcd = StringProperty('test')
def build(self):
return presentation
# in kv file
<MyButton@Button>:
text: "contents (%s)"%(app.abcd)
background_color: (255, 255, 255,1)`
Run Code Online (Sandbox Code Playgroud)
并出现错误。
AttributeError: 'NoneType' object has no attribute 'bind'
File "/usr/local/lib/python2.7/dist-packages/kivy/lang/builder.py", line 249, in create_handler
return eval(value, idmap), bound_list
File "/root/Desktop/hi/t2.kv", line 61, in <module>
text: "contents (%s)"%(app.abcd)
File "/usr/local/lib/python2.7/dist-packages/kivy/lang/parser.py", line 75, in __getattribute__
object.__getattribute__(self, '_ensure_app')()
File "/usr/local/lib/python2.7/dist-packages/kivy/lang/parser.py", line 70, in _ensure_app
app.bind(on_stop=lambda instance:
File "/usr/local/lib/python2.7/dist-packages/kivy/lang/builder.py", line 615, in …Run Code Online (Sandbox Code Playgroud) return
Container(
color: Colors.transparent,
child:
Column(
children: <Widget>[
Container(
color: Colors.transparent,
height: 30,
child:
RaisedButton(
child:
Column(
children: <Widget>[
Text("Test"),
],
),
color: Colors.transparent,
elevation: 0,
splashColor: Colors.transparent,
//onPressed: () {
// Navigator.push(context, MaterialPageRoute(builder: (context) => ToSchoolScreen()));
//},
)
),
],
)
);
Run Code Online (Sandbox Code Playgroud)
我有一个像上面这样的代码。我想在几秒钟后返回这个容器。但如果我Future像这样直接使用
return
Future.delayed(Duration(milliseconds: 500), () {
Container(
color: Colors.transparent,
child:
Column(
children: <Widget>[
Container(
color: Colors.transparent,
height: 30,
child:
RaisedButton(
child:
Column(
children: <Widget>[
Text("Test"),
],
),
color: Colors.transparent,
elevation: 0,
splashColor: Colors.transparent,
//onPressed: () …Run Code Online (Sandbox Code Playgroud)