Kivy-哪里截图[截图()]保存在Android? [英] Kivy- Where are screenshots[screenshot()] saved on Android?

查看:270
本文介绍了Kivy-哪里截图[截图()]保存在Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的问题在哪里,当我我的Andr​​oid手机上使用的截图(),我不知道在哪里的截图结束。我都对着/存储/模拟/ 0 / Android的/数据,但没有被发现。甚至没有为我的应用程序有一个文件夹。

I am having a big problem where when I use screenshot() on my android phone, I don't know where the screenshot ends up. I have looked in /storage/emulated/0/Android/data but nothing to be found. There is not even a folder for my app there.

此外,有没有一种方法来设置使截图保存?也许一个更合乎逻辑的地方。

Also, is there a way to set where the screenshots are saved? Maybe to a more logical place.

下面是我的code:`

Here is my code:`

from random import random
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.graphics import Color, Ellipse, Line
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.stacklayout import StackLayout
from kivy.clock import Clock
from kivy.uix.slider import Slider
from kivy.core.window import Window


thickness = 5

class MyPaintWidget(Widget):

    def on_touch_down(self, touch):
        color = (random(), 1, 1)
        with self.canvas:
            Color(*color, mode='hsv')
            touch.ud['line'] = Line(points=(touch.x, touch.y), width = thickness)

    def on_touch_move(self, touch):
        if 'line' in touch.ud:
            touch.ud['line'].points += [touch.x, touch.y]







class MyPaintApp(App):

    def build(self):
        #layouts
        w = Widget()
        b = BoxLayout()
        f = FloatLayout()
        a = AnchorLayout(anchor_x= 'left', anchor_y= 'bottom')
        s = StackLayout()
        #widgets
        p = MyPaintWidget()
        cb = Button(text='Clear')
        lb = Button(pos = (150,0), text = "Large\nBrush", halign = "center")
        mb = Button(pos = (300,0), text = "Medium\nBrush", halign = "center")
        sb = Button(pos = (450,0), text = "Small\nBrush", halign = "center")
        svb = Button(pos = (600, 0), text = "Save", halign = "center")

        #adding the widgets
        w.add_widget(p)
        w.add_widget(cb)
        w.add_widget(lb)
        w.add_widget(mb)
        w.add_widget(sb)
        w.add_widget(svb)
        #w.export_to_png('ScreenShot.png')



        #bindings
        def clear_canvas(obj):
            p.canvas.clear()
        cb.bind(on_release=clear_canvas)

        def large_brush(obj):
            global thickness
            thickness = 15
        lb.bind(on_release=large_brush)

        def medium_brush(obj):
            global thickness
            thickness = 10
        mb.bind(on_release=medium_brush)

        def small_brush(obj):
            global thickness
            thickness = 5
        sb.bind(on_release=small_brush)


        def Screenshot(obj):
            global Screenshotnum
            Window.screenshot(name="Screenshot.png")

        svb.bind(on_release=Screenshot)


        return w


if __name__ == '__main__':
   MyPaintApp().run()`

忽略了export_to_png的一部分

Disregard the "export_to_png" part

推荐答案

的截图保存到指定的路径,在这种情况下,只是在当前目录中,这可能是某处的文件名, /数据/数据​​,不会被其他应用程序访问,除非你有root权限。您可以检查该目录是在脚本中的东西,可能与 os.getcwd()

The screenshot is saved to the path you specify, in this case just a filename in the current directory, which is probably somewhere in /data/data and won't be accessible to other applications unless you have root access. You can check what the directory is within your script, probably with os.getcwd().

您可能只需要通过文件路径要保存为屏幕截图参数外部存储。一般情况下,可以查询android的API与pyjnius得到的文件路径的android建议您的应用程序应该使用。

You can probably just pass the external storage filepath you want to save to as the argument for screenshot. In general, you could query the android api with pyjnius to get the filepath android recommends your application should use.

这篇关于Kivy-哪里截图[截图()]保存在Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆