Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added 'unload_zbarcam' that unload zbarcam.kv and xcamera.kv files #81

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/kivy_garden/zbarcam/zbarcam.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import os
from collections import namedtuple

Expand Down Expand Up @@ -210,3 +211,19 @@ def stop(self):
self.xcamera.play = False
if platform == "android":
self.xcamera._camera._release_camera()

def unload_zbarcam(self):
if ZBarCam.kv_loaded:
# unload zbarcam.kv
zbar_kv_path = os.path.join(MODULE_DIRECTORY, 'zbarcam.kv')
Builder.unload_file(zbar_kv_path)

# unload xcamera.kv
mod_path = os.path.dirname(
sys.modules['kivy_garden.xcamera'].__file__
)
xcam_kv_path = os.path.join(mod_path, 'xcamera.kv')
Builder.unload_file(xcam_kv_path)

# set kv_loaded = false
ZBarCam.kv_loaded = False