由于我是QPython和kivy的新手,我遇到了一个可能很容易消除但我不知道怎么做的问题。 我有一个应用程序,它捕获QR码,然后在屏幕上显示QR码的内容。问题是,我的应用程序在扫描代码后立即退出。 这是我的代码:
#-*-coding:utf8;-*-
#qpy:2
#qpy:kivy
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.clock import Clock
from kivy.uix.gridlayout import GridLayout
from kivy.graphics import Color, Ellipse, Line
from BarQR_seq import Sequence, Barcode_reader
class Grid(GridLayout):
def __init__(self, **kwargs):
GridLayout.__init__(self, **kwargs)
self.cols = 2
self.add_widget(Widgets())
class Widgets(Widget):
def __init__(self, **kwargs):
Widget.__init__(self, **kwargs)
self.readseq_button = Button(text="Launch")
self.sequence = ""
self.seq_id = ""
self.readseq_button.bind(on_press=self.run_barcode)
self.add_widget(self.readseq_button)
def run_barcode(self, instance):
bcr = Barcode_reader()
bcr.capture_barcode()
seq = Sequence(bcr.barcode)
seq.get_sequence()
seq.get_id()
self.sequence = seq.seq
self.seq_id = seq.seq_id
def display_results(self):
self.seq_label = Label(text="blablabla")
return self.add_widget(self.seq_label)
class Bar_UI(App):
def build(self):
barcode = Widgets()
barcode.display_results()
return barcode
Bar_UI().run()
因此,如果单击该按钮,则运行run_barcode()函数。此函数对此处未包含的另一个类进行操作,但bcr.capture_barcode()只运行以下QPython内置方法:
droid = androidhelper.Android()
self.barcode = droid.scanBarcode()
扫描完代码应用程序后关闭而不创建标签。
你知道这是什么问题吗?
编辑: 日志说:
[Device information]
f70n_global_com,android:4.4.2,sdk:19
[Recent error information]
[QPython output]
[INFO ] [Kivy ] v1.9.0
[INFO ] [Python ] v2.7.2 (default, Nov 2 2015, 01:07:37)
[GCC 4.9 20140827 (prerelease)]
[INFO ] [Factory ] 173 symbols loaded
/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/kivy/core/image/img_pygame.py:13: RuntimeWarning: import cdrom: No module named cdrom
(ImportError: No module named cdrom)
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_pygame, img_pil (img_ffpyplayer ignored)
[INFO ] [Text ] Provider: pygame
[DEBUG ] [App ] Loading kv <./bar_ui.kv>
[DEBUG ] [App ] kv <./bar_ui.kv> not found
[INFO ] [Window ] Provider: pygame
[DEBUG ] [WinPygame ] Set window to fullscreen mode
[DEBUG ] [Window ] Display driver android
[DEBUG ] [Window ] Actual window size: 480x762
[INFO ] [GL ] OpenGL version <OpenGL ES 3.0 V@66.0 AU@ (CL@)>
[INFO ] [GL ] OpenGL vendor <Qualcomm>
[INFO ] [GL ] OpenGL renderer <Adreno (TM) 305>
[INFO ] [GL ] OpenGL parsed version: 3, 0
[INFO ] [GL ] Texture max size <4096>
[INFO ] [GL ] Texture max units <16>
[DEBUG ] [Shader ] Fragment compiled successfully
[DEBUG ] [Shader ] Vertex compiled successfully
[DEBUG ] [ImagePygame ] Load </data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/kivy/data/glsl/default.png>
[INFO ] [Support ] Android install hooks
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[DEBUG ] [Resource ] add </system/fonts> in path list
[DEBUG ] [Resource ] add </data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/kivy/data/fonts> in path list
[INFO ] [OSC ] using <thread> for socket
[DEBUG ] [Base ] Create provider from android
[INFO ] [Base ] Start application main loop
[INFO ] [Android ] found 17 joystick
[INFO ] [Android ] create joystick <0>
[INFO ] [Android ] discard joystick <0> cause no button
[INFO ] [Android ] create joystick <1>
[INFO ] [Android ] create joystick <2>
[INFO ] [Android ] create joystick <3>
[INFO ] [Android ] create joystick <4>
[INFO ] [Android ] create joystick <5>
[INFO ] [Android ] create joystick <6>
[INFO ] [Android ] create joystick <7>
[INFO ] [Android ] create joystick <8>
[INFO ] [Android ] create joystick <9>
[INFO ] [Android ] create joystick <10>
[INFO ] [Android ] create joystick <11>
[INFO ] [Android ] create joystick <12>
[INFO ] [Android ] create joystick <13>
[INFO ] [Android ] create joystick <14>
[INFO ] [Android ] create joystick <15>
[INFO ] [Android ] create joystick <16>
[INFO ] [GL ] NPOT texture support is available
[DEBUG ] [Atlas ] Load </data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/kivy/data/../data/images/defaulttheme.atlas>
[DEBUG ] [Atlas ] Need to load 1 images
[DEBUG ] [Atlas ] Load </data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/kivy/data/../data/images/defaulttheme-0.png>
[DEBUG ] [ImagePygame ] Load </data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/kivy/data/../data/images/defaulttheme-0.png>
[INFO ] [Android ] Must go into sleep mode, check the app
[INFO ] [Android ] App doesn't support pause mode, stop.
[INFO ] [Base ] Leaving application in progress...