environment: add an option to prevent parsing command line argument as kivy arguments. Ref: #2873

This commit is contained in:
Mathieu Virbel 2015-01-21 11:51:55 +01:00
parent eca95cf074
commit 6f8ed55b70
2 changed files with 20 additions and 1 deletions

View File

@ -52,6 +52,12 @@ KIVY_SDL2_PATH
.. versionadded:: 1.9.0
.. warning::
Must be used during the compilation of Kivy. It is not required for the
execution.
Configuration
-------------
@ -68,6 +74,17 @@ KIVY_NO_FILELOG
KIVY_NO_CONSOLELOG
If set, logs will be not print on the console
KIVY_NO_ARGS
If set, the argument passed in command line will not be parsed and used by Kivy.
Ie, you can safely make a script or an app with your own arguments without
requiring the `--` delimiter::
import os
os.environ["KIVY_NO_ARGS"] = "1"
import kivy
.. versionadded:: 1.9.0
Restrict core to specific implementation
----------------------------------------

View File

@ -282,7 +282,9 @@ if not environ.get('KIVY_DOC_INCLUDE'):
Logger.setLevel(level=level)
# Can be overrided in command line
if 'KIVY_UNITTEST' not in environ and 'KIVY_PACKAGING' not in environ:
if ('KIVY_UNITTEST' not in environ and
'KIVY_PACKAGING' not in environ and
'KIVY_NO_ARGS' not in environ):
# save sys argv, otherwize, gstreamer use it and display help..
sys_argv = sys.argv
sys.argv = sys.argv[:1]