0

I am trying to create a app on Android with which you fill in a few TextInputs and then give your signature on a marked space left for that, I have 2 buttons, one for clearing and one for exporting the window as a png, however when I build this as a .apk and then run it on my Tablet everything still looks fine, and pressing the exporting button don't give a error, but I can't find an image for the life of me, someone said to look in the directory the code is in, but in my case its a app (.apk), I'll add my code, even though I don't think it has much to do with the problem.

__version__ = "0.2"
from random import random
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.graphics import Color, Ellipse, Line
from kivy.core.window import Window
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.gridlayout import GridLayout
from kivy.config import Config
from kivy.base import EventLoop


class MyPaintWidget(Widget):
    Window.clearcolor = (0.95, 0.95, 0.85, 1)

    def on_touch_down(self, touch):
        color = (0,0,0)
        with self.canvas:
            Color(*color, mode='hsv')
            d = 3
            Ellipse(pos=(touch.x - d / 2, (touch.y - d / 2)+50), size=(d, d))
            touch.ud['line'] = Line(points=(touch.x, touch.y+50),width=1.5)

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


class WaentjiesApp(App):
    display_width = 1200
    global parent
    def build(self):
        global parent
        Window.size = (self.display_width, 500)
        parent = FloatLayout()
        self.painter = MyPaintWidget()
        save_button = Button(text = 'Save',pos=(0,0),size_hint=(.20,.20),on_release=self.save_canvas)
        clear_button = Button(text = 'Clear',pos=(300,0),size_hint=(.20,.20),on_release=self.clear_canvas)
        name_text = TextInput(text='',pos=(0,370),size_hint=(.15,.15))
        van_text = TextInput(text='',pos=(200,370),size_hint=(.15,.15))
        adres_text = TextInput(text='',pos=(0,220),size_hint=(.15,.15))
        waentjie_text = TextInput(text='',pos=(200,220),size_hint=(.15,.15))
        name_label = Label(text='Naam',pos=(0,450),size_hint=(.15,.15),color=(0,0,0,1))
        van_label = Label(text='Van',pos=(200,450),size_hint=(.15,.15),color=(0,0,0,1))
        adres_label = Label(text='Adres',pos=(0,300),size_hint=(.15,.15),color=(0,0,0,1))
        waentjie_label = Label(text='Waentjie',pos=(200,300),size_hint=(.15,.15),color=(0,0,0,1))
        handtekening1_label = Label(text='Handtekening',pos=(400,350),size_hint=(.15,.15),color=(0,0,0,1))
        handtekening2_label = Label(text='......................................................................................................................................',pos=(600,190),size_hint=(.15,.15),color=(0,0,0,0.5))
        agtergrond = Label()
        parent.add_widget(handtekening2_label)
        parent.add_widget(self.painter)
        parent.add_widget(save_button)
        parent.add_widget(clear_button)
        parent.add_widget(name_text)
        parent.add_widget(van_text)
        parent.add_widget(adres_text)
        parent.add_widget(name_label)
        parent.add_widget(van_label)
        parent.add_widget(adres_label)
        parent.add_widget(waentjie_text)
        parent.add_widget(waentjie_label)
        parent.add_widget(handtekening1_label)
        return parent

    def save_canvas(self, obj):
        global parent
        parent.export_to_png('b.png')

    def clear_canvas(self, obj):
        self.painter.canvas.clear()


WaentjiesApp().run()

some of the variables and names might seem weird, but English is not my first language so I tend to choose other-language names

4

1 回答 1

2

该文件保存在当前目录中,您可以通过os.path.realpath('.')脚本访问该目录。其他应用程序无法访问此目录。如果您想从其他应用程序访问该文件,请将其保存在外部存储目录中的某个位置(使用 Kivy,您可以使用App.user_data_dir)。

于 2016-07-18T19:41:16.400 回答