我已经创建了一个程序,在运行时在stdoutput上打印一些指令。当我在windows上执行应用程序时,我可以看到它们,但是当我在android设备三星S3上运行相同的应用程序时,我在任何地方都看不到打印语句的输出。

有时我们可以看到。设备上的kivy目录与程序位于同一目录中,但这些日志文件也包含kivy特定的日志,但它们忽略打印语句输出。

任何人都可以给一些建议,如何使用它。..

有帮助吗?

解决方案

使用adb n.原木,原木 要获取应用程序的输出,或使用在线可用的应用程序之一,以帮助显示"Python"的日志和grep。

以上详细步骤::

在设备上启用开发人员选项(谷歌是你的朋友)。然后启用 usb调试.

enter image description here 图片取自 http://androidfannetwork.com/

然后使用usb电缆将设备连接到pc,然后键入 adb devices 在你的控制台里。它应该显示您的设备(可能会有一个提示,要求您提供连接到计算机的权限)。

一种更简单的方法是在小部件上使用视觉指示,而不是在控制台上打印。你可以为你的应用程序创建一个函数 bubprint

from kivy.core.window import Window
from kivy.clock import Clock
from kivy.factory import Factory
from kivy.lang import Builder

Builder.load_string('''
<InfoBubble@Bubble>
    # declare our message StringProperty
    message: 'empty message'
    # let the bubble be of 200 device pixels
    # and expand as necessary on the height
    # depending on the message + 20 dp of padding.
    size_hint: None, None
    show_arrow: False
    pos_hint: {'top': 1, 'right': 1}
    size: dp(200), lbl.texture_size[1] + dp(20)
    Label:
        id: lbl
        text: root.message
        # constraint the text to be displayed within
        # the bubble width and have it be unrestricted
        # on the height.
        text_size: root.width - dp(20), None
''')

def bubbprint(self, message):
    message = repr(message)
    if not self.info_bubble:
        self.info_bubble = Factory.InfoBubble()
    self.info_bubble.message = message

    # Check if bubble is not already on screen
    if not self.info_bubble.parent:
        Window.add_widget(self.info_bubble)

    # Remove bubble after 2 secs
    Clock.schedule_once(lambda dt:
        Window.remove_widget(self.info_bubble), 2)

其他提示

Kivy发射器忽略 print().所以,使用 logging.info() 相反。

在main.py:

import logging
....
    logging.info('any strings you want to output')

和日志文件在 .../kivy/your_app/.kivy/logs/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top