beeware / toga

A Python native, OS native GUI toolkit.
https://toga.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
4.35k stars 670 forks source link

NotImplementedError: Toga's Android backend doesn't implement OptionContainer #2377

Closed lihuaming07 closed 9 months ago

lihuaming07 commented 9 months ago

Describe the bug

image The console tells me that "Toga's Android backend doesn't implement OptionContainer" while I see the official document https://toga.readthedocs.io/en/latest/reference/api/containers/optioncontainer.html#toga.OptionContainer https://toga.readthedocs.io/en/latest/reference/widgets_by_platform.html claims the contrary view.

My codes: def show_ben_gui(self): self.main_box.clear() if not getattr(self, 'correction_book', None): self.correction_book = toga.Box() self.favor_book = toga.Box() self.ben_container = toga.OptionContainer( # line 176 mentioned in the exception content=[ ("主页", toga.Box()), ("错题本", self.correction_book), ("收藏本", self.favor_book) ] ) self.ben_container.on_select = self.ben_selected self.ben_container.current_tab = "错题本" self.main_window.content = self.ben_container

Steps to reproduce

  1. Use the OptionContainer widget
  2. Run cmd with the Program path
  3. input "briefcase run android -u -r"
  4. See error

Expected behavior

It would run formally like the official docx..

Screenshots

No response

Environment

Logs

BUILD SUCCESSFUL in 3s
41 actionable tasks: 7 executed, 34 up-to-date
Building... done

[aixuexi] Built build\aixuexi\android\gradle\app\build\outputs\apk\debug\app-debug.apk

[aixuexi] Starting app on Pixel 4 XL (98281FFBA00BE7) (device ID 98281FFBA00BE7)

[aixuexi] Installing app...
Stopping old versions of the app... done

Installing new app version... done

Launching app... done

[aixuexi] Following device log output (type CTRL-C to stop log)...
===========================================================================
--------- beginning of main
I/zhiyuan.aixuex: Late-enabling -Xcheck:jni
D/ProcessState: Binder ioctl to enable oneway spam detection failed: Invalid argument
D/CompatibilityChangeReporter: Compat change id reported: 171979766; UID 10253; state: ENABLED
V/GraphicsEnvironment: ANGLE Developer option for 'com.zhiyuan.aixuexi' set to: 'default'
V/GraphicsEnvironment: ANGLE GameManagerService for com.zhiyuan.aixuexi: false
V/GraphicsEnvironment: Updatable production driver is not supported on the device.
D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true
D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true
D/MainActivity: onCreate() start
W/zhiyuan.aixuex: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (unsupported, reflection, allowed)
W/zhiyuan.aixuex: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed)
D/MainActivity: Starting Python
W/native.stderr: Could not find platform independent libraries <prefix>
W/native.stderr: Could not find platform dependent libraries <exec_prefix>
W/native.stderr: Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
W/zhiyuan.aixuexi: type=1400 audit(0.0:34477): avc: granted { execute } for path="/data/data/com.zhiyuan.aixuexi/files/chaquopy/bootstrap-native/arm64-v8a/_sha512.so" dev="dm-12" ino=95492 scontext=u:r:untrusted_app:s0:c253,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c253,c256,c512,c768 tclass=file app=com.zhiyuan.aixuexi
W/zhiyuan.aixuexi: type=1400 audit(0.0:34478): avc: granted { execute } for path="/data/data/com.zhiyuan.aixuexi/files/chaquopy/bootstrap-native/arm64-v8a/_random.so" dev="dm-12" ino=114457 scontext=u:r:untrusted_app:s0:c253,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c253,c256,c512,c768 tclass=file app=com.zhiyuan.aixuexi
W/zhiyuan.aixuexi: type=1400 audit(0.0:34479): avc: granted { execute } for path="/data/data/com.zhiyuan.aixuexi/files/chaquopy/bootstrap-native/arm64-v8a/binascii.so" dev="dm-12" ino=95475 scontext=u:r:untrusted_app:s0:c253,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c253,c256,c512,c768 tclass=file app=com.zhiyuan.aixuexi
W/zhiyuan.aixuexi: type=1400 audit(0.0:34480): avc: granted { execute } for path="/data/data/com.zhiyuan.aixuexi/files/chaquopy/bootstrap-native/arm64-v8a/mmap.so" dev="dm-12" ino=88519 scontext=u:r:untrusted_app:s0:c253,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c253,c256,c512,c768 tclass=file app=com.zhiyuan.aixuexi
W/asset   : seek out of range: want -20, end=22
W/zhiyuan.aixuexi: type=1400 audit(0.0:34481): avc: granted { execute } for path="/data/data/com.zhiyuan.aixuexi/files/chaquopy/AssetFinder/stdlib-arm64-v8a/_posixsubprocess.so" dev="dm-12" ino=121185 scontext=u:r:untrusted_app:s0:c253,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c253,c256,c512,c768 tclass=file app=com.zhiyuan.aixuexi
D/MainActivity: Running main module aixuexi
I/python.stdout: Python app launched & stored in Android Activity class
I/python.stdout: Toga app: onCreate
D/MainActivity: onCreate() complete
D/MainActivity: onStart() start
I/python.stdout: Toga app: onStart
D/MainActivity: onStart() complete
D/MainActivity: onResume() start
I/python.stdout: Toga app: onResume
D/MainActivity: onResume() complete
I/AdrenoGLES-0: QUALCOMM build                   : 85da404, I46ff5fc46f
I/AdrenoGLES-0: Build Date                       : 11/30/20
I/AdrenoGLES-0: OpenGL ES Shader Compiler Version: EV031.31.04.01
I/AdrenoGLES-0: Local Branch                     : promo490_3_Google
I/AdrenoGLES-0: Remote Branch                    : 
I/AdrenoGLES-0: Remote Branch                    : 
I/AdrenoGLES-0: Reconstruct Branch               : 
I/AdrenoGLES-0: Build Config                     : S P 10.0.4 AArch64
I/AdrenoGLES-0: Driver Path                      : /vendor/lib64/egl/libGLESv2_adreno.so
D/hw-ProcessState: Binder ioctl to enable oneway spam detection failed: Invalid argument
I/AdrenoGLES-0: PFP: 0x016ee190, ME: 0x00000000
W/AdrenoUtils: <ReadGpuID_from_sysfs:197>: Failed to open /sys/class/kgsl/kgsl-3d0/gpu_model
W/AdrenoUtils: <ReadGpuID:221>: Failed to read chip ID from gpu_model. Fallback to use the GSL path
D/hw-ProcessState: Binder ioctl to enable oneway spam detection failed: Invalid argument
D/MainActivity: onPrepareOptionsMenu() start
D/MainActivity: onPrepareOptionsMenu() complete
D/MainActivity: onPrepareOptionsMenu() start
D/MainActivity: onPrepareOptionsMenu() complete
I/python.stdout: window size (411, 769)
I/python.stdout: mobile
I/python.stdout: mode:��
W/python.stderr: Error in handler: Toga's Android backend doesn't implement OptionContainer
W/python.stderr: Traceback (most recent call last):
W/python.stderr:   File "/data/data/com.zhiyuan.aixuexi/files/chaquopy/AssetFinder/requirements/toga/handlers.py", line 80, in _handler
W/python.stderr:   File "/data/data/com.zhiyuan.aixuexi/files/chaquopy/AssetFinder/app/aixuexi/app.py", line 140, in <lambda>
W/python.stderr:   File "/data/data/com.zhiyuan.aixuexi/files/chaquopy/AssetFinder/app/aixuexi/app.py", line 169, in begin_mode
W/python.stderr:   File "/data/data/com.zhiyuan.aixuexi/files/chaquopy/AssetFinder/app/aixuexi/app.py", line 176, in show_ben_gui
W/python.stderr:   File "/data/data/com.zhiyuan.aixuexi/files/chaquopy/AssetFinder/requirements/toga/widgets/optioncontainer.py", line 407, in __init__
W/python.stderr:   File "/data/data/com.zhiyuan.aixuexi/files/chaquopy/AssetFinder/requirements/toga_android/factory.py", line 76, in __getattr__
W/python.stderr: NotImplementedError: Toga's Android backend doesn't implement OptionContainer

Additional context

No response

freakboy3742 commented 9 months ago

You're looking at latest branch of the documentation; but using the 0.4.1 branch. If you look at the stable version of the docs, they'll point to the 0.4.1 docs, which indicate OptionContainer isn't available on Android.

OptionContainer has been implemented since the release of 0.4.1, and will be included in the upcoming 0.4.2 release (which should be released later today).